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

Shape selection (Z) can't pick the css body, html{color:xxx} color #602

Closed
TALANTO opened this issue Dec 29, 2016 · 3 comments
Closed

Shape selection (Z) can't pick the css body, html{color:xxx} color #602

TALANTO opened this issue Dec 29, 2016 · 3 comments
Labels

Comments

@TALANTO
Copy link

TALANTO commented Dec 29, 2016

To explain it simply go here http://juliandescottes.github.io/piskel/ draw something black (#000000), select the Shape selection tool and try to pick it up. The error will appear (click twice if not).

Next, go here http://www.piskelapp.com/ repeat the same think and it will work but if you draw something with #aaaaaa color, the same issue will appear.

Why? Because piskellapp.com has an additional CSS file which has body{color : #AAA;}. Basically if you change body color to a different color you can't pick the same color with the tool.

The error
screenshot from 2016-12-29 13-31-47
:

The same issue appear if you click with Shape selection tool outside the canvas of the image.
imported piskel
I'll put the error as text this time (it may be different from the first one).

piskel-packaged-min-2016-11-12-06-33.js:16 Uncaught TypeError: Cannot read property 'length' of undefined
at a.ShapeSelect.a.BaseSelect.drawSelectionOnOverlay_ (piskel-packaged-min-2016-11-12-06-33.js:16)
at a.ShapeSelect.onSelectStart_ (piskel-packaged-min-2016-11-12-06-33.js:16)
at a.ShapeSelect.a.BaseSelect.applyToolAt (piskel-packaged-min-2016-11-12-06-33.js:16)
at a.DrawingController.onMousedown_ (piskel-packaged-min-2016-11-12-06-33.js:11)
at HTMLDivElement.f (piskel-packaged-min-2016-11-12-06-33.js:1)
at HTMLDivElement.dispatch (piskel-packaged-min-2016-11-12-06-33.js:2)
at HTMLDivElement.h (piskel-packaged-min-2016-11-12-06-33.js:2)
a.BaseSelect.drawSelectionOnOverlay_ @ piskel-packaged-min-2016-11-12-06-33.js:16
a.ShapeSelect.onSelectStart_ @ piskel-packaged-min-2016-11-12-06-33.js:16
a.BaseSelect.applyToolAt @ piskel-packaged-min-2016-11-12-06-33.js:16
a.DrawingController.onMousedown_ @ piskel-packaged-min-2016-11-12-06-33.js:11
f @ piskel-packaged-min-2016-11-12-06-33.js:1
dispatch @ piskel-packaged-min-2016-11-12-06-33.js:2
h @ piskel-packaged-min-2016-11-12-06-33.js:2
piskel-packaged-min-2016-11-12-06-33.js:16

Uncaught TypeError: Cannot read property 'some' of undefined
at a.ShapeSelect.a.BaseSelect.isInSelection (piskel-packaged-min-2016-11-12-06-33.js:16)
at a.ShapeSelect.a.BaseSelect.applyToolAt (piskel-packaged-min-2016-11-12-06-33.js:16)
at a.DrawingController.onMousedown_ (piskel-packaged-min-2016-11-12-06-33.js:11)
at HTMLDivElement.f (piskel-packaged-min-2016-11-12-06-33.js:1)
at HTMLDivElement.dispatch (piskel-packaged-min-2016-11-12-06-33.js:2)
at HTMLDivElement.h (piskel-packaged-min-2016-11-12-06-33.js:2)
a.BaseSelect.isInSelection @ piskel-packaged-min-2016-11-12-06-33.js:16
a.BaseSelect.applyToolAt @ piskel-packaged-min-2016-11-12-06-33.js:16
a.DrawingController.onMousedown_ @ piskel-packaged-min-2016-11-12-06-33.js:11
f @ piskel-packaged-min-2016-11-12-06-33.js:1
dispatch @ piskel-packaged-min-2016-11-12-06-33.js:2
h @ piskel-packaged-min-2016-11-12-06-33.js:2

I hope you can understand. Thank you.

@TALANTO TALANTO changed the title Shape selection (Z) can't pick the css body, html{color:xxx} Shape selection (Z) can't pick the css body, html{color:xxx} color Dec 29, 2016
@juliandescottes
Copy link
Collaborator

Thanks for the report!

Looks like this is a weird side effect on the fallback strategy found in pskl.utils.ColorToInt:
https://github.com/juliandescottes/piskel/blob/master/src/js/utils/core.js#L208-L217

When we can't parse the color, we create a div and get the color from the div's computed style (which is why you get a different behavior depending on the body color).

We should

  • check if the fallback is ever called in other situations
  • change the fallback strategy to return a default color (black?)
  • reimplement getSimilarConnectedPixelsFromFrame to directly use visitConnectedPixels instead of being a hack on top of paintSimilarConnectedPixelsFromFrame

@TALANTO
Copy link
Author

TALANTO commented Jan 13, 2017

It's still not fully fixed. I assume that you couldn't understand my explanations so I made a video. Try those sites if won't work will upload again.

https://vid.me/ZKri
http://sendvid.com/nuava6va

@juliandescottes
Copy link
Collaborator

ah I missed the second part. fixed now, thanks

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

No branches or pull requests

2 participants