-
Notifications
You must be signed in to change notification settings - Fork 1
/
037_stroke_join_overlap.zig
43 lines (32 loc) · 1.2 KB
/
037_stroke_join_overlap.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: 0BSD
// Copyright © 2024 Chris Marchesi
//! Case: Draws overlapping strokes in different directions to test that joins
//! with extremely acute angles overlap properly.
const mem = @import("std").mem;
const z2d = @import("z2d");
pub const filename = "037_stroke_join_overlap";
pub fn render(alloc: mem.Allocator, aa_mode: z2d.options.AntiAliasMode) !z2d.Surface {
const width = 200;
const height = 200;
var sfc = try z2d.Surface.init(.image_surface_rgb, alloc, width, height);
var context = try z2d.Context.init(alloc, &sfc);
defer context.deinit();
context.setSource(.{ .rgb = .{ .r = 0xFF, .g = 0xFF, .b = 0xFF } });
context.setAntiAliasingMode(aa_mode);
context.setLineWidth(5);
context.setMiterLimit(4);
try context.moveTo(10, 10);
try context.lineTo(50, 90);
try context.lineTo(35, 50);
try context.moveTo(190, 10);
try context.lineTo(150, 90);
try context.lineTo(165, 50);
try context.moveTo(10, 190);
try context.lineTo(50, 110);
try context.lineTo(35, 150);
try context.moveTo(190, 190);
try context.lineTo(150, 110);
try context.lineTo(165, 150);
try context.stroke();
return sfc;
}