generative-toolbelt.utils
A handy set of utility functions.
h
(h)(h n)Gets the Height of the canvas. `n` is an optional float value to multiply to the canvas height.
in-canvas?
(in-canvas? point)Checks if a Point is inside the canvas or not. Returns a boolean.
margin-range
(margin-range A B N MARGIN)Returns a sequence of `N` element going from `A` to `B`. `MARGIN` defines a certain margin from A and B.
n-times
(n-times n f)Call a certain function N times on its output.
not-nil?
(not-nil? something)Shortcut for (not (nil? x)) Returns a boolean.
odds
(odds value)Returns true if the random is inside the value range (0-1)
print-to-system-out
(print-to-system-out s)Prints to the original System/out stream. Useful when working with multiple tools and you want to output always on the repl console.
process-draw-options
(process-draw-options drawOpt)Process a drawing options dictionary.
r-float
(r-float low high)Get a random float number between two values.
r-gaussian
(r-gaussian)(r-gaussian center)(r-gaussian center ampl)Returns a random number from a gaussian distribution. `center` can be changed to define a custom mean. `ampl` can be changed to define the amplitude of the distribution.
r-gaussian-abs
(r-gaussian-abs)(r-gaussian-abs center)(r-gaussian-abs center ampl)Returns a random number from a positive half gaussian. See r-gaussian for more info.
r-int
(r-int high)(r-int low high)Gets a random int number between two values (Exclusive).
r-normal
(r-normal)(r-normal to)(r-normal from to)Returns a random number from a normal distribution. defaults return a float from 0 to 1. `to` can be defined to get a random float from 0 to `to` (Exclusive). `from` can be defined to get a random float from `from` (inclusive) to `to` (exclusive).
r-normal-int
(r-normal-int to)(r-normal-int from to)Returns a random INTEGER number from a normal distribution. See r-normal for more info.
r-seed
(r-seed seed)Sets the seed for the random functions.
replace-first
(replace-first SEQ NEW)Returns a new sequence from `SEQ` with the first element replaced with `NEW`.
replace-first-and-last
(replace-first-and-last SEQ NEWF NEWL)Returns a new sequence from `SEQ` with the first and last element replaced with `NEWF` and `NEWL`.
replace-last
(replace-last SEQ NEW)Returns a new sequence from `SEQ` with the last element replaced with `NEW`.
replace-nth-seq
(replace-nth-seq s ele ind)IMPROVE/CONTROL Replace the nth element from a sequence.
replace-pos-seq
(replace-pos-seq s ele position)IMPROVE/CONTROL Replace an element inside a sequence. position is a 0-1 float that indicates the relative position of the element to replace.
reset-blend-mode
(reset-blend-mode)Resets the blend mode to default.
reset-draw-options
(reset-draw-options)Resets the drawing options to default values.
seq-to-vector
(seq-to-vector s)IMPROVE/CONTROL Converts a Sequence to a Vector.
vector-to-seq
(vector-to-seq v)IMPROVE/CONTROL Converts a Vector to a Sequence.
w
(w)(w n)Gets the Width of the canvas. `n` is an optional float value to multiply to the canvas width.