snowflakes {snowflakes} | R Documentation |
Plots Randomly Generated Snowflakes
Description
The function generates and plots random snowflakes. Each snowflake is defined by a given diameter, width of the crystal, color, and random seed. Snowflakes are plotted in such way that they always remain round, no matter what the aspect ratio of the plot is. Snowflakes can be created using transparent colors, which create a more interesting and more realistic image. Images of the snowflakes can be separately saved in svg files and used in websites as static or animated images.
Usage
snowflakes(xCoor, yCoor, radius, orientation = pi/6,
deltaCoef = 15, color = "#00007744", anotherColor = color,
aspectRatio = NULL, seeds = NULL)
Arguments
xCoor |
The X coordinate of the snowflake. This argument may be a vector when multiple snowflakes are plotted. |
yCoor |
The Y coordinate of the snowflake. This argument may be a vector when multiple snowflakes are plotted. |
radius |
The radius of the snowflake. This argument may be a vector when multiple snowflakes are plotted. |
orientation |
The angle of the snowflake relatively to its center, measured in radians. Note that the rotation of the snowflake around its center can be visible only within a range from 0 to the sixth of the constant pi because the snowflake has 6 axes. This argument may be a vector when multiple snowflakes are plotted. |
deltaCoef |
By how much the radius is lager than the width of the crystal. The width of the crystal is computed as a ratio of the |
color |
The color of the snowflake (can be transparent). This argument may be a vector when multiple snowflakes are plotted. |
anotherColor |
The color of the main frame of the snowflake. This argument may be a vector when multiple snowflakes are plotted. |
aspectRatio |
Aspect ratio of the snowflake. Aspect ratio is chosen automatically so that the snowflake remains round. If changed, the snowflake might not be round any longer. This argument may be a vector when multiple snowflakes are plotted. |
seeds |
Random seed that defines a unique snowflake given that other parameters are assigned to their defaults. |
Details
See the vignette for more details and examples.
Value
Returns seeds that were used to generate the snowflakes. The user can save them and use the ones that are associated with the most appealing snowflakes.
Author(s)
Svetlana Eden <svetlana.eden@vanderbilt.edu>
References
https://github.com/SvetlanaEden/SNOWFLAKES
Examples
t = seq(0, 5*pi, .5)
xCoor = t*cos(t)
yCoor = t*sin(t)
radius = 1
orientation = runif(length(xCoor))*(pi/6)
set.seed(1)
plot(xCoor, yCoor, type="l", axes = TRUE, ylab="", xlab="",
ylim = range(yCoor) + radius*c(-1, 1)*3,
xlim = range(xCoor) + radius*c(-1, 1)*0, col=gray(.9))
returnedSeeds = snowflakes(xCoor = xCoor, yCoor = yCoor, radius = radius,
orientation = orientation, seeds = 1:3,
color = gray((1:length(xCoor))/(length(xCoor)+1)), anotherColor = "gray")