(define draw-disc! (lambda (image col row radius) (image.select-ellipse! image selection.replace (- col radius) (- row radius) (+ radius radius) (+ radius radius)) (image.fill! image) (image.stroke! image) (image.select-nothing! image))) (define draw-square! (lambda (image col row radius) (image.select-rectangle! image selection.replace (- col radius) (- row radius) (+ radius radius) (+ radius radius)) (image.stroke! image) (image.select-nothing! image))) (define draw-box! (lambda (image col row radius) (image.select-rectangle! image selection.replace (- col radius) (- row radius) (+ radius radius) (+ radius radius)) (image.fill! image) (image.stroke! image) (image.select-nothing! image))) (define draw-circle! (lambda (image col row radius) (image.select-ellipse! image selection.replace (- col radius) (- row radius) (+ radius radius) (+ radius radius)) (image.stroke! image) (image.select-nothing! image))) (define draw-stamp! (lambda (image col row radius rotation val) (cond ((= (modulo val 4) 1) (draw-circle! image col row radius)) ((= (modulo val 4) 2) (draw-disc! image col row radius)) ((= (modulo val 4) 3) (draw-square! image col row radius)) (else (draw-box! image col row radius))))) (define draw-rolled! (lambda (image col row inner-radius stamp-radius revolution val) (draw-stamp! image (+ col (* (+ inner-radius stamp-radius) (cos revolution))) (+ row (* (+ inner-radius stamp-radius) (sin revolution))) stamp-radius (/ (* revolution inner-radius) stamp-radius) val))) (define rgb.average (lambda (color1 color2) (rgb.new (* 0.25 (+ (rgb.red color1) (rgb.red color2))) (* 0.25 (+ (rgb.green color1) (rgb.green color2))) (* 0.25 (+ (rgb.blue color1) (rgb.blue color2)))))) (define fractal-rectangle! (lambda (image color left top right bottom level) (cond ((= level 0) (envt.set-fgcolor! color) (image.select-rectangle! image selection.replace left top (- right left) (- bottom top)) (image.fill! image) (image.select-nothing! image) (envt.update-displays!)) (else (let* ((midcol1 (round (+ left (/ (- right left) 6)))) (midcol2 (round (- right (/ (- right left) 8)))) (midrow1 (round (+ top (/ (- bottom top) 8)))) (midrow2 (round (- bottom (/ (- bottom top) 4))))) ; First row of squares (fractal-rectangle! image (rgb.average color color.grey) left top midcol1 midrow1 (- level 1)) (fractal-rectangle! image (rgb.average color color.white) midcol1 top midcol2 midrow1 (- level 1)) (fractal-rectangle! image (rgb.average color color.grey) midcol2 top right midrow1 (- level 1)) ; Second row of squares (fractal-rectangle! image (rgb.average color color.white) left midrow1 midcol1 midrow2 (- level 1)) (fractal-rectangle! image (rgb.average color color.grey) midcol1 midrow1 midcol2 midrow2 (- level 1)) (fractal-rectangle! image (rgb.average color color.white) midcol2 midrow1 right midrow2 (- level 1)) ; Third row of squares (fractal-rectangle! image (rgb.average color color.grey) left midrow2 midcol1 bottom (- level 1)) (fractal-rectangle! image (rgb.average color color.white) midcol1 midrow2 midcol2 bottom (- level 1)) (fractal-rectangle! image (rgb.average color color.grey) midcol2 midrow2 right bottom (- level 1)) ))))) (define sushi-roll! (lambda (image val width height) (let kernel ((step 0) (revolution 0) (red (modulo val 256)) (green (modulo val 128)) (blue (modulo val 64)) (theta (/ pi (max (modulo val 16) 8))) (col (/ width 2)) (row (/ height 2)) (inner-radius (/ 250 (/ 1000 width))) (stamp-radius (/ (max 20 (modulo val 50)) (/ 1000 width)))) (define color (rgb.new red green blue)) (cond ((<= step (/ (* 2 pi) theta)) (draw-rolled! image col row inner-radius stamp-radius revolution val) (envt.set-fgcolor! (rgb.new red green blue)) (envt.set-brush! (list-ref (list "Circle (01)" "pixel (1x1 square)" "Circle Fuzzy (03)" "Felt Pen" "square (5x5) blur" "Calligraphic Brush" "Sand Dunes (AP)") (modulo val 7))) (kernel (+ step 1) (+ revolution theta) (+ red (/ step 4)) (+ green (/ step 2)) (+ blue step) theta col row inner-radius stamp-radius)))))) (define canvas (image.new 200 200)) (image.show canvas) (envt.set-bgcolor! "white") (envt.set-fgcolor! "white") (envt.update-displays!) (fractal-rectangle! canvas color.grey 0 0 200 200 2) (sushi-roll! canvas 111 200 200) (envt.update-displays!)