Skip to content

Instantly share code, notes, and snippets.

View sasaki-shigeo's full-sized avatar

SASAKI Shigeo sasaki-shigeo

View GitHub Profile
@sasaki-shigeo
sasaki-shigeo / PerlinNoise.pde
Created January 21, 2019 03:21
Perlin Noise Example / パーリンノイズの使用例
size(500, 500);
for (int i = 0; i < width; i++) {
point(i, height * noise(0.01 * i));
}
@sasaki-shigeo
sasaki-shigeo / binary-recursive-tree.pde
Created December 9, 2019 03:06
drawing a binary recursive tree in Processing / 2枝の再帰的な木を描く
void setup() {
size(500, 500);
}
void draw() {
translate(width/2, height);
scale(1, -1);
tree(120);
}
@sasaki-shigeo
sasaki-shigeo / snow-falling4.pde
Created December 16, 2019 03:08
Snow crystal animation in Processing / Processing による雪の結晶のアニメーション
float[] xs = new float[100];
float[] ys = new float[100];
void setup() {
size(800, 800);
frameRate(20);
for (int i = 0; i < 100; i++) {
xs[i] = random(width);
ys[i] = random(height);
@sasaki-shigeo
sasaki-shigeo / gasket.pde
Created January 20, 2020 00:32
Sierpinski's gasket
void setup() {
size(500, 500);
fill(0);
noLoop();
}
void draw() {
gasket(0, 50, 500, 7);
}
@sasaki-shigeo
sasaki-shigeo / koch.pde
Created January 20, 2020 00:35
Koch curve
void setup() {
size(500, 500);
noLoop();
}
void draw() {
translate(0, 300);
koch(500, 5);
}
@sasaki-shigeo
sasaki-shigeo / spline.pde
Created January 20, 2020 03:15
Spline curve drawer
ArrayList<PVector> points = new ArrayList<PVector>();
void setup() {
size(600, 600);
}
void mouseClicked() {
PVector p = new PVector(mouseX, mouseY);
points.add(p);
@sasaki-shigeo
sasaki-shigeo / carpet.pde
Created January 21, 2020 00:59
Sierpinski's carpet
void setup() {
size(500, 500);
fill(0);
noLoop();
}
void draw() {
fill(0, 128, 0);
noStroke();
carpet(0, 0, 500, 500, 4);
@sasaki-shigeo
sasaki-shigeo / atoi.c
Created January 22, 2020 05:40
Enhanced atoi function
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
int e_atoi(char *str) {
enum { ST_START, ST_ZERO, ST_DEC, ST_OCT, ST_X, ST_HEX } state = ST_START;
int result = 0;
for (int c = *(str++); c != '\0'; c = *(str++)) {
switch (state) {
@sasaki-shigeo
sasaki-shigeo / prime-number.scm
Created January 29, 2020 04:08
Functions for prime numbers
(require srfi/1) ; list library
(require srfi/13) ; string library
(require srfi/26) ; cut (function placeholder)
(require srfi/42) ; comprehension
(require srfi/45) ; lazy -- efficient `delay' for tail calls
;;(require rnrs/hashtables-6)
(require srfi/69) ; hash-table
;;;
;;; power modulo: a^n mod m
@sasaki-shigeo
sasaki-shigeo / hilbert.pde
Created February 6, 2020 03:31
Hilbert Curve
float unit = 10;
void setup() {
size(500, 500);
noLoop();
}
void draw() {
translate(10, 10);
hilbert(20, 20, 480, 4);