Advertisement
Guest User

Untitled

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