Shinyoung: Unterschied zwischen den Versionen
Aus exmediawiki
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 32: | Zeile 32: | ||
--------- | --------- | ||
<big><big>'''26.05 Seminar'''</big></big> | |||
<br> | |||
https://editor.p5js.org/shinyoung.rhyu/full/gdngY43px | |||
//var otherWay = 0; | //var otherWay = 0; | ||
Version vom 26. Mai 2025, 14:30 Uhr
12.05
Create a repeating infinite number of squares :
https://editor.p5js.org/shinyoung.rhyu/full/FDZkUXra8p
Drawing a book cover using rules :

19.05 homework
Drawings :

Code examples based on drawings : https://editor.p5js.org/shinyoung.rhyu/full/5MOgdiwjF
26.05 homework
loop code:
https://editor.p5js.org/shinyoung.rhyu/full/gdngY43px
homework:

26.05 Seminar
https://editor.p5js.org/shinyoung.rhyu/full/gdngY43px
//var otherWay = 0;
function setup() {
createCanvas(600, 600); //noLoop(); frameRate(2); noFill();
}
function draw() {
background(220);
let LimitA = 4;
let LimitB = 4;
for(let a = 0; a < LimitA; a= a+1){
for(let b = 0; b < LimitB; b= b+1){
drawSquare(a*0.25*width , b*0.25*height , height*0.25 , height*0.25 , a+b*LimitA);
// 맨 마지막의 a+b*LimitA 는 a와 b가 0으로부터 시작하기 때문에, 두 수를 더한 다음 곱해야 우리가 원하는 4*4 = 16 개의 숫자가 생성됨 //A와 B를 1보다 크다고 조건문을 작성하면 두 수를 곱하는 것으로도 충분해지지만, 이 경우 컨버스의 0 자리가 없어지기 때문에 전체 모양이 오른쪽으로 이동하게 되고, 4의 배수들은 화면에 보이지 않게 된다. }
}
}
function drawSquare(_X, _Y, _tileWidth, _tileHeight, _num){
let tileWidth = _tileWidth;
let tileHeight = _tileHeight;
let minRectwidth = 10;
let minRectHeight = 15;
let amountOFSquares = 20;
let X = tileWidth / 2 + _X
let Y = tileHeight /2 + _Y
let num = _num;
rectMode(CENTER);
noFill();
for (let i = 0; i <amountOFSquares; i++) { //i가 10을 넘지 않음, i++는 i가 점진적으로 1씩 더해지는 구조, 이것이 도달하여 10을 넘을 경우 다시 뒤로 돌아가는 조건문
let rectWidth = random(minRectwidth, tileWidth);
let rectheight = random(minRectHeight, tileHeight);
rect(X, Y, rectWidth, rectheight)
}
fill(255,0,0);
text(num,X, Y );
}