SHARE
TWEET
Untitled
a guest
Sep 27th, 2014
182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- ;;; ATTEMPT 1 -- draw-pixel. This works.
- (defn render [entity screen]
- (swap! scale #(+ % (- (rand) 0.5)))
- (let [pm (Pixmap. 50 150 (pixmap-format :r-g-b-a8888))]
- (doseq [x (range 50)
- y (range 150)]
- (let [v (SimplexNoise/noise (/ x @scale) (/ y @scale))
- v (/ (inc v) 2)]
- (pixmap! pm :set-color (color v v v 1))
- (pixmap! pm :draw-pixel x y)))
- (draw! screen [(texture pm)])
- (pixmap! pm :dispose)))
- ;;; ATTEMPT 2 -- create a Gdx2DPixmap. This is broken.
- (defn render [entity screen]
- (swap! scale #(+ % (- (rand) 0.5)))
- (let [colors (for [x (range 50)
- y (range 150)]
- (let [v (SimplexNoise/noise (/ x @scale) (/ y @scale))
- v (/ (inc v) 2)
- v (* 255 v)
- v (Math/floor v)]
- [v v v 1]
- ))
- pixbytes (byte-array (concat [50 150 4] (flatten colors)))
- gp (Gdx2DPixmap. pixbytes 0 (count pixbytes))
- pm (Pixmap. gp)]
- (draw! screen [(texture pm)])
- (pixmap! pm :dispose)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
