gl-react-julia
Universal gl-react Julia set fractals.
Julia sets are generated by iterating z = z^p + c
for each point z
in the complex plane.
This package includes a standard Julia set (<JuliaFractal>
)), along with two extensions of the concept:
-
<JuliaImageFractal>
: picks up paint from a source image at each successivez
and combines it as the color of pixelz0
-
<JuliaFieldFractal>
: like JuliaImageFractal, butp
is recomputed each iteration as a function of the underlying image color and any other numbers that are handy (e.g.z
,c
,z0
, etc.)
Props
- center (required): [x, y]
- zoom (required): 0 is full size, 1 is double magnification, 2 is 4x, ...
- c (required): Julia constant -- [real, imaginary]
- p (required): Julia power (
number
) (or input toJuliaFieldFractal
'sfieldExpr
) - image: source url for
JuliaImageFractal
andJuliaFieldFractal
- fieldExpr: e.g.
dot(hsv.xz, z)
-- Julia powerp
varies with the angle between (hue, brightness) and (real, imaginary) vectors. The output is interpreted as a proportion ofr
vsq
:p = q + (r-q)*$fieldExpr
. - q (
JuliaFieldFractal
only) -- input tofieldExpr
- r (
JuliaFieldFractal
only) -- input tofieldExpr
npm
npm install --save gl-react-julia gl-react gl-react-dom
npm install --save-dev @types/gl-react @types/gl-react-dom buffer
Example
import { Surface } from "gl-react-dom"; // for React DOM
import { JuliaImageFractal } from 'gl-react-julia';
const imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/8/8c/%22Alexander_Visits_the_Sage_Plato_in_his_Mountain_Cave%22%2C_Folio_from_a_Khamsa_%28Quintet%29_of_Amir_Khusrau_Dihlavi_MET_h1_13.228.30.jpg';
function App() {
return <Surface width={900} height={600}>
<JuliaImageFractal
center={[-.5, 0]}
zoom={2.1}
c={[.65, -.35]}
p={3}
image={imageUrl}
/>
</Surface>;
}