zillionプロジェクト開発ブログ [Gauche]ドラゴン曲線 忍者ブログ

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

c-wrapperとSDLと自作のL-systemライブラリを使ってドラゴン曲線を描いてみた.

(use klib.list)
(use klib.sdl)
(use klib.turtle)
(use klib.l-system)

(define-rule x->x 'x '(x + y f))
(define-rule y->x 'y '(f x - y))

(define gen (make <G> :init '(f x) :rules `(,x->x ,y->x)))

(define (dragon-curve n level)
  (convert (gen level)
           `(f . ,(lambda (x) (forward (/. n (expt 1.4 level)))))
           `(+ . ,(lambda (x) (turn 90)))               
           `(- . ,(lambda (x) (turn -90)))
           `(x . ,(lambda (x) (turn 0)))
           `(y . ,(lambda (x) (turn 0)))
           ))

(define (main args)
  (set-caption! "Dragon Curve")
  (turtle-main args
               (color (make <color> :r 0 :g 0))
               (move 300)
               (dragon-curve 250 13)
               ))
 

20120413-202043.png
 

拍手[7回]

PR

◎ Post your Comment
Name
Title
E-mail
URL
Comment
Pass   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
◎ カウンター
◎ カレンダー
02 2024/03 04
S M T W T F S
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 27 28 29 30
31
◎ 最新CM
[10/24 名無しの権兵衛]
[08/30 名無しの権兵衛]
[08/14 no name no future]
[08/05 ゲームサークルEaSt]
[07/28 リオウ]
◎ プロフィール
HN:
solilpquy
年齢:
29
性別:
男性
誕生日:
1994/09/22
職業:
人間
趣味:
趣味ねぇ~~う~ん・・・
◎ ブログ内検索
◎ バーコード
◎ アクセス解析
◎ フリーエリア
◎ フリーエリア
Script: Ninja Blog 
Design by: タイムカプセル
忍者ブログ 
[PR]