From a6e989f0208d704ad6d0e7751ebb6d9ff776e797 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 24 Apr 2017 20:13:20 +0200 Subject: [PATCH] A lot of composition examples --- examples/06-composition/06-composition.scm | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/examples/06-composition/06-composition.scm b/examples/06-composition/06-composition.scm index 9d21e7d..eeb1130 100644 --- a/examples/06-composition/06-composition.scm +++ b/examples/06-composition/06-composition.scm @@ -22,16 +22,38 @@ (define (tick) (* 3000000 (get-internal-real-time))) (define (waggle) (* 200 (cos (* pi (tick))))) (define (wiggle) (* 300 (sin (* pi (tick))))) +(define (swaggle) (cos (* pi (tick)))) +(define (swiggle) (sin (* pi (tick)))) -(define left-right-homer - (move (image "homer.png") - wiggle 0)) +(define homer (image "homer.png")) +(define marge (image "marge.png")) -(define up-down-marge - (move (image "marge.png") - 0 waggle)) +(define (hv-dance image1 image2) + (over (move image1 wiggle 0) + (move image2 0 waggle))) + +(define homer-marge-dance + (hv-dance homer marge)) + +(display-scene + (window ((resolution '(640 480))) + homer-marge-dance)) + +(display-scene + (window ((resolution '(640 480))) + (let ((small (scale homer-marge-dance 0.5))) + (hv-dance small small)))) + +(display-scene + (window ((resolution '(640 480))) + (scale homer-marge-dance (lambda () (abs (swiggle)))))) + +(display-scene + (window ((resolution '(640 480))) + (hv-dance (scale homer swiggle) + (scale marge swaggle)))) (display-scene (window ((resolution '(640 480))) - (over left-right-homer - up-down-marge))) + (over (scale homer swiggle) + (move marge wiggle waggle)))) -- 2.39.5