-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request : Add option to size Object strokeWidth independently of scale #2012
Comments
i tell you clearly my opinion, i do not like this. In short i would be more for a solution like this: Every corner as a configurable icon and function. Also i m against something that is called lockStrokeWidth and actually change the strokeWidth 60 times per second when you resize the object. |
i m aware the fact that a square, pulled from one side to be a rect, becomes a terrible 2 different sized borders object. but i do not think that a simple true / false var is the solution. a more configurable scenario will solve this defect and more request in future. |
@asturur just for you information, my propososal of It's annoying however. My current version of fabric contains far too much in the way of extensions and patches in order to get my desired behaviour. And most of it is to make fabric closer to the behaviour of commercial editors like adobe illustrator etc. It would be great to get some of these things in the core library. |
i know i know, that s why i m for a more configurable option other than another bool property. but anyway i m just a frequent contributor, and so, as you i m telling my opinion. |
@asturur indeed. I agree... All I care about is getting this kind of natural/native app behaviour into the core library. Whether it be via individual object properties or by global options as you suggest doesn't matter to me. |
I'm torn between adding even more complexity to Fabric and having a pretty common/useful feature such as this one (there were few requests for it in the past as well). Marking as "possible feature" for now. |
After a bit of research i've found that this is actually extremely easy to implement perfectly. All it requires is that the transform is restored before the actual stroke. Therefore this could be implemented for each shape/object individually with a single call to
Or it could be implemented globally by modifying fabrics Also a small modification to I've just tried it out by hacking the fabric source code directly in the Polygon class and it works perfectly. Take a look at this for more info: |
@kangax Here's a quick demo with a couple of monkey patched functions Obviously this is using version Better to implement it on a per object basis though in my opinion. All it requires is restoring the context just before applying the stroke. Then reapplying the previous transform just before drawing the controls. |
@gordyr feel free to send a PR, and I'll take a look at it :) |
Hi guys, I have been fighting against this for the last couple of days. After a lot of tries I could make it work. |
Hello, thanks all for your help. |
In most visual editors when you set a border or
strokeWidth
of an object such as a circle or rectangle the width is maintained at its correct pixel dimensions as you scale the object with the controls.e.g If I draw a rectangle and set its border (strokeWidth) to 2px, then drag the corner controls so that it is then 3 times its original size, the width of the border outline would remain at 2px.
I understand the current behaviour and believe in many scenarios it is desirable. however for many others it is certainly not.
I would like to propose adding a property to the
Object
class perhaps something likelockStrokeWidth
which would then implement the suggested behaviour.This would also be very useful when dealing with text strokes in
IText
.As far as I am aware this should be reasonably simple to approximate by simply dividing by the objects
scale
(Math.max(this.getScaleX(), this.getScaleY())
) properties in_setStrokeStyles
and also_calculateCurrentDimensions
. which would work very well for most objects.However a further improvement for the shape classes such like
Rect
andCircle
would be to have the controls actually set thewidth
andheight
properties of the objects themselves while forcing the scale properties to1
to ensure consistency with modern native editors.Any thoughts on this?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: