Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. (allowed ()
  2. "!work" "!canvasTest" "@lib.css" )
  3.  
  4. (load
  5. "@lib/http.l" "@lib/xhtml.l" "@lib/form.l"
  6. "@lib/canvas.l" "@lib/svg.l" )
  7.  
  8. (allow 'showTextMetric )
  9. (allow "!mk.svg")
  10.  
  11.  
  12. (de showTextMetric (Letter W)
  13. (setq *TextW W)
  14. (out "/tmp/pil.txt" (println "Text " Letter " has width " W " pixels") )
  15. )
  16.  
  17.  
  18. (de mk.svg (Page)
  19. (httpHead "image/svg+xml" 0)
  20. (ht:Out *Chunked
  21. #{
  22. # GENERATE SVG
  23. (prin "<g transform=\"translate(126,72)\">")
  24. (prin "<rect x=\"0\" y=\"0\" width=\"300\" height=\"258\" fill=\"none\" stroke=\"gray\" stroke-width=\"0.25\"/>")
  25. (prin "</g>")
  26. }#
  27. (<svg> 200 200 "px"
  28. (rect 0 0 40 30)
  29. ) ) )
  30.  
  31. (de drawTile (Letter X Y R W H LP HP)
  32. # calls link to add to list
  33. (csFont "32pt sans-serif")
  34. (csBeginPath)
  35.  
  36. #draw square tile
  37. (csMoveTo (+ X R) Y)
  38. (csLineTo (+ X W (* -1 R)) Y)
  39. (csQuadraticCurveTo (+ X W) Y (+ X W) (+ Y R))
  40. (csLineTo (+ X W) (+ Y H (* -1 R)) )
  41. (csQuadraticCurveTo (+ X W) (+ Y H) (+ X W (* -1 R)) (+ Y H))
  42. (csLineTo (+ X R) (+ Y H))
  43. (csQuadraticCurveTo X (+ Y H) X (+ Y H (* -1 R)))
  44. (csLineTo X (+ Y R))
  45. (csQuadraticCurveTo X Y (+ X R) Y)
  46.  
  47. (csClosePath)
  48. (csStrokeStyle "blue")
  49. (csStroke)
  50. (csFillStyle "#FDA893")
  51. (csFill)
  52. (csFillStyle "green")
  53. (csFillText Letter (+ X (/ (- W LP) 2)) (+ Y (/ (- H HP) 2))) )
  54.  
  55. (de drawImage ()
  56. (csDrawImage (sesId (pack "!mk.svg?" (ht:Fmt This *Cnt)))
  57. 50 # X
  58. 50 # Y
  59. (make
  60. (drawTile "A" 200 200 10 100 100 7 10) ) ) )
  61.  
  62. (de drawCanvas (Id Dly F X Y X2 Y2)
  63. (inc *Cnt)
  64. (make (drawImage)) )
  65.  
  66. (de canvasTest ()
  67. (action
  68. (html 0 "Canvas Test1" "@lib.css" '((onload . "drawCanvas('$testID', -1)"))
  69. (form NIL
  70. (<canvas> "$testID" 600 600) ) ) ) )
  71.  
  72. (de work ()
  73. (app)
  74. (setq *Cnt 0)
  75. (redirect (baseHRef) *SesId "!canvasTest") )
  76.  
  77. (server 8080 "!work")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement