simple-graphics
Check-in [dbd1f7ae2b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More colours, and bumped version number to 0.2
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | 0.2
Files: files | file ages | folders
SHA1:dbd1f7ae2b8aeafa28f24fbdb8d357fada094a38
User & Date: alaric 2012-07-09 20:06:49
Context
2012-07-09
20:07
Release v0.2 check-in: 845e1aac0b user: alaric tags: trunk
20:06
More colours, and bumped version number to 0.2 check-in: dbd1f7ae2b user: alaric tags: trunk, 0.2
19:49
Added licence, and a category in the metafile. check-in: 4b2353ed64 user: alaric tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to simple-graphics.scm.

1
2
3
4
5
6

7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
...
210
211
212
213
214
215
216


217



















218
219
220
221
222
223
224
(module simple-graphics
        (forward forwards turn right left backward backwards
         pen-up pen-down home clear
         (adventure begin-adventure! end-adventure!)
         save goto go-to heading
         red green blue orange yellow brown grey black

         faster slower speed
         lost)

;; TODO:
;; Display a turtle cursor sprite

(import chicken scheme)
(use doodle)
(use miscmacros)
(use parley)
(use posix)


(define +width+ 640)
(define +height+ 480)

(define *initialised* #f)

(define *x* #f)
................................................................................
(define-colour red 1 0 0)
(define-colour green 0 1 0)
(define-colour blue 0 0 1)
(define-colour yellow 1 1 0)
(define-colour orange 1 0.5 0)
(define-colour brown 0.5 0.25 0)
(define-colour grey 0.5 0.5 0.5)


(define-colour black 0 0 0)




















(define (heading angle)
  (ensure-initialised!)
  (let ((cos-angle (cos (degrees->radians (- angle 90))))
        (sin-angle (sin (degrees->radians (- angle 90))))
        (current-magnitude (sqrt (+ (* *dx* *dx*) (* *dy* *dy*)))))
    (set! *dx* (* cos-angle current-magnitude))





|
>











>







 







>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
(module simple-graphics
        (forward forwards turn right left backward backwards
         pen-up pen-down home clear
         (adventure begin-adventure! end-adventure!)
         save goto go-to heading
         red green blue orange yellow brown grey purple turquoise black
         lighter darker
         faster slower speed
         lost)

;; TODO:
;; Display a turtle cursor sprite

(import chicken scheme)
(use doodle)
(use miscmacros)
(use parley)
(use posix)
(use srfi-1)

(define +width+ 640)
(define +height+ 480)

(define *initialised* #f)

(define *x* #f)
................................................................................
(define-colour red 1 0 0)
(define-colour green 0 1 0)
(define-colour blue 0 0 1)
(define-colour yellow 1 1 0)
(define-colour orange 1 0.5 0)
(define-colour brown 0.5 0.25 0)
(define-colour grey 0.5 0.5 0.5)
(define-colour purple 0.8 0 1)
(define-colour turquoise 0 1 1) 
(define-colour black 0 0 0)

(define (lighten sample)
  (/ (+ sample 1.0) 2.0))

(define (darken sample)
  (/ sample 2.0))

(define (colour-delta modifier)
  (let ((r (first *colour*))
        (g (second *colour*))
        (b (third *colour*))
        (a (fourth *colour*)))
    (set! *colour* (list (modifier r) (modifier g) (modifier b) a))))

(define (lighter)
  (colour-delta lighten))

(define (darker)
  (colour-delta darken))

(define (heading angle)
  (ensure-initialised!)
  (let ((cos-angle (cos (degrees->radians (- angle 90))))
        (sin-angle (sin (degrees->radians (- angle 90))))
        (current-magnitude (sqrt (+ (* *dx* *dx*) (* *dy* *dy*)))))
    (set! *dx* (* cos-angle current-magnitude))

Changes to simple-graphics.setup.

1
2
3
4
5
6
7
(compile -s -O3 -d1 simple-graphics.scm -j simple-graphics)
(compile -s -O3 -d1 simple-graphics.import.scm)
(compile -c -O3 -d1 simple-graphics.scm -unit simple-graphics)

(install-extension 'simple-graphics '("simple-graphics.so" "simple-graphics.o" "simple-graphics.import.so")
                   '((version "1.0")
                     (static "simple-graphics.o")))





|
|
1
2
3
4
5
6
7
(compile -s -O3 -d1 simple-graphics.scm -j simple-graphics)
(compile -s -O3 -d1 simple-graphics.import.scm)
(compile -c -O3 -d1 simple-graphics.scm -unit simple-graphics)

(install-extension 'simple-graphics '("simple-graphics.so" "simple-graphics.o" "simple-graphics.import.so")
                   '((version "0.2")
                     (static "simple-graphics.o")))