code:p5js:gestaltrule_06
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
code:p5js:gestaltrule_06 [2025/03/20 09:14] – created Felix Hardmood Beck | code:p5js:gestaltrule_06 [2025/03/20 09:19] (current) – Felix Hardmood Beck | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | Im unteren Beispiel wird ein prägnantes Element gezeigt: Ein zufälliger Kreis hebt sich durch Farbe (Rot) und Größe von den anderen ab. Das Ergebniss ist folgender Wahrnehmungseffekt: | ||
+ | |||
+ | |||
< | < | ||
< | < | ||
Line 4: | Line 8: | ||
</ | </ | ||
< | < | ||
+ | <div id=" | ||
< | < | ||
- | function setup() { | + | |
- | createCanvas(600, | + | let canvas = createCanvas(600, |
- | | + | |
- | } | + | |
- | + | } | |
- | function draw() { | + | |
- | background(240); | + | |
- | + | ||
- | let cols = 10; | + | |
- | let rows = 6; | + | |
- | let spacingX = width / (cols + 1); | + | |
- | let spacingY = height / (rows + 1); | + | |
- | let specialIndex = int(random(cols * rows)); // Ein zufällig abweichendes Objekt | + | |
- | + | ||
- | let count = 0; | + | |
- | for (let i = 0; i < cols; i++) { | + | |
- | for (let j = 0; j < rows; j++) { | + | |
- | let x = (i + 1) * spacingX; | + | |
- | let y = (j + 1) * spacingY; | + | |
- | + | ||
- | if (count === specialIndex) { | + | |
- | | + | |
- | ellipse(x, y, 40); | + | |
- | } else { | + | |
- | fill(100); | + | |
- | ellipse(x, y, 30); | + | |
- | } | + | |
- | count++; | + | |
- | } | + | |
- | } | + | |
- | } | + | |
+ | function draw() { | ||
+ | background(240); | ||
+ | | ||
+ | let cols = 10; | ||
+ | let rows = 6; | ||
+ | let spacingX = width / (cols + 1); | ||
+ | let spacingY = height / (rows + 1); | ||
+ | let specialIndex = int(random(cols * rows)); // Ein zufällig abweichendes Objekt | ||
+ | | ||
+ | let count = 0; | ||
+ | for (let i = 0; i < cols; i++) { | ||
+ | for (let j = 0; j < rows; j++) { | ||
+ | let x = (i + 1) * spacingX; | ||
+ | let y = (j + 1) * spacingY; | ||
+ | | ||
+ | if (count === specialIndex) { | ||
+ | fill(255, 0, 0); // Hebt sich in Farbe ab (prägnantes Element) | ||
+ | ellipse(x, y, 40); | ||
+ | } else { | ||
+ | fill(100); | ||
+ | ellipse(x, y, 30); | ||
+ | } | ||
+ | count++; | ||
+ | } | ||
+ | } | ||
+ | } | ||
</ | </ | ||
- | <div id=" | ||
</ | </ | ||
</ | </ | ||
Line 76: | Line 80: | ||
} | } | ||
} | } | ||
+ | |||
</ | </ | ||
+ | |||
/var/www/vhosts/ct-lab.info/wiki.ct-lab.info/data/attic/code/p5js/gestaltrule_06.1742462042.txt.gz · Last modified: 2025/03/20 09:14 by Felix Hardmood Beck