logoPlayer-semantics.galgas 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. map @routineMap {
  2. @instructionList mInstructionList
  3. insert insertKey error message "the '%K' routine has been already declared"
  4. search searchKey error message "the '%K' routine is not declared"
  5. }
  6. list @instructionList {
  7. @instruction mInstruction
  8. }
  9. abstract class @instruction {
  10. }
  11. class @penUp : @instruction {
  12. }
  13. class @penDown : @instruction {
  14. }
  15. class @forward : @instruction {
  16. @luint mLength
  17. }
  18. class @rotate : @instruction {
  19. @luint mAngle
  20. }
  21. abstract method @instruction codeDisplay
  22. ?! @bool ioPenDown
  23. ?! @double ioX
  24. ?! @double ioY
  25. ?! @double ioAngle
  26. ?! @string unused svgContent
  27. override method @penUp codeDisplay
  28. ?! @bool ioPenDown
  29. ?! @double unused ioX
  30. ?! @double unused ioY
  31. ?! @double unused ioAngle
  32. ?! @string unused svgContent
  33. {
  34. ioPenDown = false
  35. }
  36. override method @penDown codeDisplay
  37. ?! @bool ioPenDown
  38. ?! @double unused ioX
  39. ?! @double unused ioY
  40. ?! @double unused ioAngle
  41. ?! @string unused svgContent
  42. {
  43. ioPenDown = true
  44. }
  45. override method @rotate codeDisplay
  46. ?! @bool unused ioPenDown
  47. ?! @double unused ioX
  48. ?! @double unused ioY
  49. ?! @double ioAngle
  50. ?! @string unused svgContent
  51. {
  52. ioAngle = ioAngle + [[mAngle uint] double]
  53. }
  54. override method @forward codeDisplay
  55. ?! @bool ioPenDown
  56. ?! @double ioX
  57. ?! @double ioY
  58. ?! @double ioAngle
  59. ?! @string svgContent
  60. {
  61. let @double x = ioX + [mLength double] * [ioAngle cosDegree]
  62. let @double y = ioY + [mLength double] * [ioAngle sinDegree]
  63. if ioPenDown then
  64. message "[" + ioX + ", " + ioY + "] -> ["+ x + ", " + y + "]\n"
  65. svgContent += "<line "
  66. + "x1=\"" + ioX + "\" y1=\"" + ioY + "\" "
  67. + "x2=\"" + x + "\" y2=\"" + y + "\" "
  68. + "style=\"stroke :#1F56D2\" "
  69. + "stroke-linecap=\"round\" />\n"
  70. end
  71. ioX = x
  72. ioY = y
  73. }
  74. # Declare svg template
  75. filewrapper generationTemplate in "." {
  76. }
  77. {}
  78. {
  79. template svg "logoPlayer-svg.galgasTemplate"
  80. ?@string TITLE
  81. ?@string DRAWINGS
  82. }