This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You'll need to install ffmpeg to make this work. | |
# Creates a lot of pngs and an mp4 in the working directory, | |
# and will overwrite anything with the same name | |
# so be careful. | |
lt <- 600 | |
mt <- 400 | |
t <- seq(0,mt,l=lt) | |
a <- 1 # I don't use 'a' in this particular animation. | |
d <- expand.grid(a=a, t=t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rgl) | |
## Open the 3D device | |
open3d(windowRect = c(20, 30, 800, 800), bg=list("white") ) | |
## Make the data frame for plotting | |
d <- expand.grid(x=seq(0,2*pi,l=100), y=seq(0,2*pi,l=100)) | |
## Set the increment | |
inc = pi*2 / 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pickover <- function(prev, p){ | |
c( | |
sin(p[1]*prev[2])+p[3]*sin(p[1]*prev[1]), | |
sin(p[2]*prev[1])+p[4]*sin(p[2]*prev[2]) | |
) | |
} | |
computeAttractor <- function(params,funs,n=1e4,startX){ | |
X=matrix(NA, nrow=n, ncol=length(startX)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>GLSL Experiment</title> | |
<meta | |
name="viewport" | |
content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" | |
/> | |
<meta property="og:image" content="thumbnail.jpg" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str<-strsplit(readChar(basename(sys.frame(1)$ofile),1e5),"")[[1]]; | |
w=ceiling(sqrt(length(str)-2));N=300; | |
d<-data.frame(x=floor(runif(N,0,w)),y=floor(runif(N,0,w)),h=runif(N,0,1)^4,s=.5,v=sqrt(runif(N,0.8,1))); | |
## refugees welcome ##; | |
d2<-data.frame(labels=str,x=(seq_along(str)-1)%%w,y=(seq_along(str)-1)%/%(w)); | |
blanks<-d2[d2$labels%in%c(" ","\n"),] | |
library(ggplot2) | |
### THE CODE IS THE ART ### | |
ggplot(d,aes(x,y,fill=hsv(h,s,v)))+ | |
geom_raster()+theme_void()+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str=strsplit(readChar(sys.frame(1)$ofile,1e5),"")[[1]]; | |
r=ceiling(sqrt(length(str)-1));for(i in 1:320){print(i); | |
##THE.CODE.IS.THE.ART## | |
inc=i/320; | |
p1 = 2.5*1i^(4*inc); | |
p2 = -1.5*1i^(8*inc); | |
cx = Re(p1/4+p2/4); | |
cy = Im(p1/4+p2/4); | |
x = seq(cx-3,cx+3,l=r); | |
y = seq(cy+3,cy-3,l=r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For the point.in.poly function | |
library(sp) | |
# For 'createPolygons' | |
library(gglogo) | |
# To tween polygons | |
library(transformr) | |
# To make a gif! | |
library(gifski) | |
# I'm running the code like this because I want to captue the whole call during the execution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(data.table) | |
## Implement ideas from creating symmetry | |
## chapter 7 | |
f <- function(z,a,m,n) a*(z^m*Conj(z)^n) | |
# Set resolution | |
N=2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set random number seed for reproducibility | |
set.seed(2210) | |
# Number of starting points | |
N=5000 | |
# Describe the flow function | |
flow <- function(z,bs) { | |
fz <- ((z+bs[1])*(z+bs[2])*(z+bs[3])*(z+bs[4])*(z+bs[8]))/ | |
((z+bs[5])*(z+bs[6])*(z+bs[7])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code to generate Bezier 'mesh' images inspired by the work of Jacquie Tran (https://art.jacquietran.com/) | |
# Function to calculate Bezier curves | |
bezierz <- function(z1,z2,ct,ct2,ct3,l,o=2){ | |
ll=1-l | |
if(o==3) return(z1*ll^4 + 4*ct*ll^3*l + 6*ct2*ll^2*l^2 + 4*ct3*ll*l^3 + z2*l^4) | |
if(o==2) return(z1*ll^3 + 3*ct*ll^2*l + 3*ct2*ll*l^2 + z2*l^3) | |
if(o==1) return(z1*ll^2 + 2*ct*ll*l + z2*l^2) | |
} |
OlderNewer