diff options
| author | Andrés Cuervo <acwervo@gmail.com> | 2022-12-19 21:04:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-19 21:04:01 +0000 |
| commit | 7233b7565fe64b7e603fb56cd4f7c4be8c124081 (patch) | |
| tree | 8fea2fc1bf08f08e33dd6cefd4df83c43d90ffb1 /virtual-programs | |
| parent | some of the earlier messing w images (diff) | |
| parent | Add 96 - 98 & update im.folk (diff) | |
| download | folk-7233b7565fe64b7e603fb56cd4f7c4be8c124081.tar.gz folk-7233b7565fe64b7e603fb56cd4f7c4be8c124081.zip | |
Merge pull request #12 from FolkComputer/osnr/when-when
merge last couple days' work
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/camera-slice.folk | 16 | ||||
| -rw-r--r-- | virtual-programs/im.folk | 40 |
2 files changed, 56 insertions, 0 deletions
diff --git a/virtual-programs/camera-slice.folk b/virtual-programs/camera-slice.folk new file mode 100644 index 00000000..3fb4e98d --- /dev/null +++ b/virtual-programs/camera-slice.folk @@ -0,0 +1,16 @@ +Wish $this has filename "camera-slice.folk" +Wish $this has camera image +Wish $this is outlined white + +# Wish program code labelled + +When $this has camera image /im/ { + When $this has region /r/ { + set coords [lmap n [lindex $r 0 0] {expr $n * 1}] + Wish display runs [list Display::image {*}$coords $im] + Wish $this is labelled "$coords $im" + # filter $im + } +} + + diff --git a/virtual-programs/im.folk b/virtual-programs/im.folk new file mode 100644 index 00000000..95e4252f --- /dev/null +++ b/virtual-programs/im.folk @@ -0,0 +1,40 @@ +Wish $this has filename "im.folk" +Wish $this is outlined green + +set cc [c create] +defineImageType $cc + +$cc include <stdlib.h> +$cc include <string.h> +$cc proc bw {image_t im} image_t { + image_t ret; + ret.width = im.width; + ret.height = im.height; + ret.components = 3; + ret.bytesPerRow = ret.width * ret.components; + ret.data = calloc(ret.bytesPerRow, ret.height); + + for (uint32_t y = 0; y < im.height; ++y) { + int R = 0; int G = 1; int B = 2; + for (uint32_t x = 0; x < im.width; ++x) { + int i = y * ret.bytesPerRow + x * ret.components; + int j = y * im.bytesPerRow + x * im.components; + ret.data[i + 0] = im.data[j + R]; + ret.data[i + 1] = im.data[j + G]; + ret.data[i + 2] = im.data[j + B]; + } + } + + return ret; +} +$cc proc freeImage {image_t im} void { free(im.data); } +$cc compile + +Wish $this has camera image +When $this has camera image /im/ { + When $this has region /r/ { + set bwim [bw $im] + Wish display runs [list Display::image {*}[lindex $r 0 0] $bwim] + On unmatch [list freeImage $bwim] + } +}
\ No newline at end of file |
