Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Width of the final picture
- (define WIDTH 512)
- ;; Height of the final picture
- (define HEIGHT 512)
- ;; Number of grid cells
- (define SCALE 64)
- ;; The width of the grid
- (define GWIDTH (/ WIDTH SCALE))
- ;; The height of the grid
- (define GHEIGHT (/ HEIGHT SCALE))
- ;; Defines a 2D Vector
- ;; x - The x-value of the vector
- ;; y - The y-value of the vector
- (define-struct vector2d (x y))
- ; create-gradients: number -> (list of vector)
- ; Ruft die local Funktion "create" auf
- ; Bsp: (create-gradients 2) ergibt:
- ;(list(make-vector2d #i-0.9916790270710302 #i0.5249526803021658)(make-vector2d #i0.5993336254015262 #i0.8165964304676605))
- (define (create-gradients n)
- ;create: list number -> (listof vector)
- ;Erzeugt eine Liste, mit der Länge des übergebenen Parameter, von zufälligen Gradienten
- ;Bsp: (create '() 2) ergibt (list (make-vector2d #i0.5557147071202895 #i0.16166538194593366) (make-vector2d #i-0.8928569845064996 #i0.6875843026669924))
- (local
- ((define (create lst n)
- (cond
- [(= n (length lst)) lst]
- [else (create (append lst (cons (make-vector2d (cos(* 2 pi (random))) (sin (* 2 pi (random)))) '()))n)]
- )))
- (create '() n)
- ))
- ;; fade: number -> number
- ;; Uses a Sigmoid function to smooth numbers betwenn 0 to 1
- ;; Example: (fade 1) -> 1
- (define (fade t)
- (+ (- (* 6 t t t t t) (* 15 t t t t)) (* 10 t t t))
- )
- (check-expect (fade 1) 1)
- (check-within (fade 0.5) 0.5 0.001)
- (check-within (fade 0.3) 0.16308 0.001)
- (check-within (fade 0.8) 0.94208 0.001)
- ;; Globally store the list of gradients
- (define gradients (create-gradients (* (+ 1 GWIDTH) (+ 1 GHEIGHT))))
- ; linear-interpolation: number number number -> number
- ; Führt die lineare Interpolation zwischen zwei Werten x,y mit einem Gewicht w durch.
- ; Bsp: (linear-interpolation 3 4 5) ergibt 8
- (define (linear-interpolation x y w)
- (+ (* ( - 1 w) x)(* w y))
- )
- (check-expect (linear-interpolation 3 4 5) 8)
- (check-expect (linear-interpolation 7 8 9) 16)
- ;dot-grid-gradient: number number number number -> number
- ;Berechnet das Skalarprodukt von zwei Vektoren
- ;Bsp: (dot-grid-gradient 5 8 40 50) ergibt 77
- (define (dot-grid-gradient ix iy x y)
- (+ (* (- x ix)) (* (- y iy) ))
- )
- (define (perlin-noise x y)
- 1
- )
- (define (create-land width height)
- 1
- )
- ;(save-image (color-list->bitmap (create-land WIDTH HEIGHT) WIDTH HEIGHT) "land.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement