Hi, perhaps a stupid question, but I'm stumped. How can I "wrap around" the animation here? (I mean how do I make it look like it's a infinite strip scrolling right?)
(ns depata_lanuwa
(:require [quil.core :as q]
[quil.helpers.drawing :refer [line-join-points]]
[quil.helpers.seqs :refer [range-incl]]))
(defn rand-walk-coords
[seed]
(lazy-seq (cons seed (rand-walk-coords (+ seed (/ (- (rand 5) 1) 20))))))
(defn slightly-natural-horizontal-line
[x-start x-end y]
(let [step 2
xs (range-incl x-start x-end step)
ys (rand-walk-coords y)
line-args (line-join-points xs ys)]
(dorun (map #(apply q/line %) line-args))))
(defn slightly-natural-vertical-line
[y-start y-end x]
(let [step 2
ys (range-incl y-start y-end step)
xs (rand-walk-coords x)
line-args (line-join-points xs ys)]
(dorun (map #(apply q/line %) line-args))))
(defn n-natural-horizontal-lines
[x-start x-end y-start n y-dist]
(doseq [y
(->> (range-incl n)
(map (comp (partial + y-start) (partial * y-dist))))]
(slightly-natural-horizontal-line x-start x-end y)))
(defn n-natural-vertical-lines
[y-start y-end x-start n x-dist]
(doseq [x
(->> (range-incl n)
(map (comp (partial + x-start) (partial * x-dist))))]
(slightly-natural-vertical-line y-start y-end x)))
(defn single-block [weight stroke x n d]
(q/stroke-weight weight)
(q/smooth 8)
(apply q/stroke stroke)
(let [nd (* n d)]
(n-natural-horizontal-lines x (+ x nd) 10 n d)
(n-natural-vertical-lines 10 (+ 10 nd) (+ x nd) n d)
(n-natural-vertical-lines (+ 10 nd) (+ 10 (* 2 nd)) x n d)
(n-natural-horizontal-lines (+ x nd) (+ x (* 2 nd)) (+ 10 nd) n d))
)
(def x-offset (atom 0))
(reset! x-offset 0)
(defn draw []
(q/background 255)
(q/stroke 0 0 0)
; Top border
(q/stroke-weight 3)
(q/stroke 0 0 0)
(q/line [0 10] [600 10])
; Bottom border
(q/stroke-weight 3)
(q/stroke 0 0 0)
(q/line [0 110] [600 110])
(q/frame-rate 30)
(doseq [x (range-incl 0 500 100)]
(single-block 1 [0 0 0] (+ @x-offset x) 5 10))
(swap! x-offset inc)
)
(q/defsketch depata_lanuwa
:title ""
:settings #(q/smooth 2)
;;:setup draw
:draw draw
:size [600 120])Got it π I had to wrap the q/line function
Any easy way to turn an animation into a gif?
I think I used imagemagick myself
Iβve pondered whether there are easier solutions. For just recording a .mov video, I use Quicktime Player on Mac, it has a great screen recorder where you can select part of the screen. And no install - it comes with the OS π I wonder if thereβs some good .mov->gif tool. Maybe imagemagick can do it.
AFAIR ffmpeg can convert .mov to .gif
Ah, well π
I think Iβm confusing imagemagick and ffmpeg
For the best quality and infinite loops ImageMagicks's convert with saved individual frames is the option I use most. Saving to .mov adds another lossy compression step.
Thanks for the tip!
Just save individual frames and use external tool to combine them into gif.
hi, how do I add some randomness/noise to a black horizontal line for example? To make it look less artificial?
Create line by chunks using vertex.