Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (allowed ()
- "!work" "!canvasTest" "@lib.css" )
- (load
- "@lib/http.l" "@lib/xhtml.l" "@lib/form.l"
- "@lib/canvas.l" "@lib/svg.l" )
- (allow 'showTextMetric )
- (allow "!mk.svg")
- (de showTextMetric (Letter W)
- (setq *TextW W)
- (out "/tmp/pil.txt" (println "Text " Letter " has width " W " pixels") )
- )
- (de mk.svg (Page)
- (httpHead "image/svg+xml" 0)
- (ht:Out *Chunked
- #{
- # GENERATE SVG
- (prin "<g transform=\"translate(126,72)\">")
- (prin "<rect x=\"0\" y=\"0\" width=\"300\" height=\"258\" fill=\"none\" stroke=\"gray\" stroke-width=\"0.25\"/>")
- (prin "</g>")
- }#
- (<svg> 200 200 "px"
- (rect 0 0 40 30)
- ) ) )
- (de drawTile (Letter X Y R W H LP HP)
- # calls link to add to list
- (csFont "32pt sans-serif")
- (csBeginPath)
- #draw square tile
- (csMoveTo (+ X R) Y)
- (csLineTo (+ X W (* -1 R)) Y)
- (csQuadraticCurveTo (+ X W) Y (+ X W) (+ Y R))
- (csLineTo (+ X W) (+ Y H (* -1 R)) )
- (csQuadraticCurveTo (+ X W) (+ Y H) (+ X W (* -1 R)) (+ Y H))
- (csLineTo (+ X R) (+ Y H))
- (csQuadraticCurveTo X (+ Y H) X (+ Y H (* -1 R)))
- (csLineTo X (+ Y R))
- (csQuadraticCurveTo X Y (+ X R) Y)
- (csClosePath)
- (csStrokeStyle "blue")
- (csStroke)
- (csFillStyle "#FDA893")
- (csFill)
- (csFillStyle "green")
- (csFillText Letter (+ X (/ (- W LP) 2)) (+ Y (/ (- H HP) 2))) )
- (de drawImage ()
- (csDrawImage (sesId (pack "!mk.svg?" (ht:Fmt This *Cnt)))
- 50 # X
- 50 # Y
- (make
- (drawTile "A" 200 200 10 100 100 7 10) ) ) )
- (de drawCanvas (Id Dly F X Y X2 Y2)
- (inc *Cnt)
- (make (drawImage)) )
- (de canvasTest ()
- (action
- (html 0 "Canvas Test1" "@lib.css" '((onload . "drawCanvas('$testID', -1)"))
- (form NIL
- (<canvas> "$testID" 600 600) ) ) ) )
- (de work ()
- (app)
- (setq *Cnt 0)
- (redirect (baseHRef) *SesId "!canvasTest") )
- (server 8080 "!work")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement