Scheme playground.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

82 lines
2.0 KiB

  1. ;;; defined in C code
  2. ;;; (pixel-put x y color)
  3. ;;; (pixel-rect-fill x1 y1 x2 y2 color)
  4. ;;; (stroke-line x1 y1 x2 y2 color)
  5. (import (srfi 27))
  6. (define (pixel-hline x1 x2 y color)
  7. (if (> x1 x2)
  8. #t
  9. (begin
  10. (pixel-put x1 y color)
  11. (pixel-hline (+ x1 1) x2 y color))))
  12. (define (pixel-vline x y1 y2 color)
  13. (if (> y1 y2)
  14. #t
  15. (begin
  16. (pixel-put x y1 color)
  17. (pixel-vline x (+ y1 1) y2 color))))
  18. (define (pixel-rect x1 y1 x2 y2 color)
  19. (pixel-hline x1 x2 y1 color)
  20. (pixel-hline x1 x2 y2 color)
  21. (pixel-vline x1 y1 y2 color)
  22. (pixel-vline x2 y1 y2 color))
  23. (display "hello from scheme world!\n")
  24. (define this-key 0)
  25. (define last-key 0)
  26. (define paint-color #xffffff)
  27. (define random-color-mode #t)
  28. ;; Play a wav file when the program starts.
  29. (play-wav-file "Test.wav" 0)
  30. ;; Play the wav file AND loop forever:
  31. ;; (play-wav-file "Test.wav" -1)
  32. (define (main)
  33. ;;; (display "(main)\n")
  34. (pixel-rect 32 32 128 128 #xffffff)
  35. (pixel-rect-fill 150 32 250 128 #xffff00)
  36. (stroke-line 300 32 350 128 #x00ffffff)
  37. (pixel-ellipse-fill 420 75 20 60 #xffaaaaff)
  38. (if (= (mouse-buttons) 1)
  39. (pixel-rect-fill
  40. (mouse-x) (mouse-y)
  41. (+ (mouse-x) 8) (+ (mouse-y) 8)
  42. paint-color))
  43. (if (= (mouse-buttons) 4)
  44. (pixel-rect-fill
  45. (mouse-x) (mouse-y)
  46. (+ (mouse-x) 32) (+ (mouse-y) 32)
  47. #x000000))
  48. (set! this-key (keyboard))
  49. (if random-color-mode
  50. (set! paint-color (random-integer #xffffff)))
  51. (if (> this-key 0)
  52. (if (not (= this-key last-key))
  53. (begin
  54. (display (list "key: " this-key))
  55. (display "\n")
  56. (cond
  57. ((= this-key 49) (set! random-color-mode #t))
  58. ((= this-key 50) (set! random-color-mode #f))
  59. ((= this-key 51) (set! paint-color #x0000ff))
  60. ((= this-key 52) (set! paint-color #xff00ff))
  61. ((= this-key 53) (set! paint-color #x00ffff))
  62. ((= this-key 54) (set! paint-color #xffff00))
  63. ((= this-key 55) (set! paint-color #xffffff))
  64. ))))
  65. (set! last-key (keyboard))
  66. )