Bezier Curve

Coloring Formula

by Kerry Mitchell, 07 Apr 2000

Basic information

As a fractal is being computed, the iterate (typically, the z variable) can bounce around all over the complex plane.  This formula colors the pixel according to some condition related to how close z comes to a given curve.  The curve is a Bezier curve, which is a general spline between 2 points.

Bezier curves were developed by Pierre Bézier in the 1970's for CAD/CAM operations, and became the underpinnings of the entire Adobe PostScript drawing language.  A cubic Bezier curve is defined by 4 points, 2 endpoints (or anchor points) and 2 control points.  The curve begins at the first anchor point, and ends at the second.  At the first anchor, the curve is tangent to the line from the first anchor to the first control point.  Similarly, at the second anchor, it is tangent to the line from the second control point to the second anchor.  Thus, the control points serve to pull the curve into a particular shape.  With a proper choice of points, all manners of curves can be generated, from straight lines to loops.

The general nature of Bezier curves means that they can't be easily expressed in terms of x and y, like lines and circles can.  They are parameterized with a variable t, which runs from 0 at the first anchor point to 1 at the second.  In this coloring method, the curve is discretized by choosing a finite number of points (determined by the "step size" parameter).  Each iteration is checked against every discrete point on the curve.  Consequently, this can be a very slow method.

Parameters

Hints

To see how the distances work, try using the "built-in fast Julia" formula type.  Set the seed to (0,0), the number of iterations to 1, and use this formula for the inside coloring.  Use the "show curve" choice of the "color by" parameter.

For long curves, use a smaller step size if you want the appearance of solid lines.  Also use a smaller step size if you're planning to render the image at a high resolution, to fill in the gaps between dots.  If your curve has sharp turns, that will affect the distribution of the dots, and you may wish to decrease the step size in that case, too.

Sample image

BezierCurveSample {
; copyright Kerry Mitchell 07jan00
fractal:
  title="Bezier Curve Sample" width=640 height=480 author="Kerry Mitchell"
  created="January 7, 2000" numlayers=10
layer:
  method=multipass caption="y curve" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=0.7/0.75 p_z1=1.1/0.75 p_z2=0.7/0 p_z3=1.1/0 p_dt=0.004 p_nexp=0.1
  p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="y slant" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=1.5/0.75 p_z1=1.1/0 p_z2=1.1/0 p_z3=0.7/-0.75 p_dt=0.006 p_nexp=0.1
  p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="r arch" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=1.1/0.5 p_z1=0.7/0.5 p_z2=0.3/0.5 p_z3=0.3/-0.25 p_dt=0.006
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="r vertical" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=0.3/0.5 p_z1=0.3/-0.125 p_z2=0.3/-0.125 p_z3=0.3/-0.75 p_dt=0.006
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="r arch" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=0.7/0.75 p_z1=0.5/0.75 p_z2=-0.1/0.75 p_z3=-0.1/0 p_dt=0.004
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="r vertical" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=-0.1/0.75 p_z1=-0.1/0 p_z2=-0.1/0 p_z3=-0.1/-0.75 p_dt=0.002
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="e crossbar" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=-1.2/0 p_z1=-0.85/0 p_z2=-0.85/0 p_z3=-0.5/0 p_dt=0.006 p_nexp=0.1
  p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="e curve" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=-0.45/0.75 p_z1=-1.5/0 p_z2=-1.5/0 p_z3=-0.45/-0.75 p_dt=0.004
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="K curve" opacity=100 visible=yes alpha=no
  mergemode=darken
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=-0.5/1.2 p_z1=-1.83/0 p_z2=-1.83/0 p_z3=-0.5/-1.2 p_dt=0.002
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
layer:
  method=multipass caption="K vertical" visible=yes alpha=no
mapping:
  center=0/0 magn=1 angle=0
formula:
  filename="Standard.ufm" entry="FastJulia" maxiter=1 percheck=off
  p_Seed=0/0 p_Bailout=1000
inside:
  filename="lkm.ucl" entry="bezier-curve" transfer=linear repeat=no
  p_z0=-1.5/1.2 p_z1=-1.5/0 p_z2=-1.5/0 p_z3=-1.5/-1.2 p_dt=0.002
  p_nexp=0.1 p_colorby="minimum distance"
outside:
  filename="lkm.ucl" entry="basic" transfer=none repeat=yes
  p_colorby="iteration"
gradient:
  smooth=yes numnodes=2 index=0 color=0 index=399 color=16777215
}