(require "common.scm") (define width 400) (define height 250) (let* ( (v_width (* width 2)) (v_height (* height 2)) (img (Gd.create_truecolor v_width v_height)) (img2 (Gd.create_truecolor width height)) (ca (img#colors)) (bg (ca#create 255 255 255)) (line (ca#create 0 0 127)) (rad (/. (*. 4.0 (atan 1.0)) 180.0)) (ax (*. 30.0 rad)) (ay (*. -25.0 rad)) (center_x (float_of_int (/ v_width 2))) (center_y (float_of_int (/ v_height 2))) (ls (Array.of_list (list-ec (for i 0 50) (Array.of_list (list-ec (for j 0 50) (let z (float_of_int (- (* i 10) 250))) (let x (float_of_int (- (* j 10) 250))) (let y (*. 30.0 (cos (+. (*. (sqrt (+. (*. x x) (*. z z))) rad) (cos (*. 3.0 (sqrt (+. (*. x x) (*. z z))) rad))))) ) (tuple (int_of_float (+. center_x (+. (*. x (cos ay)) (*. z (sin ay))))) (int_of_float (-. center_y (-. (*. y (cos ax)) (*. (+. (*. x -1.0 (sin ay)) (*. z (cos ay))) (sin ax))))) (int_of_float z)))))) ) ) (img#filled_rectangle 0 0 (- v_width 1) (- v_height 1) bg) (List.iter (fun ((i j)) (if (> j 0) (let ( ((x y z) (Array.get (Array.get ls i) j)) ((px py pz) (Array.get (Array.get ls i) (- j 1))) ) (img#line x y px py line) ) ) (if (> i 0) (let ( ((x y z) (Array.get (Array.get ls i) j)) ((px py pz) (Array.get (Array.get ls (- i 1)) j)) ) (img#line x y px py line) ) ) ) (list-ec (for i 0 50) (for j 0 50) (tuple i j))) (img2#copy_resampled img 0 0 0 0 width height v_width v_height) (img2#save_as_png "draw3.png") )