diff options
| author | Omar Rizwan <omar@omar.website> | 2022-10-14 16:19:48 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2022-10-14 16:19:48 +0000 |
| commit | 5f073db79597819fba7f69b689cc0ceb36cc42da (patch) | |
| tree | bcdffa668941a9c6bf22f617a859cea5ad6b0e15 /virtual-programs | |
| parent | apriltag rendering works (just upside-down) (diff) | |
| download | folk-5f073db79597819fba7f69b689cc0ceb36cc42da.tar.gz folk-5f073db79597819fba7f69b689cc0ceb36cc42da.zip | |
Add some test infra, work on livecprocs
Sync seems broken
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/print-test.folk | 15 | ||||
| -rw-r--r-- | virtual-programs/print.folk | 17 |
2 files changed, 21 insertions, 11 deletions
diff --git a/virtual-programs/print-test.folk b/virtual-programs/print-test.folk index 661604f5..98d8e9f5 100644 --- a/virtual-programs/print-test.folk +++ b/virtual-programs/print-test.folk @@ -1,9 +1,10 @@ -catch { - set fp [open "test-output.ps" w] - puts $fp [programToPs 6 hello] - close $fp - puts "output to test-output.ps!" -} err -puts $err +puts $::nodename + +set fp [open "test-output.ps" w] +puts $fp [programToPs 6 hello] +close $fp +puts "output to test-output.ps! $::nodename" # puts $::livecprocs + + diff --git a/virtual-programs/print.folk b/virtual-programs/print.folk index 86d67eeb..ee0c723b 100644 --- a/virtual-programs/print.folk +++ b/virtual-programs/print.folk @@ -17,10 +17,16 @@ critcl::ccode { #define emit(...) i += sprintf(&ret[i], __VA_ARGS__) } +if {![info exists ::livecprocs]} {set ::livecprocs [dict create]} proc livecproc {name args} { - critcl::cproc $name$::stepCount {*}$args - lappend ::livecprocs $name$::stepCount - proc $name {args} { [lindex $::livecprocs end] {*}$args } + if {![dict exists ::livecprocs $name $args]} { + critcl::cproc $name$::stepCount {*}$args + dict set ::livecprocs $name $args $name$::stepCount + } + proc $name {args} { + set name [lindex [info level 0] 0] + [lindex [dict values [dict get $::livecprocs $name]] end] {*}$args + } } livecproc tagImageForId {int id} string { if (tf == NULL) tf = tagStandard52h13_create(); @@ -29,7 +35,9 @@ livecproc tagImageForId {int id} string { char* ret = Tcl_Alloc(10000); int i = 0; - emit("%f %f scale\n", 1.0/image->width, 1.0/image->height); + emit("gsave\n"); + emit("0 1 translate\n"); + emit("%f %f scale\n", 1.0/image->width, -1.0/image->height); for (int row = 0; row < image->height; row++) { for (int col = 0; col < image->width; col++) { uint8_t pixel = image->buf[(row * image->stride) + col]; @@ -43,6 +51,7 @@ livecproc tagImageForId {int id} string { } emit("\n"); } + emit("grestore\n"); ret[i++] = '\0'; image_u8_destroy(image); return ret; |
