I have a group containing a text object and a rectangle object. When the group is scaled, I want the rectangle object to resize, but the text object remains the same size.
Can this be done?
Mathematics! for help!
Look at the violin!
http://jsfiddle.net/davidtorroija/w64bsnon/2/
var line; var canvas = this.__canvas = new fabric.Canvas('c'); fabric.Object.prototype.originX = fabric.Object.prototype.originY = 'center'; canvas.on({ 'object:scaling': function(p){ console.log('p',p.target.ScaleX ) //p.target._objects[0].scaleX = p.target.scaleX //p.target._objects[0].scaleY = p.target.scaleY //p.target.scaleX = 1 //p.target.scaleY = 1 if (p.target.scaleX < 1) p.target._objects[1].scaleX = 1 + (1 -p.target.scaleX ) else p.target._objects[1].scaleX = 1 / (p.target.scaleX) if (p.target.scaleY < 1) p.target._objects[1].scaleY = 1 + (1 -p.target.scaleY) else p.target._objects[1].scaleY = 1 / (p.target.scaleY) canvas.renderAll() }, }); var rect = new fabric.Rect({top: 110, left:110, height: 100, width: 100, fill:'#ccc'}) var text = new fabric.IText('pepe',{text: 'pepe',top: 110, left:110, height: 100, width: 100, fill:'#000'}) var group = new fabric.Group([rect,text]) canvas.add(group)
<script src="http://fabricjs.com/lib/fabric.js"></script> <canvas id="c" width="600" height="600"></canvas>
Source: https://habr.com/ru/post/959413/More articles:Find a specific iBeacon after I enter the Region (background) - iosA good way to null check a long list of parameters - javaHow to find and replace all occurrences of a substring in a string? - c ++Best way to check NULL for objects in Java - javaCSS animated box tag - htmlHow to check model in django rest framework? - pythonMatlab displays several three-dimensional lines - matlabHow is Spring Bootstrap and Aspect implemented? - javahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/959417/add-additional-parameters-to-send-to-server-using-fineuploader&usg=ALkJrhi415iPiomZBcCLmESNiW0BEVYekQVS2013 disable web publishing Activity windo - visual-studioAll Articles