-
-
Notifications
You must be signed in to change notification settings - Fork 133
renderer: support shape-rendering="crispEdges"
for aliased shapes
#2499
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
base: main
Are you sure you want to change the base?
Conversation
@OverloadedOrama Hello, Thanks for your contribution. I am curious about the practical use of this feature in user applications. Could you provide some tips on use cases? |
@OverloadedOrama One more question, do you really need to apply this per shape or scene? or is it applied to the full screen in the ThorVG canvas? |
@hermet Hello! I am working on a pixel art editor made with Godot, and I want to implement support for vector layers in order to have non-destructive shapes, and my idea is to construct a SVG behind the scenes that gets rasterized by Godot/ThorVG in order to be drawn in the canvas. This already can work fine, but all shapes are currently anti-aliased, with no option to turn it off, which doesn't work well with pixel art. So I thought to use the I think this needs to be applied per-shape, just like the attribute is per-shape in SVG, in order to allow users to choose which shapes are anti-aliased and which ones are not. |
@RuiwenTang @SergeyLebedkin Hello, could you please confirm with the GL/WG engine side if they can allow the AA option per shape? |
49972ae
to
25cf78c
Compare
I'm not sure why unit tests are failing. For some reason, if I uncomment either line 90 or line 91 on |
25cf78c
to
64945aa
Compare
64945aa
to
bf7c262
Compare
bf7c262
to
0f5cf9a
Compare
87ee4f3
to
9b43b93
Compare
shape-rendering="crispEdges"
for aliased shapes in the software renderershape-rendering="crispEdges"
for aliased shapes
b234c07
to
f1e9ce0
Compare
0f5cf9a
to
b0354d6
Compare
Thanks for your contribution. Still some considerations:
|
Hello @hermet, apologies for the late reply. I don't have a practical demo ready at the moment, but as I mentioned the reason I need this is because I want to add vector layers in my pixel art software, which is made with Godot, and I'd like to give users the option to disable AA so the shapes can look better for pixel art. If you think that adding a per-shape flag for AA is not needed and it can increase memory usage, then I completely understand and I'd be okay with a more global solution. What I'd ideally want though is for a way to toggle AA with SVG code. The idea for vector layers is to pass an SVG string and use Godot's Image.load_svg_from_string to turn SVG into a rasterized image. From what I understand, this uses ThorVG's software renderer behind the scenes. Using the |
9b6c8bc
to
a6ffb7a
Compare
7ceb794
to
43923a5
Compare
Implements #1869 for the software renderer. If the
shape-rendering="crispEdges"
attribute is used in the SVG, the software renderer does not use anti-aliasing for the shape's lines. The rest of theshape-rendering
values just default to anti-aliasing, I'm not sure how else to handle them. I tested it with svg2png and Godot and it seems to be working as intended.Tested using the following svg file:
Result png:

This is the first time I'm contributing to ThorVG, hopefully I did everything right. 😅