PasteRack.org
Paste # 77689
2014-12-10 21:26:00

Fork as a new paste.

Paste viewed 224 times.


Embed:

  1. #lang racket
  2.  
  3. (define top-frame (new frame%
  4.                          [label "KR"]
  5.                          [width 1000]
  6.                          [height 1000]))
  7.  
  8. (define image (pict->bitmap (rectangle 50 50)))
  9.  
  10. (define (draw-object x dc)
  11.   (case (first x)
  12.     [("LINE") (send dc draw-line (second x) (third x) (fourth x) (fifth x))]
  13.     [("CIRCLE") (send dc draw-bitmap (pict->bitmap (circle (round (fourth x)))) (round (second x)) (round (third x)))]
  14.     [("POINT") (send dc draw-point (round (second x)) (round (third x)))]
  15.     [else "Not drawing anything!"]))
  16.  
  17. (define canvas (new canvas%
  18.                     [parent top-frame]
  19.                     [paint-callback (lambda (canvas dc)
  20.                                       (draw-object (car (map find-specific-values list-of-objects)) dc)
  21.                                       (send dc draw-bitmap image 0 0))]))
  22.  
  23. (define drawer (send canvas get-dc))
  24.  
  25. (send top-frame show #t)
  26.  
  27. ; this works!
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. (define top-frame (new frame%
  46.                          [label "KR"]
  47.                          [width 1000]
  48.                          [height 1000]))
  49.  
  50. (define image (pict->bitmap (rectangle 50 50)))
  51.  
  52. (define (draw-object x dc)
  53.   (case (first x)
  54.     [("LINE") (send dc draw-line (second x) (third x) (fourth x) (fifth x))]
  55.     [("CIRCLE") (send dc draw-bitmap (pict->bitmap (circle (round (fourth x)))) (round (second x)) (round (third x)))]
  56.     [("POINT") (send dc draw-point (round (second x)) (round (third x)))]
  57.     [else "Not drawing anything!"]))
  58.  
  59. (define canvas (new canvas%
  60.                     [parent top-frame]
  61.                     [paint-callback (lambda (canvas dc)
  62.                                       (map draw-object (map find-specific-values list-of-objects) dc)
  63.                                       (send dc draw-bitmap image 0 0))]))
  64.  
  65. (define drawer (send canvas get-dc))
  66.  
  67. (send top-frame show #t)
  68.  
  69. ; this doesn't :(

=>

frame%: undefined;

 cannot reference an identifier before its definition

  in module: 'm

pict->bitmap: undefined;

 cannot reference an identifier before its definition

  in module: 'm

canvas%: undefined;

 cannot reference an identifier before its definition

  in module: 'm

canvas: undefined;

 cannot reference an identifier before its definition

  in module: 'm

top-frame: undefined;

 cannot reference an identifier before its definition

  in module: 'm

frame%: undefined;

 cannot reference an identifier before its definition

  in module: 'm

pict->bitmap: undefined;

 cannot reference an identifier before its definition

  in module: 'm

canvas%: undefined;

 cannot reference an identifier before its definition

  in module: 'm

canvas: undefined;

 cannot reference an identifier before its definition

  in module: 'm

top-frame: undefined;

 cannot reference an identifier before its definition

  in module: 'm