Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions spec/086_stroke_dash_close_multiple_join.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: 0BSD
// Copyright © 2024-2026 Chris Marchesi

//! Case: Renders a closed dashed path that traverses multiple corners on the
//! close. This tests that direction is retained on the close and the correct
//! caps are applied on the correct contours.
const Io = @import("std").Io;
const mem = @import("std").mem;

const z2d = @import("z2d");

pub const filename = "086_stroke_dash_close_multiple_join";

pub fn render(io: Io, alloc: mem.Allocator, aa_mode: z2d.options.AntiAliasMode) !z2d.Surface {
const width = 300;
const height = 300;
var sfc = try z2d.Surface.init(.image_surface_rgb, alloc, width, height);

var context = z2d.Context.init(io, alloc, &sfc);
defer context.deinit();
context.setSourceToPixel(.{ .rgb = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF } });
context.setAntiAliasingMode(aa_mode);
context.setDashes(&.{ 90, 30 });
context.setDashOffset(60);
context.setLineWidth(6);

try context.moveTo(50, 150);
try context.lineTo(150, 250);
try context.lineTo(250, 50);
try context.lineTo(50, 100);
try context.closePath();

try context.stroke();

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.
2 changes: 2 additions & 0 deletions spec/main_bench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const _082_stroke_hairline_clip = @import("082_stroke_hairline_clip.zig");
const _083_star_simplify_offset = @import("083_star_simplify_offset.zig");
const _084_offset_ghostty_conformance = @import("084_offset_ghostty_conformance.zig");
const _085_deja_sans_ignore_invalid_points = @import("085_deja_sans_ignore_invalid_points.zig");
const _086_stroke_dash_close_multiple_join = @import("086_stroke_dash_close_multiple_join.zig");

//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -222,6 +223,7 @@ pub fn main() !void {
try addPathBenchmark(&bench, _083_star_simplify_offset);
try addPathBenchmark(&bench, _084_offset_ghostty_conformance);
try addPathBenchmark(&bench, _085_deja_sans_ignore_invalid_points);
try addPathBenchmark(&bench, _086_stroke_dash_close_multiple_join);

var threaded: Io.Threaded = .init_single_threaded;
const io = threaded.io();
Expand Down
6 changes: 6 additions & 0 deletions spec/main_spec.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const _082_stroke_hairline_clip = @import("082_stroke_hairline_clip.zig");
const _083_star_simplify_offset = @import("083_star_simplify_offset.zig");
const _084_offset_ghostty_conformance = @import("084_offset_ghostty_conformance.zig");
const _085_deja_sans_ignore_invalid_points = @import("085_deja_sans_ignore_invalid_points.zig");
const _086_stroke_dash_close_multiple_join = @import("086_stroke_dash_close_multiple_join.zig");

//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -195,6 +196,7 @@ pub fn main() !void {
try pathExportRun(io, alloc, _083_star_simplify_offset);
try pathExportRun(io, alloc, _084_offset_ghostty_conformance);
try pathExportRun(io, alloc, _085_deja_sans_ignore_invalid_points);
try pathExportRun(io, alloc, _086_stroke_dash_close_multiple_join);
}

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -539,6 +541,10 @@ test "085_deja_sans_ignore_invalid_points" {
try pathTestRun(testing.io, testing.allocator, _085_deja_sans_ignore_invalid_points);
}

test "086_stroke_dash_close_multiple_join" {
try pathTestRun(testing.io, testing.allocator, _086_stroke_dash_close_multiple_join);
}

//////////////////////////////////////////////////////////////////////////////

fn compositorExportRun(io: Io, alloc: mem.Allocator, subject: anytype) !void {
Expand Down
2 changes: 2 additions & 0 deletions src/internal/tess/dashed_plotter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ const Plotter = struct {
// We need to replace the initial polygon with the outer due to the
// direction of the concat happened in.
self.initial_polygon.on.outer = self.outer;
// Retain clockwise direction from existing polygon
self.initial_polygon.on.clockwise_ = self.clockwise_;

// Our first cap points are based entirely off of the plotter state
// (not the initial state).
Expand Down
Loading