xxxxxxxxxx
let centerX, centerY;
let numberOfLines = 200; // Çizgi sayısı
function setup() {
createCanvas(400, 600);
centerX = width / 2;
centerY = height / 2;
background(255);
stroke(0); // Siyah çizgi
strokeWeight(0.5); // Daha ince çizgiler için çizgi kalınlığı
drawRandomLines(); // Başlangıçta rastgele çizgileri çiz
noFill();
strokeWeight(2); // Çerçeve çizgi kalınlığı
rect(10, 10, width - 20, height - 20); // Çerçeve
}
// Rastgele çizgiler çizen fonksiyon
function drawRandomLines() {
background(255); // Her çizim öncesi arkaplanı temizle
strokeWeight(0.5); // Çizgi kalınlığını düşürdük
for (let i = 0; i < numberOfLines; i++) {
let angle = random(TWO_PI); // Rastgele açı
let lineLength = random(50, 300); // 50-300 arası Rastgele uzunluk
let xEnd = centerX + cos(angle) * lineLength;
let yEnd = centerY + sin(angle) * lineLength;
line(centerX, centerY, xEnd, yEnd);
}
// Çerçeve yeniden çiziliyor
noFill();
strokeWeight(2);
rect(10, 10, width - 20, height - 20);
}
function keyPressed() {
if (key == 'r') {
drawRandomLines(); // R tuşuna basınca çizgileri yeniden çiz
}
if (key == 's') {
saveCanvas('randomness', 'png'); // Netliği artırmak için PNG olarak kaydediyoruz
}
}