Last active
October 22, 2024 07:06
-
-
Save georgemsavva/0a864f7e8aba84527ce2bb0d3cf44fab to your computer and use it in GitHub Desktop.
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
# There is some explanation for why the bitwise operator functions do what they do here: | |
# https://inventwithpython.com/blog/2021/08/02/algorithmic-art-with-the-bitfielddraw-module/ | |
# ignore the warnings, THIS IS ART! | |
library(ggplot2) | |
cols <- c("#b8e1c5", "#3ac9fb", "#fadacc","#fcb2c6", | |
"#002f88", "#fd7a5d","#00B850", "#091a22") | |
N=96 | |
ggplot(expand.grid(x=1:N,y=1:N,t=11))+aes(x,y)+ | |
geom_raster(aes(fill=factor( | |
bitwAnd(2/3*(x+y),y-abs(x+y))%%(t) | |
))) + | |
geom_point(size=1,aes(pch=factor( | |
bitwXor(x,y-x)%%(t)), | |
col=factor(bitwAnd(10*(x)+y,y-x)%%(t)))) + | |
scale_fill_manual(values=c(cols,rep(NA,100)),na.value = hsv(0,0,0,0))+ | |
scale_color_manual(values=c(cols[1:6],rep(NA,100)),na.value = hsv(0,0,0,0))+ | |
theme_void()+ | |
theme(legend.position = "none", | |
plot.background = element_rect(fill="#f5f5f5", color = NA))+ | |
coord_fixed() | |
ggsave("bits.jpg",width=10,height=10,dpi="retina") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment