繁体   English   中英

Fabric.js:更改一个或多个选择的正方形/矩形颜色

[英]Fabric.js : Change one or multiple selection square/rectangle color

我正在开发一个使用Fabric.js库的项目。 我想知道如何更改当您想要选择一个或多个对象时出现的正方形/矩形。

是下图中的蓝色矩形:

在此处输入图片说明

我已经在改变一些样式,比如对象选择的角颜色、边框颜色等等:

fabric.Object.prototype.selection = !HelperJSViewBag.getValue("isMobile") && true;
fabric.Object.prototype.selectionColor = HelperJSViewBag.getValue("selectionColor").length > 0 ? HelperJSViewBag.getValue("selectionColor") : 'rgba(255,119,0,0.3)';
fabric.Object.prototype.rotationCursor = HelperJSViewBag.getValue('cursor_rotacao').length > 0 ? HelperJSViewBag.getValue('cursor_rotacao') : "crosshair";
fabric.Object.prototype.cornerSize = HelperJSViewBag.getValue("isMobile") ? (HelperJSViewBag.getValue("containerCornerSizeMobile") > 0 ? HelperJSViewBag.getValue("containerCornerSizeMobile") : 14) : (HelperJSViewBag.getValue("containerCornerSize") > 0 ? HelperJSViewBag.getValue("containerCornerSize") : 10);
fabric.Object.prototype.cornerColor = HelperJSViewBag.getValue("containerCornerColor").length > 0 ? HelperJSViewBag.getValue("containerCornerColor") : '#eee';
fabric.Object.prototype.borderColor = fabric.Object.prototype.cornerColor;
fabric.Object.prototype.transparentCorners = false;
fabric.Object.prototype.borderScaleFactor = HelperJSViewBag.getValue("borderScaleFactor") > 0 ? HelperJSViewBag.getValue("borderScaleFactor") : 1;
fabric.Object.prototype.hasRotatingPoint = !HelperJSViewBag.getValue("isMobile") && true;
fabric.Object.prototype.rotatingPointOffset = HelperJSViewBag.getValue("isMobile") ? 20 : 35;

 var canvas = new fabric.Canvas('canvas'); fabric.Canvas.prototype.set({ selectionColor : 'rgba(255,0,0,0.3)', selectionBorderColor : 'rgba(0, 255, 0, 0.3)', selectionLineWidth : 10, selectionDashArray : [3,3] });
 canvas { border: 2px dotted green; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.16/fabric.min.js"></script> <canvas id="canvas" width="400" height="400"></canvas>

您可以覆盖这些选择属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM