xxxxxxxxxx
100
// CT Principles
// Decomposition: Köpeği baş, kulaklar, gözler, burun, gövde, bacaklar ve kuyruk olarak parçalara böldük.
// Pattern Recognition: Tekrarlayan bileşenler için (kulaklar, bacaklar, gözler) array kullanıdık.
// Abstraction: Köpeğin temel hatlarını belirleyerek detayları azaltıp sadelik sağladık.
// Algorithms: Rastgele değerler belirleyerek her çalıştırmada farklı bir köpek oluşturduk.
function setup() {
createCanvas(400, 400);
noLoop();
}
function draw() {
background(255);
// RENK DEĞERLERİ
let furColors = [
[180, 120, 80], // Kahverengi
[200, 150, 100], // Açık kahverengi
[220, 180, 140], // Krem
[150, 100, 60] // Koyu kahverengi
];
let colors = {
body: random(furColors),
ear: random(furColors),
head: random(furColors),
tail: random(furColors) // Kuyruk için ayrı bir renk seçimi
};
// VÜCUT DEĞERLERİ
let vucut = {
bodyWidth: random(100, 140),
bodyHeight: random(80, 100),
earLength: random(50, 70),
headSize: random(60, 80),
tailWidth: random(15, 25), // Kuyruk genişliği
tailHeight: random(30, 50) // Kuyruk yüksekliği
};
let centerX = width / 2;
let centerY = height / 2;
// GÖVDE
fill(colors.body);
ellipse(centerX, centerY, vucut.bodyWidth, vucut.bodyHeight);
// BAŞ
fill(colors.head);
ellipse(centerX, centerY - vucut.bodyHeight / 2, vucut.headSize, vucut.headSize);
// KULAKLAR
let ears = [
{ x: centerX - vucut.headSize / 2, y: centerY - vucut.bodyHeight / 2 + 10 },
{ x: centerX + vucut.headSize / 2, y: centerY - vucut.bodyHeight / 2 + 10 }
];
fill(colors.ear);
for (let ear of ears) {
ellipse(ear.x, ear.y, 30, vucut.earLength);
}
// GÖZLER
let eyes = [
{ x: centerX - 15, y: centerY - vucut.bodyHeight / 2 - 5 },
{ x: centerX + 15, y: centerY - vucut.bodyHeight / 2 - 5 }
];
fill(0);
for (let eye of eyes) {
ellipse(eye.x, eye.y, 8, 8);
}
// BURUN
fill(50);
ellipse(centerX, centerY - vucut.bodyHeight / 2 + 10, 10, 8);
// KUYRUK
fill(colors.tail);
rect(centerX + vucut.bodyWidth / 2 - 5, centerY - 10, vucut.tailWidth, vucut.tailHeight);
// BACAKLAR
let legs = [
{ x: centerX - 30, y: centerY + vucut.bodyHeight / 2 - 5 },
{ x: centerX + 15, y: centerY + vucut.bodyHeight / 2 - 5 }
];
fill(colors.body);
for (let leg of legs) {
rect(leg.x, leg.y, 15, 30);
}
}
function keyPressed() {
// R tuşuna basıldığında yeniden çizim yap
if (key === 'r' || key === 'R') {
redraw();
}
}