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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
//! Geometric Shapes | U+25A0...U+25FF
//! https://en.wikipedia.org/wiki/Geometric_Shapes_(Unicode_block)
//!
//! ■ □ ▢ ▣ ▤ ▥ ▦ ▧ ▨ ▩ ▪ ▫ ▬ ▭ ▮ ▯
//! ▰ ▱ ▲ △ ▴ ▵ ▶ ▷ ▸ ▹ ► ▻ ▼ ▽ ▾ ▿
//! ◀ ◁ ◂ ◃ ◄ ◅ ◆ ◇ ◈ ◉ ◊ ○ ◌ ◍ ◎ ●
//! ◐ ◑ ◒ ◓ ◔ ◕ ◖ ◗ ◘ ◙ ◚ ◛ ◜ ◝ ◞ ◟
//! ◠ ◡ ◢ ◣ ◤ ◥ ◦ ◧ ◨ ◩ ◪ ◫ ◬ ◭ ◮ ◯
//! ◰ ◱ ◲ ◳ ◴ ◵ ◶ ◷ ◸ ◹ ◺ ◻ ◼ ◽︎◾︎◿
//!
//! Only a subset of this block is viable for sprite drawing; filling
//! out this file to have full coverage of this block is not the goal.
//!
const std = @import("std");
const Allocator = std.mem.Allocator;
const common = @import("common.zig");
const Thickness = common.Thickness;
const Corner = common.Corner;
const Shade = common.Shade;
const font = @import("../../main.zig");
/// ◢ ◣ ◤ ◥
pub fn draw25E2_25E5(
cp: u32,
canvas: *font.sprite.Canvas,
width: u32,
height: u32,
metrics: font.Metrics,
) !void {
_ = width;
_ = height;
switch (cp) {
// ◢
0x25e2 => try cornerTriangleShade(metrics, canvas, .br, .on),
// ◣
0x25e3 => try cornerTriangleShade(metrics, canvas, .bl, .on),
// ◤
0x25e4 => try cornerTriangleShade(metrics, canvas, .tl, .on),
// ◥
0x25e5 => try cornerTriangleShade(metrics, canvas, .tr, .on),
else => unreachable,
}
}
/// ◸ ◹ ◺
pub fn draw25F8_25FA(
cp: u32,
canvas: *font.sprite.Canvas,
width: u32,
height: u32,
metrics: font.Metrics,
) !void {
_ = width;
_ = height;
switch (cp) {
// ◸
0x25f8 => try cornerTriangleOutline(metrics, canvas, .tl),
// ◹
0x25f9 => try cornerTriangleOutline(metrics, canvas, .tr),
// ◺
0x25fa => try cornerTriangleOutline(metrics, canvas, .bl),
else => unreachable,
}
}
/// ◿
pub fn draw25FF(
cp: u32,
canvas: *font.sprite.Canvas,
width: u32,
height: u32,
metrics: font.Metrics,
) !void {
_ = cp;
_ = width;
_ = height;
try cornerTriangleOutline(metrics, canvas, .br);
}
pub fn cornerTriangleShade(
metrics: font.Metrics,
canvas: *font.sprite.Canvas,
comptime corner: Corner,
comptime shade: Shade,
) !void {
const float_width: f64 = @floatFromInt(metrics.cell_width);
const float_height: f64 = @floatFromInt(metrics.cell_height);
const x0, const y0, const x1, const y1, const x2, const y2 =
switch (corner) {
.tl => .{
0,
0,
0,
float_height,
float_width,
0,
},
.tr => .{
0,
0,
float_width,
float_height,
float_width,
0,
},
.bl => .{
0,
0,
0,
float_height,
float_width,
float_height,
},
.br => .{
0,
float_height,
float_width,
float_height,
float_width,
0,
},
};
var path = canvas.staticPath(5); // nodes.len = 0
path.moveTo(x0, y0); // +1, nodes.len = 1
path.lineTo(x1, y1); // +1, nodes.len = 2
path.lineTo(x2, y2); // +1, nodes.len = 3
path.close(); // +2, nodes.len = 5
try canvas.fillPath(
path.wrapped_path,
.{},
@enumFromInt(@intFromEnum(shade)),
);
}
pub fn cornerTriangleOutline(
metrics: font.Metrics,
canvas: *font.sprite.Canvas,
comptime corner: Corner,
) !void {
const float_thick: f64 = @floatFromInt(Thickness.light.height(metrics.box_thickness));
const float_width: f64 = @floatFromInt(metrics.cell_width);
const float_height: f64 = @floatFromInt(metrics.cell_height);
const x0, const y0, const x1, const y1, const x2, const y2 =
switch (corner) {
.tl => .{
0,
0,
0,
float_height,
float_width,
0,
},
.tr => .{
0,
0,
float_width,
float_height,
float_width,
0,
},
.bl => .{
0,
0,
0,
float_height,
float_width,
float_height,
},
.br => .{
0,
float_height,
float_width,
float_height,
float_width,
0,
},
};
var path = canvas.staticPath(5); // nodes.len = 0
path.moveTo(x0, y0); // +1, nodes.len = 1
path.lineTo(x1, y1); // +1, nodes.len = 2
path.lineTo(x2, y2); // +1, nodes.len = 3
path.close(); // +2, nodes.len = 5
try canvas.innerStrokePath(path.wrapped_path, .{
.line_cap_mode = .butt,
.line_width = float_thick,
}, .on);
}
|