From 0ece21c189df93d85f5d59fa42ed497a3f012a5e Mon Sep 17 00:00:00 2001 From: Cristobal Sciutto Date: Fri, 27 Oct 2023 17:54:01 -0400 Subject: [PATCH 1/4] no collection for outline --- virtual-programs/outline.folk | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/virtual-programs/outline.folk b/virtual-programs/outline.folk index 1d6411cb..13f060b1 100644 --- a/virtual-programs/outline.folk +++ b/virtual-programs/outline.folk @@ -9,21 +9,9 @@ proc loopRegion {edges vertices width color} { Wish the GPU draws pipeline "line" with instances $instances } -When the collected matches for [list /someone/ wishes /thing/ is outlined /color/] are /matches/ { - set thingColors [dict create] - foreach match $matches { - dict lappend thingColors [dict get $match thing] [dict get $match color] - } - foreach thing [dict keys $thingColors] { - When $thing has region /region/ { - set thickness 0 - foreach color [dict get $thingColors $thing] { - # FIXME: assumes path - lassign $region vertices edges - loopRegion $edges $vertices [incr thickness 3] $color - } - } - } +When /someone/ wishes /thing/ is outlined /color/ & /thing/ has region /region/ { + lassign $region vertices edges + loopRegion $edges $vertices 3 $color } When /someone/ wishes /thing/ is outlined thick /color/ & /thing/ has region /region/ { From e92b0920b8f9523d89779edbab563ac076b60387 Mon Sep 17 00:00:00 2001 From: Cristobal Sciutto Date: Fri, 27 Oct 2023 17:54:10 -0400 Subject: [PATCH 2/4] neighbor callback --- virtual-programs/intersect.folk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/virtual-programs/intersect.folk b/virtual-programs/intersect.folk index 7755acbd..1aea9695 100644 --- a/virtual-programs/intersect.folk +++ b/virtual-programs/intersect.folk @@ -25,4 +25,8 @@ When /someone/ wishes /p/ has neighbors & /p/ has region /r/ & /p2/ has region / #Display::stroke [list [list $b2MaxX $b2MaxY] {500 500}] 3 white #Display::stroke [list [list $b2MinX $b2MinY] [list $b2MaxX $b2MaxY]] 10 blue } -} \ No newline at end of file +} + +When when /p/ has neighbor /n/ /lambda/ with environment /e/ { + Wish $p has neighbors +} From 4ab1d8922b54fe2945dcdb6b3272c52c71f28957 Mon Sep 17 00:00:00 2001 From: Cristobal Sciutto Date: Fri, 27 Oct 2023 18:00:12 -0400 Subject: [PATCH 3/4] scale as param --- virtual-programs/display/image.folk | 8 ++++---- virtual-programs/images.folk | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/virtual-programs/display/image.folk b/virtual-programs/display/image.folk index 23246d45..55a283e0 100644 --- a/virtual-programs/display/image.folk +++ b/virtual-programs/display/image.folk @@ -5,10 +5,10 @@ On process "display" { dict set ::pipelines "image" [Gpu::pipeline {sampler2D image vec2 imageSize vec2 pos float radians float scale fn rotate} { - vec2 a = pos + rotate(-imageSize/2, -radians); - vec2 b = pos + rotate(vec2(imageSize.x, -imageSize.y)/2, -radians); - vec2 c = pos + rotate(imageSize/2, -radians); - vec2 d = pos + rotate(vec2(-imageSize.x, imageSize.y)/2, -radians); + vec2 a = scale * (pos + rotate(-imageSize/2, -radians)); + vec2 b = scale * (pos + rotate(vec2(imageSize.x, -imageSize.y)/2, -radians)); + vec2 c = scale * (pos + rotate(imageSize/2, -radians)); + vec2 d = scale * (pos + rotate(vec2(-imageSize.x, imageSize.y)/2, -radians)); vec2 vertices[4] = vec2[4](a, b, d, c); return vertices[gl_VertexIndex]; } {fn invBilinear fn rotate} { diff --git a/virtual-programs/images.folk b/virtual-programs/images.folk index d8bcaf55..1be51424 100644 --- a/virtual-programs/images.folk +++ b/virtual-programs/images.folk @@ -343,7 +343,7 @@ When /someone/ wishes /p/ displays camera slice /slice/ & /p/ has region /r/ { Wish to draw an image with center $center image $slice radians 0 scale 1 } -When /someone/ wishes /p/ displays image /im/ { +When /someone/ wishes /p/ displays image /im/ with scale /s/ { set im [image load $im] When $p has region /r/ { # Compute a scale for im that will fit in the region width/height @@ -354,10 +354,14 @@ When /someone/ wishes /p/ displays image /im/ { # set scale [expr {min($width / [image width $im], # $height / [image height $im])}] # Wish $p is labelled $im - Wish to draw an image with center $center image $im radians [region angle $r] + Wish to draw an image with center $center image $im radians [region angle $r] scale $s } # On unmatch { # # HACK: Leaves time for the display to finish trying to display this. # after 5000 [list image freeJpeg $im] # } } + +When /someone/ wishes /p/ displays image /im/ { + Wish $p displays image $im with scale 1 +} From 37ccfee6ea7e27607b4a08fd44048d6ae8a189e2 Mon Sep 17 00:00:00 2001 From: Cristobal Sciutto Date: Fri, 27 Oct 2023 18:18:31 -0400 Subject: [PATCH 4/4] scale sampling --- virtual-programs/display/image.folk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtual-programs/display/image.folk b/virtual-programs/display/image.folk index 55a283e0..7415b260 100644 --- a/virtual-programs/display/image.folk +++ b/virtual-programs/display/image.folk @@ -5,17 +5,17 @@ On process "display" { dict set ::pipelines "image" [Gpu::pipeline {sampler2D image vec2 imageSize vec2 pos float radians float scale fn rotate} { - vec2 a = scale * (pos + rotate(-imageSize/2, -radians)); - vec2 b = scale * (pos + rotate(vec2(imageSize.x, -imageSize.y)/2, -radians)); - vec2 c = scale * (pos + rotate(imageSize/2, -radians)); - vec2 d = scale * (pos + rotate(vec2(-imageSize.x, imageSize.y)/2, -radians)); + vec2 a = pos + scale * (rotate(-imageSize/2, -radians)); + vec2 b = pos + scale * (rotate(vec2(imageSize.x, -imageSize.y)/2, -radians)); + vec2 c = pos + scale * (rotate(imageSize/2, -radians)); + vec2 d = pos + scale * (rotate(vec2(-imageSize.x, imageSize.y)/2, -radians)); vec2 vertices[4] = vec2[4](a, b, d, c); return vertices[gl_VertexIndex]; } {fn invBilinear fn rotate} { - vec2 a = pos + rotate(-imageSize/2, -radians); - vec2 b = pos + rotate(vec2(imageSize.x, -imageSize.y)/2, -radians); - vec2 c = pos + rotate(imageSize/2, -radians); - vec2 d = pos + rotate(vec2(-imageSize.x, imageSize.y)/2, -radians); + vec2 a = pos + scale * (rotate(-imageSize/2, -radians)); + vec2 b = pos + scale * (rotate(vec2(imageSize.x, -imageSize.y)/2, -radians)); + vec2 c = pos + scale * (rotate(imageSize/2, -radians)); + vec2 d = pos + scale * (rotate(vec2(-imageSize.x, imageSize.y)/2, -radians)); vec2 p = gl_FragCoord.xy; vec2 uv = invBilinear(p, a, b, c, d); if( max( abs(uv.x-0.5), abs(uv.y-0.5))<0.5 ) {