Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface for Digital Libraries via Calibre #137

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions virtual-programs/images.folk
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,17 @@ namespace eval ::image {
variable imagesCache [dict create]
# Loads a URL or file path if passed. If passed a valid image_t,
# just returns that image_t.
proc load {im} {
proc load {im {name ""}} {
variable imagesCache

if {[dict exists $imagesCache $im]} {
set im [dict get $imagesCache $im]
} else {
set impath $im
if {[string match "http*://*" $impath]} {
set im /tmp/[regsub -all {\W+} $impath "_"]
exec -ignorestderr curl -o$im $impath
set name [expr { $name ne "" ? $name : [regsub -all {\W+} $impath "_"] }]
set im /tmp/$name
exec -ignorestderr curl -o $im $impath
}
if {[string match "*jpg" $im] ||
[string match "*jpeg" $im] ||
Expand Down Expand Up @@ -345,8 +347,11 @@ 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/ with scale /s/ {
set im [image load $im]
When /someone/ wishes /p/ displays image /im/ with /...options/ {
set s [dict_getdef $options scale 1]
set name [dict_getdef $options name ""]

set im [image load $im $name]
When $p has region /r/ {
# Compute a scale for im that will fit in the region width/height
# Draw im with scale and rotation
Expand Down
26 changes: 13 additions & 13 deletions virtual-programs/mask-tags.folk
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
When tag /something/ has corners /corners/ {
set tagCorners [lmap p $corners {::cameraToProjector $p}]
# When tag /id/ has corners /corners/ & /nobody/ claims /id/ is not masked {
# set tagCorners [lmap p $corners {::cameraToProjector $p}]

set vecBottom [sub [lindex $tagCorners 1] [lindex $tagCorners 0]]
set vecRight [sub [lindex $tagCorners 2] [lindex $tagCorners 1]]
# set vecBottom [sub [lindex $tagCorners 1] [lindex $tagCorners 0]]
# set vecRight [sub [lindex $tagCorners 2] [lindex $tagCorners 1]]

set offsets {{-0.5 -0.5} {0.5 -0.5} {0.5 0.5} {-0.5 0.5}}
set scales [matmul $offsets [list $vecBottom $vecRight]]
set corners [add $tagCorners $scales]
# set offsets {{-0.5 -0.5} {0.5 -0.5} {0.5 0.5} {-0.5 0.5}}
# set scales [matmul $offsets [list $vecBottom $vecRight]]
# set corners [add $tagCorners $scales]

set p0 [lindex $corners 0]
set p1 [lindex $corners 1]
set p2 [lindex $corners 2]
set p3 [lindex $corners 3]
Wish to draw a quad with p0 $p0 p1 $p1 p2 $p2 p3 $p3 color black layer 1
}
# set p0 [lindex $corners 0]
# set p1 [lindex $corners 1]
# set p2 [lindex $corners 2]
# set p3 [lindex $corners 3]
# Wish to draw a quad with p0 $p0 p1 $p1 p2 $p2 p3 $p3 color black layer 1
# }