logoPlayer-semantics.galgas 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. override method @penUp codeDisplay
  27. ?! @bool ioPenDown
  28. ?! @double unused ioX
  29. ?! @double unused ioY
  30. ?! @double unused ioAngle
  31. {
  32. ioPenDown = false
  33. }
  34. override method @penDown codeDisplay
  35. ?! @bool ioPenDown
  36. ?! @double unused ioX
  37. ?! @double unused ioY
  38. ?! @double unused ioAngle
  39. {
  40. ioPenDown = true
  41. }
  42. override method @rotate codeDisplay
  43. ?! @bool unused ioPenDown
  44. ?! @double unused ioX
  45. ?! @double unused ioY
  46. ?! @double ioAngle
  47. {
  48. ioAngle = ioAngle + [[mAngle uint] double]
  49. }
  50. override method @forward codeDisplay
  51. ?! @bool ioPenDown
  52. ?! @double ioX
  53. ?! @double ioY
  54. ?! @double ioAngle
  55. {
  56. let @double x = ioX + [mLength double] * [ioAngle cosDegree]
  57. let @double y = ioY + [mLength double] * [ioAngle sinDegree]
  58. if ioPenDown then
  59. message "[" + ioX + ", " + ioY + "] -> ["+ x + ", " + y + "]\n"
  60. end
  61. ioX = x
  62. ioY = y
  63. }
  64. # Declare svg template
  65. filewrapper generationTemplate in "." {
  66. }
  67. {}
  68. {
  69. template svg "logoPlayer-svg.galgasTemplate"
  70. ?@string TITLE
  71. ?@string DRAWINGS
  72. }