Changeset 6231
- Timestamp:
- Apr 8, 2007, 10:05:17 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/tiny.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/tiny.lisp
r5884 r6231 43 43 (defconstant numsides 12) 44 44 45 (define-objc-method ((:void :draw-rect (:<NSR>ect rect)) 46 demo-view) 45 (objc:defmethod (#/drawRect: :void) ((self demo-view) (rect :<NSR>ect)) 47 46 (declare (ignore rect)) 48 (slet ((bounds (send self 'bounds))) 49 (let ((width (ns-width bounds)) 50 (height (ns-height bounds))) 51 (macrolet ((X (tt) `(* (1+ (sin ,tt)) width 0.5)) 52 (Y (tt) `(* (1+ (cos ,tt)) height 0.5))) 53 ;; Fill the view with white 54 (send (the ns-color (send (@class ns-color) 'white-color)) 'set) 55 (#_NSRectFill bounds) 56 ;; Trace two polygons with N sides and connect all of the vertices 57 ;; with lines 58 (send (the ns-color (send (@class ns-color) 'black-color)) 'set) 47 (let* ((bounds (#/bounds self)) 48 (width (ns:ns-rect-width bounds)) 49 (height (ns:ns-rect-height bounds))) 50 (macrolet ((X (tt) `(* (1+ (sin ,tt)) width 0.5)) 51 (Y (tt) `(* (1+ (cos ,tt)) height 0.5))) 52 ;; Fill the view with white 53 (#/set (#/whiteColor ns:ns-color)) 54 (#_NSRectFill bounds) 55 ;; Trace two polygons with N sides and connect all of the vertices 56 ;; with lines 57 (#/set (#/blackColor ns:ns-color)) 58 (rlet ((source-point :ns-point) 59 (dest-point :ns-point)) 60 (loop 61 for f from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides)) 62 do 59 63 (loop 60 for ffrom 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides))64 for g from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides)) 61 65 do 62 (loop 63 for g from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides)) 64 do 65 (send (@class ns-bezier-path) 66 :stroke-line-from-point (ns-make-point (X f) (Y f)) 67 :to-point (ns-make-point (X g) (Y g))))))))) 66 (ns:init-ns-point source-point (X f) (Y f)) 67 (ns:init-ns-point dest-point (X g) (Y g)) 68 (#/strokeLineFromPoint:toPoint: ns:ns-bezier-path source-point dest-point))))))) 68 69 69 70 … … 73 74 (defun tiny-setup () 74 75 (with-autorelease-pool 75 (slet ((r (ns-make-rect (float 100.0 +cgfloat-zero+) 76 (float 350.0 +cgfloat-zero+) 77 (float 400.0 +cgfloat-zero+) 78 (float 400.0 +cgfloat-zero+)))) 79 (let ((w (make-instance 76 (let* ((r (ns:make-ns-rect 100 350 400 400)) 77 (w (make-instance 80 78 'ns:ns-window 81 79 :with-content-rect r … … 85 83 :backing #$NSBackingStoreBuffered 86 84 :defer t))) 87 (send w :set-title #@"Tiny Window Application")88 (let ((my-view (make-instance 'demo-view :with-frame r)))89 (send w :set-content-view my-view)90 (send w :set-delegatemy-view))91 (send w :make-key-and-order-frontnil)92 w))))85 (#/setTitle: w "Tiny Window Application") 86 (let ((my-view (make-instance 'demo-view :with-frame r))) 87 (#/setContentView: w my-view) 88 (#/setDelegate: w my-view)) 89 (#/makeKeyAndOrderFront: w nil) 90 w))) 93 91 94 92
Note:
See TracChangeset
for help on using the changeset viewer.
