-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraster.js
40 lines (31 loc) · 1023 Bytes
/
raster.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* set width and height of single raster field */
var FIELD = 50;
/* set margin between fields of raster */
var MARGIN = 10;
function createRaster() {
background(0);
/* move raster into the center of the canvas */
var origin_x = ((width - (FIELD + MARGIN)) % (FIELD + MARGIN)) / 2;
var origin_y = ((height - (FIELD + MARGIN)) % (FIELD + MARGIN)) / 2;
/* create raster with margin between fields */
for ( var y = origin_y; y < height - FIELD; y += FIELD + MARGIN ) {
for ( var x = origin_x; x < width - FIELD; x += FIELD + MARGIN ) {
// Do something, eg.
// ellipseMode(CORNER);
// fill(random(255));
// ellipse(x, y, FIELD, FIELD);
}
}
}
function setup() {
createCanvas(document.documentElement.clientWidth, document.documentElement.clientHeight);
noStroke(); // if there is a stroke of 1px, the margin looses 1px
createRaster();
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
createRaster();
}
function draw() {
//background(255);
}