LingDong- / q5xjs

A small and fast alternative (experimental) implementation of p5.js
https://q5xjs.netlify.app/
The Unlicense
548 stars 25 forks source link

Fix push() and pop() ignoring some styles #11

Closed peilingjiang closed 3 years ago

peilingjiang commented 3 years ago

push() and pop() ignores several important style definitions, including noStroke or noFill, now as they are controlled directly in the library instead of by ctx. While the two functions only do ctx.save() and restore().

p5 web editor example - before, after

This PR is not ready to be merged yet, mainly because the result I got here is different from the one shown on the q5 demo page, and I don't know why. Also, I'm not sure if it's just a design choice. There are also several other things to do if there's actually a need for this PR -


Another minor change in the second commit is that I changed $.frameCount++ to ++$.frameCount as the latter is slightly faster.

LingDong- commented 3 years ago

Hi @peilingjiang,

Thanks a lot for the PR! Sounds good. I'll be happy to merge it when it's ready.

I totally forgot about those additional styles not remembered by ctx.save/restore. Thanks for helping with this!

For minification, I was doing it by manually copy-pasting to https://javascript-minifier.com/, the reason being that it seems libs like uglify etc. either doesn't produce correct result or doesn't compress as much ¯\(ツ)/¯ I'm also ok with doing that myself after the PR, along with version bumping, which I guess would be appropriate too.

Feel free to let me know when the PR is ready, thanks!

peilingjiang commented 3 years ago

Hi @LingDong-, I've minified the file and pushed this new commit. It should be ready to merge now. Could you handle the version bump and release? Thank you!

LingDong- commented 3 years ago

thanks a lot! I've bumped the version and published