diff options
| author | Omar Rizwan <omar@omar.website> | 2023-09-26 23:07:27 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-09-26 23:07:27 +0000 |
| commit | ef73ec928b677f6c9ff3024cc09a926b48438964 (patch) | |
| tree | fdfbab179198b02395ce5f200927a9acc29f42e3 /virtual-programs | |
| parent | display: Fix more glyph angles (diff) | |
| download | folk-ef73ec928b677f6c9ff3024cc09a926b48438964.tar.gz folk-ef73ec928b677f6c9ff3024cc09a926b48438964.zip | |
display: Reintroduce stroke color support
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/display.folk | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index 3fc02d85..cc31575d 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -33,6 +33,8 @@ On process { Gpu::ImageManager::imageManagerInit namespace eval Display { + namespace eval Colors { source "pi/Colors.tcl" } + variable rotate [Gpu::fn {vec2 v float a} vec2 { float s = sin(a); float c = cos(a); @@ -153,7 +155,7 @@ On process { return mix(vec4(0, 0, 0, 0), vec4(1, 1, 1, 1), opacity); }] - variable line [Gpu::pipeline {vec2 from vec2 to float thickness} { + variable line [Gpu::pipeline {vec2 from vec2 to float thickness vec4 color} { vec2 vertices[4] = vec2[4]( min(from, to) - thickness, vec2(max(from.x, to.x) + thickness, min(from.y, to.y) - thickness), @@ -169,17 +171,22 @@ On process { q = abs(q) - vec2(l, thickness)*0.5; float dist = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0); - return dist < 0.0 ? vec4(1, 0, 1, 1) : vec4(0, 0, 0, 0); + return dist < 0.0 ? color : vec4(0, 0, 0, 0); }] proc start {} { Gpu::drawStart } + proc getColor {color} { + if {[info exists Colors::$color]} { return [set Colors::$color] } \ + else { return $Colors::white } + } + proc stroke {points width color} { variable line for {set i 0} {$i < [expr {[llength $points] - 1}]} {incr i} { set from [lindex $points $i] set to [lindex $points [expr $i+1]] - Gpu::draw $line $from $to $width + Gpu::draw $line $from $to $width [getColor $color] } } proc circle {x y radius thickness color} {} |
