Skip to content

Instantly share code, notes, and snippets.

@chichacha
chichacha / Abstract_Text_Image.R
Last active January 26, 2019 21:34
Abstraction of Text -
library(tidyverse)
library(magick)
library(imager)
library(ggvoronoi)
library(TSP)
create_char_image <- function(char="美"){
data.frame() %>%
ggplot(aes(x=0,y=0)) +
@chichacha
chichacha / HalfCircle_Triangle.r
Created January 27, 2019 00:57
HalfCircles & Triangles
library(tidyverse)
#half_circle
half_circle <- function(xc=0,yc=0,r=1,shift=0,points=100,...){
df <- tibble(
t = seq(shift ,pi+shift,length.out=points),
x = xc + r*cos(t),
y = yc + r*sin(t)
)
return(df %>% select(x,y))
@chichacha
chichacha / Rectangles_Playground.r
Created January 27, 2019 04:55
Drawing Rectangles
library(tidyverse)
library(scales)
phi <- (1 + sqrt(5))/2
draw_rect <- function(xr=1,yr=1,name="square") {
df <- tibble(
x=c(0,0,xr,xr,0),
y=c(0,yr,yr,0,0)
)
@chichacha
chichacha / Dots on Lines.r
Created February 8, 2019 07:15
Chaos but not chaos
make_params <- function(n=60){
params <- tibble(
x1 = runif(n),
x2 = runif(n),
y1 = runif(n),
y2 = runif(n)
) %>% mutate(g=row_number())
}
@chichacha
chichacha / Happy_VDay.r
Created February 15, 2019 04:38
Drawing Heart Shape & Revealing It
## drawing heart!
library(tidyverse)
library(gganimate)
## function to create data frame for heart shape with 100 points.
heart_vertices <- function(xc=0,yc=0,npoints=100,...){
t = seq(-pi,pi, length.out=npoints+1)
x = xc + 16 *(sin(t))^3
y = yc + 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t)
@chichacha
chichacha / annotate_raster_experiment.R
Created July 27, 2019 22:23
Experimenting with Raster Image as Background
library(tidyverse)
## creating raster to use as background
## get your favourite colour
colpal <- c("#fe4a49", "#2ab7ca", "#fed766", "#e6e6ea", "#f4f4f8")
viridis_bg <- matrix(viridis_pal()(150*50),nrow=50)
@chichacha
chichacha / Interpolation_Raster.md
Created July 28, 2019 01:07
Uploading RMD file using gistr package

title: "Testing gistr package" author: "Chisato" date: "27/07/2019" output: html_document: highlight: kate theme: spacelab

@chichacha
chichacha / geom_delaunay_tile function.R
Created August 10, 2019 23:34
Playing around with ggforce package
library(tidyverse)
library(ggforce)
df <- tibble() %>%
expand(x=c(0:32), y=c(0:16))
df %>%
sample_n(nrow(df)-1) %>%
ggplot(aes(x=x,y=y)) +
@chichacha
chichacha / ShapeForCD.R
Created August 11, 2019 05:43
Drawing Logo for CD
library(tidyverse)
library(ggforce)
my_points <- tibble(
x = c(1,4,4,0,0,4,4,1,1,2.5,0,0,0,2.5,1,0),
y = c(0,0,2,2,5,5,7,7,0,0,5,2,2,7,7,5),
g = c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
)
my_points2 <- my_points %>%
@chichacha
chichacha / create_art_with_words.R
Created August 11, 2019 21:51
Experimentation with ggforce Package
library(tidyverse)
library(tidytext)
library(ggforce)
library(patchwork)
library(ggthemes)
## prep colour palettes
hue_circle <- ggthemes::tableau_color_pal("Hue Circle")(16)