-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FillPlotter,StrokePlotter: ignore degenerate line_to
This fixes the plotters to just drop line_to movements when they refer to the current point. This should prevent unexpected artifacts that would occur by plotting things like degenerate joins, etc. This manifests in stroke more than anything else I think, fill seems fine, but we've included it there too (in addition to a unit test) for correctness.
- Loading branch information
1 parent
f6c5b38
commit 21c4d25
Showing
7 changed files
with
103 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: 0BSD | ||
// Copyright © 2024 Chris Marchesi | ||
|
||
//! Case: Ensure no-op (degenerate) lineto operations are accounted for | ||
//! properly and do not break strokes. | ||
const debug = @import("std").debug; | ||
const mem = @import("std").mem; | ||
|
||
const z2d = @import("z2d"); | ||
|
||
pub const filename = "041_stroke_noop_lineto"; | ||
|
||
pub fn render(alloc: mem.Allocator, aa_mode: z2d.options.AntiAliasMode) !z2d.Surface { | ||
const width = 18; | ||
const height = 36; | ||
const sfc = try z2d.Surface.init(.image_surface_rgb, alloc, width, height); | ||
|
||
var context: z2d.Context = .{ | ||
.surface = sfc, | ||
.pattern = .{ | ||
.opaque_pattern = .{ | ||
.pixel = .{ .rgb = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF } }, // White on black | ||
}, | ||
}, | ||
.anti_aliasing_mode = aa_mode, | ||
}; | ||
|
||
var path = z2d.Path.init(alloc); | ||
defer path.deinit(); | ||
|
||
try path.moveTo(9, 0); | ||
try path.lineTo(9, 9); | ||
try path.lineTo(0, 18); | ||
try path.lineTo(0, 18); | ||
|
||
try context.stroke(alloc, path); | ||
|
||
return sfc; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters