# Plot Data: x,y,r
x <- numeric(length=50)
y <- numeric(length=50)
r <- numeric(length=50)
for(t in 1:50) {
xy <- exp(1i * t/2 - t/12)
x[t] <- Re(xy)
y[t] <- Im(xy)
r[t] <- sqrt(x[t]^2 + y[t]^2)
}
# New class object
m <- LightMapper$new(xdim=500, ydim = 400, blend_mode = "screen")
# Map data on to raster
m$map(x=x, y=y, intensity = 1, radius = r/100, falloff_exponent = 0.5, distance_exponent = 2)
# Output raster data as a dataframe
pd <- m$output_dataframe(saturation = 1)
# Plot with ggplot
ggplot(pd, aes(x = x, y = y, fill = value)) +
geom_raster(show.legend = FALSE) +
scale_fill_gradientn(colors=additive_alpha(c("black", "purple", "white"))) +
coord_fixed(ratio = m$aspect(), xlim = m$xlim(), ylim = m$ylim(), expand = FALSE) +
theme_night(bgcolor = "black")
Run the code above in your browser using DataLab