Learn R Programming

aRtsy (version 0.2.4)

canvas_flame: Draw a Fractal Flame

Description

This function implements the fractal flame algorithm.

Usage

canvas_flame(
  colors,
  background = "#000000",
  iterations = 1000000,
  variations = 0,
  symmetry = 0,
  blend = TRUE,
  weighted = FALSE,
  post = FALSE,
  final = FALSE,
  extra = FALSE,
  display = c("colored", "logdensity"),
  zoom = 1,
  resolution = 1000,
  gamma = 1
)

Value

A ggplot object containing the artwork.

Arguments

colors

a string or character vector specifying the color(s) used for the artwork.

background

a character specifying the color used for the background.

iterations

a positive integer specifying the number of iterations of the algorithm. Using more iterations results in images of higher quality but also increases the computation time.

variations

an integer (vector) with a minimum of 0 and a maximum of 48 specifying the variations to be included in the flame. The default 0 includes only a linear variation. Including multiple variations (e.g., c(1, 2, 3)) increases the computation time. See the details section for more information about possible variations.

symmetry

an integer with a minimum of -6 and a maximum of 6 indicating the type of symmetry to include in the flame. The default 0 includes no symmetry. Including symmetry decreases the computation time as a function of the absolute symmetry value. See the details section for more information about possible symmetries.

blend

logical. Whether to blend the variations (TRUE) or pick a unique variation in each iteration (FALSE). blend = TRUE increases computation time as a function of the number of included variations.

weighted

logical. Whether to weigh the functions and the variations (TRUE) or pick a function at random and equally weigh all variations (FALSE). weighted = TRUE significantly increases the computation time.

post

logical. Whether to apply a post transformation in each iteration.

final

logical. Whether to apply a final transformation in each iteration.

extra

logical. Whether to apply an additional post transformation after the final transformation. Only has an effect when final = TRUE.

display

a character indicating how to display the flame. colored (the default) displays colors according to which function they originate from. logdensity plots a gradient using the log density of the pixel count.

zoom

a positive value specifying the amount of zooming.

resolution

resolution of the artwork in pixels per row/column. Increasing the resolution does not increases the computation time of this algorithm.

gamma

a numeric value specifying the gamma correction (only used when display = "colored"). Larger values result in brighter images and vice versa.

Author

Koen Derks, koen-derks@hotmail.com

Details

The variation argument can be used to include specific variations into the flame. See the appendix in the references for examples of all variations. Possible variations are:

  • 0: Linear (default)

  • 1: Sine

  • 2: Spherical

  • 3: Swirl

  • 4: Horsehoe

  • 5: Polar

  • 6: Handkerchief

  • 7: Heart

  • 8: Disc

  • 9: Spiral

  • 10: Hyperbolic

  • 11: Diamond

  • 12: Ex

  • 13: Julia

  • 14: Bent

  • 15: Waves

  • 16: Fisheye

  • 17: Popcorn

  • 18: Exponential

  • 19: Power

  • 20: Cosine

  • 21: Rings

  • 22: Fan

  • 23: Blob

  • 24: PDJ

  • 25: Fan2

  • 26: Rings2

  • 27: Eyefish

  • 28: Bubble

  • 29: Cylinder

  • 30: Perspective

  • 31: Noise

  • 32: JuliaN

  • 33: JuliaScope

  • 34: Blur

  • 35: Gaussian

  • 36: RadialBlur

  • 37: Pie

  • 38: Ngon

  • 39: Curl

  • 40: Rectangles

  • 41: Arch

  • 42: Tangent

  • 43: Square

  • 44: Rays

  • 45: Blade

  • 46: Secant

  • 47: Twintrian

  • 48: Cross

The symmetry argument can be used to include symmetry into the flame. Possible options are:

  • 0: No symmetry (default)

  • -1: Dihedral symmetry

  • 1: Two-way rotational symmetry

  • (-)2: (Dihedral) Three-way rotational symmetry

  • (-)3: (Dihedral) Four-way rotational symmetry

  • (-)4: (Dihedral) Five-way rotational symmetry

  • (-)5: (Dihedral) Six-way rotational symmetry

  • (-)6: (Dihedral) Snowflake symmetry

References

https://flam3.com/flame_draves.pdf

See Also

colorPalette

Examples

Run this code
# \donttest{
set.seed(3)

# Simple example, linear variation, relatively few iterations
canvas_flame(colors = c("dodgerblue", "green"), variations = 0)

# Simple example, linear variation, dihedral symmetry
canvas_flame(colors = c("hotpink", "yellow"), variations = 0, symmetry = -1, iterations = 1e7)

# Advanced example (no-blend, weighted, sine and spherical variations)
canvas_flame(
  colors = colorPalette("origami"), variations = c(1, 2),
  blend = FALSE, weighted = TRUE, iterations = 1e8
)

# More iterations give much better images
set.seed(123)
canvas_flame(colors = c("red", "blue"), iterations = 1e8, variations = c(10, 17))
# }

Run the code above in your browser using DataLab