Inspired by @lauraalpinto: https://codepen.io/lauraalpinto/pen/qLzGBX?editors=0100
A Pen by Martin Møller Skarbiniks Pedersen on CodePen.
x <- function(k, t) { | |
c( -sin(4*pi*k/1000) + sin(t)*sin(t/3)/5, | |
-0.5*sin(8*pi*k/1000) + cos(t)/2 | |
) | |
} | |
y <- function(k, t) { | |
c( -cos(2*pi*k/1000) + cos(t)*cos(t/3)/2, | |
-0.5*cos(4*pi*k/1000) + sin(t)/3 |
library(ggplot2) | |
hexdf <- function (size = 1, mid = c(0, 0), angle = 90) { | |
width <- size * 1 | |
height <- size * 0.865 | |
xy <- shape:::getellipse(width, height, mid = mid, dr = 2 * pi/6) | |
tibble::as_tibble(structure(as.data.frame( | |
shape::rotatexy(xy,angle = angle, mid = mid)), class = "data.frame", names = c("x", "y")), validate = FALSE) | |
} |
# Yavalath board | |
library(ggplot2) | |
hexdf <- function (size = 1, mid = c(0, 0), angle = 90) { | |
width <- size * 1 | |
height <- size * 0.865 | |
xy <- shape:::getellipse(width, height, mid = mid, dr = 2 * pi/6) | |
tibble::as_tibble(structure(as.data.frame( | |
shape::rotatexy(xy,angle = angle, mid = mid)), class = "data.frame", names = c("x", "y")), validate = FALSE) |
circleFunc <- | |
function(center = c(0,0), diameter = 1, npoints = 100, start = 0, end = 2*pi) { | |
tt <- seq(start, end, length.out = npoints) | |
data.frame(x = center[1] + diameter / 2 * cos(tt), | |
y = center[2] + diameter / 2 * sin(tt)) | |
} | |
add.alpha <- function(col, alpha = 1) { | |
if(missing(col)) | |
stop("Please provide a vector colors.") |
library(ggplot2) | |
circle_alpha <- 0.3 | |
radius1 <- 25 | |
radius2 <- 75 | |
how_many <- 200 | |
reverse_colors <- FALSE | |
circleFunc <- | |
function(center = c(0,0), radius = 1, npoints = 100, start = 0, end = 2*pi) { |
polygon <- function(n) { | |
tibble( | |
x = accumulate(1:(n-1), ~.x+cos(.y*2*pi/n), .init = 0), | |
y = accumulate(1:(n-1), ~.x+sin(.y*2*pi/n), .init = 0), | |
xend = accumulate(2:n, ~.x+cos(.y*2*pi/n), .init = cos(2*pi/n)), | |
yend = accumulate(2:n, ~.x+sin(.y*2*pi/n), .init = sin(2*pi/n))) | |
} | |
ggplot(polygon(5) + geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) + theme_void() + coord_equal() |
Inspired by @lauraalpinto: https://codepen.io/lauraalpinto/pen/qLzGBX?editors=0100
A Pen by Martin Møller Skarbiniks Pedersen on CodePen.
library(gmp) | |
ONE <- as.bigz("1") | |
TWO <- as.bigz("2") | |
THREE <- as.bigz("3") | |
FOUR <- as.bigz("4") | |
SEVEN <- as.bigz("7") | |
TEN <- as.bigz("10") | |
q <- as.bigz("1") |
#http://rosettacode.org/wiki/Generate_Chess960_starting_position | |
pieces <- c("R","B","N","Q","K","N","B","R") | |
generateFirstRank <- function() { | |
attempt <- paste0(sample(pieces), collapse = "") | |
while (!check_position(attempt)) { | |
attempt <- paste0(sample(pieces), collapse = "") | |
} | |
return(attempt) |
library(digest) | |
DEBUG <- FALSE | |
while(TRUE) { | |
flag <- paste0(c(sample(c(letters,LETTERS,0:9,":","_","+"), 8, replace = TRUE)), collapse = "") | |
shasum <- substr(digest(flag,"md5", serialize=FALSE), 27,32) | |
cat(flag,shasum,"\n") | |
} |