Skip to content

Instantly share code, notes, and snippets.

@georgemsavva
Last active December 7, 2024 23:29
Show Gist options
  • Save georgemsavva/6c8b86501e452c85e50aecd921ad0b5f to your computer and use it in GitHub Desktop.
Save georgemsavva/6c8b86501e452c85e50aecd921ad0b5f to your computer and use it in GitHub Desktop.
a frosty fractal
par(mfrow=c(1,1))
par(mar=c(0,0,0,0))
l=1.2
# variables
res=1000
n=500
x <- y <- seq(-l,l, length.out=res)
c <- outer(x,y*1i,FUN="+")
z <- matrix(0.0, nrow=res, ncol=res)
o <- matrix(1e5, nrow=res, ncol=res)
index <- which(Mod(z) < 5)
o[index] <- pmin(o[index] , abs(1-Mod(z[index])))
for (rep in 1:20) {
#print(rep)
index <- which(Mod(z) < 5)
z[index] <-
1*z[index]^(7) +
1*c[index]
z[index] <-
z[index]^(13)+
1*c[index]
}
z=z^3*1
for (rep in 1:n) {
z[index] <- (z[index]^2)-(0.48-.62i)
o[index] <- pmin(o[index] , abs(Mod((z[index]))))
}
o2 <- -log(o)
o2 <- (o2 - min(o2)) / (max(o2)-min(o2))
pal=sample(hcl.pals(),1)
print(pal)
image(x,y,pmax(o2^1.1,0),
col=hcl.colors(pal="Broc",1000, rev=F
),
asp=1,axes=F,ann=F,useRaster=TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment