Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
souptik-samanta authored Jan 4, 2025
1 parent f161d2e commit b78d176
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
88 changes: 87 additions & 1 deletion art/SouptikWave/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ function degreesToRadians(angleInDegrees) {

// Function to check if a point is within canvas bounds
function isWithinBounds(x, y) {

return x >= 0 && x <= canvasWidth && y >= 0 && y <= canvasHeight;
}

// Function to check if a point is outside the clock area
function isOutsideClock(x, y) {

const dx = x - clockCenterX;
const dy = y - clockCenterY;
return Math.sqrt(dx * dx + dy * dy) > clockRadius;
Expand All @@ -51,22 +53,30 @@ function isOutsideClock(x, y) {
function safeMoveToForScenery(turtle, x, y) {
if (isWithinBounds(x, y) && isOutsideClock(x, y)) {
turtle.goTo([x, y]);


}


}


// Draw the clock ofc
for (let angle = 0; angle < degreesToRadians(360); angle += 0.01) {
const x = Math.cos(angle) * clockRadius;
const y = Math.sin(angle) * clockRadius;
turtle.goTo([x, y]);


}

turtle.up();

for (let angle = 0; angle <= degreesToRadians(361); angle += degreesToRadians(360) / 12) {
let x = Math.cos(angle) * (clockRadius - markerOffset);
let y = Math.sin(angle) * (clockRadius - markerOffset);
turtle.goTo([x, y]);


turtle.down();
x = Math.cos(angle) * (clockRadius - (markerOffset + markerLength));
Expand All @@ -76,6 +86,8 @@ for (let angle = 0; angle <= degreesToRadians(361); angle += degreesToRadians(36
x = Math.cos(angle) * (clockRadius - markerOffset);
y = Math.sin(angle) * (clockRadius - markerOffset);
turtle.goTo([x, y]);



turtle.up();
}
Expand Down Expand Up @@ -166,6 +178,7 @@ safeMoveToForScenery(painter, mountainX, mountainY);
painter.down();
const totalMountains = Math.floor(randomRange(2, 5));


for (let mountain = 0; mountain < totalMountains; mountain++) {
mountainX = (canvasWidth / totalMountains) * mountain;

Expand Down Expand Up @@ -194,8 +207,81 @@ for (let mountain = 0; mountain < totalMountains; mountain++) {
mountainY += randomRange(-3, 1);
safeMoveToForScenery(painter, mountainX, mountainY);
}


function drawBirds(count, regionCenterX, regionCenterY, regionRadius) {
const birdLines = [];
const birdTurtle = new bt.Turtle();
const existingBirds = [];


for (let i = 0; i < count; i++) {
let birdX, birdY;
let isValidPosition;



do {
isValidPosition = true;
const angle = Math.random() * 2 * Math.PI;
const radius = Math.random() * regionRadius;
birdX = regionCenterX + radius * Math.cos(angle);
birdY = regionCenterY + radius * Math.sin(angle);



if (!isWithinBounds(birdX, birdY) || !isOutsideClock(birdX, birdY)) {
isValidPosition = false;
continue;
}



for (const [existingX, existingY] of existingBirds) {
const distance = Math.sqrt(
Math.pow(birdX - existingX, 2) + Math.pow(birdY - existingY, 2)
);
if (distance < 8) { // Minimum distance to avoid overlap
isValidPosition = false;
break;
}
}
} while (!isValidPosition);


existingBirds.push([birdX, birdY]);

const birdSize = Math.random() * 5 + 2;




birdTurtle.up();
birdTurtle.goTo([birdX, birdY]);
birdTurtle.down();
birdTurtle.goTo([birdX - birdSize, birdY - birdSize / 2]);
birdTurtle.goTo([birdX + birdSize, birdY - birdSize / 2]);
}

bt.join(birdLines, birdTurtle.lines());
drawLines(birdLines);
}



const regionCenterX = 30;

const regionCenterY = 80;

const regionRadius = 25;


drawBirds(1, regionCenterX, regionCenterY, regionRadius);

}

bt.join(sceneElements, painter.lines());
bt.join(sceneElements, painter.lines() );

drawLines(sceneElements);
drawLines(clockLines);

Binary file modified art/SouptikWave/snapshots/img1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified art/SouptikWave/snapshots/img2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified art/SouptikWave/snapshots/img3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b78d176

Please sign in to comment.