Skip to content
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

stroke is offset from fill. #5636

Closed
mildewey opened this issue Apr 14, 2019 · 2 comments · Fixed by #5668
Closed

stroke is offset from fill. #5636

mildewey opened this issue Apr 14, 2019 · 2 comments · Fixed by #5668

Comments

@mildewey
Copy link

Version

2.7.0

Test Case

http://jsfiddle.net/p7duxn9g/

Information about environment

Nodejs or browser? browser
Which browsers? chrome

Steps to reproduce

Create two identically shaped polygons, have one be fill-only and the other be stroke-only. Give the stroke a partially-transparent color.

Expected Behavior

The stroke is any of: entirely inside the boundary of the identical fill, entirely outside the boundary of the outside of the fill, centered on the boundary of the fill with half outside, half inside. Bonus points for configurability.

Actual Behavior

The stroke is down and to the right of the fill. On lines going in that direction, it (roughly) straddles the boundary of the fill. On lines going horizontal, vertical, or in the other slant to the down-left direction, the stroke is entirely to one side of the fill.
fabric-offset

@asturur
Copy link
Member

asturur commented Apr 14, 2019

Hi, i cannot check the fiddle from the phone, bit looking at what you are describing i think you are missing how top and left properties work.

two identical shapes fill only or stroke only will not be aligned because top and left will be offset of half strokeWidth.

the width and height of a shape and so its positioning does count strokeWidth too.

try to use originX and originY set to 'center' and should be easier to center them.

@asturur
Copy link
Member

asturur commented Apr 14, 2019

I better understand your point after seeing the fiddle.
http://jsfiddle.net/Lks8y7gh/
I can see 2 problems here:

  1. derived top and left from points array has to take in account strokeWidth too
  2. derived top and left from points array has to take in account originX,originY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants