julia_image.cmn 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # This is a program that renders Julia set image along with a text as a PPM
  2. # image. NOTE: when rendering this in "higher" resolutions, such as 128x100,
  3. # the current C interpreter takes a while to finish, keep in mind this isn't
  4. # too optimized and the interpreter is slow.
  5. ~8
  6. ~IMG_mem:60000
  7. ~0
  8. IMG_out: -> .
  9. ~"../programs/imglib.cmn"
  10. ~"../programs/minilib.cmn"
  11. IMAGE_W: 128 .
  12. IMAGE_H: 90 .
  13. VIEW_W: 3000 .
  14. VIEW_H: 2000 .
  15. JULIA_X: -368 .
  16. JULIA_Y: -634 .
  17. # in: x, y, 4x4bitmap
  18. drawChar:
  19. 4
  20. @'
  21. 4
  22. @'
  23. $2 2 % ?
  24. $0 $5 + -- $2 $5 + -- IMG_BLACK IMG_setPixel
  25. .
  26. $2 2 / $:3 # shift mask by one to the right
  27. --
  28. .
  29. ^
  30. --
  31. .
  32. ^
  33. ^ ^ ^
  34. .
  35. # julia set, modified function from the Mandelbrot example
  36. julia:
  37. # x
  38. # y
  39. 0 # iteration
  40. $2 # cx
  41. $2 # cy
  42. @@
  43. $2 63 <' ?
  44. ^ ++ $:3
  45. ;
  46. ^ ^ !@
  47. .
  48. $1 $0 * $1 $0 * - 1024 // JULIA_X +
  49. $2 $2 * 512 // JULIA_Y + $:2
  50. $:2
  51. $1 $0 * $1 $0 * + 4194304 > ?
  52. !@
  53. .
  54. .
  55. ^ ^ $:2 ^
  56. .
  57. IMAGE_W IMAGE_H IMG_new
  58. IMAGE_H
  59. @'
  60. --
  61. IMAGE_W
  62. @'
  63. --
  64. $0 $2
  65. $1 VIEW_W * IMAGE_W / VIEW_W 2 / -
  66. $1 VIEW_H * IMAGE_H / VIEW_H 2 / -
  67. julia 4 * $0 2 * cos8 255 $1 - # create RGB color
  68. IMG_setPixel
  69. .
  70. ^
  71. .
  72. ^
  73. 1 1 +b1101111110011001 drawChar # M
  74. 6 1 +b0110100111111001 drawChar # A
  75. 11 1 +b1110100110011110 drawChar # D
  76. 16 1 +b1111111010001111 drawChar # E
  77. 25 1 +b1001100111111101 drawChar # W
  78. 30 1 +b0100010001000100 drawChar # I
  79. 33 1 +b1110010001000100 drawChar # T
  80. 37 1 +b1001111110011001 drawChar # H
  81. 45 1 +b0111100010000111 drawChar # C
  82. 50 1 +b0110100110010110 drawChar # O
  83. 55 1 +b1101111110011001 drawChar # M
  84. 60 1 +b1001100110010110 drawChar # U
  85. 65 1 +b1001110110111001 drawChar # N
  86. IMG_toPPM