Project #5 Make Your Own Library: frac.js
Description
frac.js is a p5 library that allows you to create simple recursive fractals using images. Using pngs is recommended.
Documentation
Basic Fractal Function
basicFractal(img, x, y, w, h, limit, scaling, [xoffset], [yoffset], [rotation], [offsetscaling])
Draws a simple, unidirectional fractal.
Parameters:
img: The image you want to replicate. This should be preloaded into a variable in p5.
x: The x-coordinate of the starting fractal.
y: The y-coordinate of the starting fractal.
w: The width of the starting fractal in pixels.
h: The height of the starting fractal in pixels.
limit: The limit to which you want the fractal to repeat in pixels. Recommended 20.
scaling: Fractals in this library scale down. This determines the amount of scaling. Should input a value between 0.75 and 0.99.
xoffset: Amount of x-offset on the next copy. Optional.
yoffset: Amount of y-offset on the next copy. Optional.
rotation: Amount of rotation on the next copy. Rotation is affected by the scaling value. Optional.
offsetscaling: This determines if offsets are scaled by the scaling value. Input true or false. Default false. Optional.
Particle Fractal Function
particleFractal(img, x, y, w, h, limit, scaling, showPercent, [randomRotate])
Draws a pseudo particle system fractal.
Parameters:
img: The image you want to replicate. This should be preloaded into a variable in p5.
x: The x-coordinate of the starting fractal.
y: The y-coordinate of the starting fractal.
w: The width of the starting fractal in pixels.
h: The height of the starting fractal in pixels.
limit: The limit to which you want the fractal to repeat in pixels. Recommended 20.
scaling: Fractals in this library scale down. This determines the amount of scaling. Should input a value between 0.75 and 0.99.
showPercent: This sets the amount of copies from the grid to be randomly shown. Input value between 0.0001 and 0.2.
randomRotate: Randomly rotates all shown copies. Input true or false. Default false. Optional.