;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; 

;; DRAW A SQUARE - Graphics Example

;;

;; Define and draw an orange square

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; Create a new canvas

; A canvas has a transparent background by default

(define *canvas* (gfx:make-canvas))


; Create and return a square path object.

; A path is made up of line segments.

(define draw-square

   (lambda (x y size)

      (let ((path (gfx:make-path)))

      (gfx:set-start-point path x y)

      (gfx:add-line path x (+ y size))

      (gfx:add-line path (+ x size) (+ y size))

      (gfx:add-line path (+ x size) y)

      (gfx:add-line path x y)

        (gfx:close-path path)

      path)))


; define a square path

(define *square* (draw-square 100 100 200))

; define a fill colour

(define *fill* '(1.0 0.5 0.1 1.0))

; define a stroke colour - the colour for the line

(define *stroke* '(0.5 0.9 1.0 1.0))

(gfx:clear-canvas (now) *canvas*)

; draw path at a particular time to a particular canvas

(gfx:draw-path (now) *canvas* *square* *stroke* *fill* 2.0)