Comments (3)
I've made some progress on this.
The line, curve, polygon, rectangle, rounded rectangle, and ellipse tools all now support patterns and aliasing.
Remaining are the fill, brush, and pencil tools, as well as the eraser tool when used with right click to replace colors.
from jspaint.
Most of this stuff, along with #7 and #6, should be easy, but it's all complicated by trying to make everything anti-anti-aliased. Antialiasing is the default and only option (except when scaling images) in the Canvas API, but aliasing, aside from being retro, has the practical benefit that the fill tool naturally avoids leaving ugly seams along the edges of shapes, without having to have a tolerance setting.
I've been looking into using pixi.js for rendering shapes. It's not perfect: it doesn't support using an even-odd winding rule like mspaint uses, and 1px strokes on shapes don't work quite right... but it should definitely be a step up!
Filling shapes with patterns seems to work in Chrome, Firefox, and Edge. Did you select a filled style in the tool options? The default is no fill.
I think I'll be working on this soon (adding pixi.js) so even if there is a bug it probably won't be relevant for long. 😄
-
The brush and line tools currently use a cached offscreen canvas because of some slow aliased circle drawing code, so the pattern is applied only when rendering said canvas.
-
The eraser, airbrush, and rectangle tools, and currently also the rounded rectangle and ellipse tools although they're very inefficient because of it, use
fillRect
. They should all work with patterns. -
The curve and polygon tools don't yet support anti-anti-aliasing (AAA) so they just use the canvas API normally which means they work with patterns. The polygon actually tries to do AAA for the preview, for no particularly good reason, so it looks smeared like the line tool until it's finalized.
-
The fill tool uses an algorithm that replaces pixels in-place in an
ImageData
object, and I see a couple options for making it work with patterns:- rewrite it to keep track of the pixels it's affecting / has visited in a separate
ImageData
object, and then use that to draw the fill, as a mask for the selected pattern. - access the pattern data during the fill algorithm; there's no direct way to access a
Pattern
object's data, width or height, so it would need to be stored elsewhere.
- rewrite it to keep track of the pixels it's affecting / has visited in a separate
from jspaint.
This is done. I finished this up last year for the Winter Update (the Winter theme has candy cane patterns in the palette 💈🎨 )
from jspaint.
Related Issues (20)
- Unable to Rotate By Angle HOT 2
- "Width" field is not focused and selected when opening Image -> Attributes... HOT 3
- How to open multiple windows in electron macOS? HOT 2
- why does electron app make requests to internet when started? HOT 4
- Bucket tool went weird today HOT 5
- i cant draw after making 1 brushstroke or anything on the canvas HOT 3
- Pixel data offset field from the BMP header is ignored
- The Recover Document (Woah!) pop-up still occurs despite the following HOT 2
- Blended/Anti-Aliased edges on rectangle tool HOT 4
- every stroke i make does not save on the canvas and keeps deleting the previous one HOT 31
- [feature] comic creator
- Shortcut keys?
- Pasted screenshots show up twice as big (HiDPI Retina screenshot) HOT 1
- Error when changing eraser size with keyboard
- Internal copy not working on macOS Safari
- Error trying to paste a screenshot on Windows 11
- Errors trying to paste/open an SVG file
- Shift+Insert, Ctrl+Insert, and Ctrl+Delete shortcuts throw errors HOT 1
- .bmp file saves incorrectly
- [feature] Windows 3.1 style tools HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jspaint.