PasteRack.org
Paste # 85538
2014-12-10 21:25:11

Fork as a new paste.

Paste viewed 271 times.


Embed:

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

=>

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