blob: 60ac839e22c48658941b2fbeff7f0dcb7a28cf15 (
plain)
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
|
Wish the GPU compiles pipeline "circle" {
{vec2 center float radius float thickness vec4 color int filled} {
float r = radius + thickness;
vec2 vertices[4] = vec2[4](
center - r,
vec2(center.x + r, center.y - r),
vec2(center.x - r, center.y + r),
center + r
);
return vertices[gl_VertexIndex];
} {
float dist = length(gl_FragCoord.xy - center) - radius;
if (filled == 1) {
return (dist < thickness) ? color : vec4(0, 0, 0, 0);
} else {
return (dist < thickness && dist > 0.0) ? color : vec4(0, 0, 0, 0);
}
}
}
When /someone/ wishes to draw a circle with /...options/ {
set center [dict_getdef $options center ""]
if {$center eq ""} { set center [list [dict get $options x] [dict get $options y]] }
set radius [dict get $options radius]
set thickness [dict get $options thickness]
set color [getColor [dict get $options color]]
set filled [dict_getdef $options filled false]
set layer [dict_getdef $options layer 0]
Wish the GPU draws pipeline "circle" with arguments \
[list $center $radius $thickness $color [expr {$filled eq false ? 0 : 1}]] \
layer $layer
}
|