Skip to content

Instantly share code, notes, and snippets.

@jonthegeek
Created September 21, 2019 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonthegeek/98a9206acc6662d660e8c1aea21cd54a to your computer and use it in GitHub Desktop.
Save jonthegeek/98a9206acc6662d660e8c1aea21cd54a to your computer and use it in GitHub Desktop.
frink <- magick::image_read(
"https://jeroen.github.io/images/frink.png"
)
bitmap <- frink[[1]]
radius <- 20
x_seq <- seq_len(dim(bitmap)[[2]])
y_seq <- seq_len(dim(bitmap)[[3]])
center_x <- median(x_seq)
center_y <- median(y_seq)
for(x in x_seq) {
for(y in y_seq) {
if ((x-center_x)^2 + (y-center_y)^2 > radius^2) {
bitmap[,x,y] <- as.raw(c(0x00, 0x00, 0x00, 0x00))
}
}
}
magick::image_read(bitmap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment