Skip to content

Commit

Permalink
JAN19
Browse files Browse the repository at this point in the history
  • Loading branch information
ronikaufman committed Jan 19, 2023
1 parent 7ec382e commit 5e8c056
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
Binary file added JAN11-20/JAN19/JAN19_1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added JAN11-20/JAN19/JAN19_2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions JAN11-20/JAN19/sketch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Genuary 2023
JAN.18 "A grid inside a grid inside a grid"
By Roni Kaufman
https://ronikaufman.github.io
*/

const N_FRAMES = 120;
let s = 16, n = 48;
let myFont;
let balls = [], nBalls = 15;
let v0;

function preload() {
myFont = loadFont("./fonts/VictorMono-Medium.ttf");
}

function setup() {
createCanvas(n*s, n*s);
noStroke();
textSize(s*1.1);
textAlign(LEFT, TOP);
textFont(myFont);
fill("#fffbe6");

for (let i = 0; i < nBalls; i++) {
let sp = random(5, 10);
let t0 = random(TAU);
let r = random(20, 25);
balls.push(new Ball(width/2, height/2, sp, t0, r));
}
v0 = createVector(width/2, height/2);
}

function draw() {
background("#050505");

let charset = "@%#*+=-:·:-=+*#%@";

let t = TAU*(frameCount%N_FRAMES)/N_FRAMES;
for (let x = 0; x < width; x += s) {
for (let y = 0; y < height; y += s) {
let v = createVector(x+s/2, y+s/2);
let sum = 0;
for (let b of balls) {
let d = v.dist(b.pos);
sum += b.r/d;
}
let charIdx = constrain(~~(sum*charset.length), 0, 2*charset.length)%charset.length;
text(charset[charIdx], x, y);
}
}

for (let b of balls) b.update(t);
}

function Ball(x, y, sp, t0, r) {
this.pos = createVector(x, y);
this.theta = random(TAU);
this.sp = sp;
this.t0 = t0
this.r = r;

this.update = function(t) {
this.vel = p5.Vector.fromAngle(this.theta, sin(this.t0 + t)*this.sp);
this.pos.add(this.vel);
}
}

function keyPressed() {
if (key === 's') {
saveGif("JAN19.gif", N_FRAMES, {delay: 0, units: "frames"});
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Reference: ["Wanderer (rotations)" on the Tilings Encyclopedia](https://tilings.
### JAN. 19
> Black and white
<img src="./JAN11-20/JAN19/JAN19_1.gif" width="40%"/> <img src="./JAN11-20/JAN19/JAN19_2.gif" width="40%"/>

### JAN. 20
> Art Deco
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<script src="./p5.min.js" type="text/javascript"></script>
<script src="JAN11-20/JAN18/sketch.js" type="text/javascript"></script>
<script src="JAN11-20/JAN19/sketch.js" type="text/javascript"></script>
</head>
<body style = "width: 100%; height: 100%; background-color: 0; margin: 0; display: flex; justify-content: center; align-items: center;">
</body>
Expand Down

0 comments on commit 5e8c056

Please sign in to comment.