Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #939

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions art/6SidedDice-OwenO/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
@title: 6-Sided Dice
@author: Owen O
@snapshot: snapshot1.png
*/

// Set the dimensions of the dice
setDocDimensions(100, 100);

// Create a function to draw a circle at a given position
function drawCircle(x, y, radius) {
const steps = 360;
const angleStep = 2 * Math.PI / steps;
const points = [];

for (let i = 0; i < steps; i++) {
const angle = i * angleStep;
points.push([x + radius * Math.cos(angle), y + radius * Math.sin(angle)]);
}

drawLines([points]);
}

// Create a function to draw the dice outline
function drawDiceOutline(thickness) {
const outlinePoints = [[10, 10], [90, 10], [90, 90], [10, 90], [10, 10]];


drawLines([outlinePoints]);
}
drawDiceOutline(1);

// Create a function to draw the dots based on a random number
function drawDots(num) {
const dotSpacing = 20;
switch (num) {
case 1:
drawCircle(50, 50, 5);
break;
case 2:
drawCircle(25, 25, 5);
drawCircle(75, 75, 5);
break;
case 3:
drawCircle(25, 25, 5);
drawCircle(50, 50, 5);
drawCircle(75, 75, 5);
break;
case 4:
drawCircle(25, 25, 5);
drawCircle(75, 25, 5);
drawCircle(25, 75, 5);
drawCircle(75, 75, 5);
break;
case 5:
drawCircle(25, 25, 5);
drawCircle(75, 25, 5);
drawCircle(25, 75, 5);
drawCircle(75, 75, 5);
drawCircle(50, 50, 5);
break;
case 6:
drawCircle(25, 25, 5);
drawCircle(75, 25, 5);
drawCircle(25, 50, 5);
drawCircle(75, 50, 5);
drawCircle(25, 75, 5);
drawCircle(75, 75, 5);
break;
default:
break;
}
}

// Generate a random number between 1 and 6
const randomNumber = Math.floor(Math.random() * 6) + 1;

// Draw the dots based on the random number
drawDots(randomNumber);
Binary file added art/6SidedDice-OwenO/snapshots/snapshot1.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 added art/6SidedDice-OwenO/snapshots/snapshot2.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 added art/6SidedDice-OwenO/snapshots/snapshot3.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 added art/6SidedDice-OwenO/snapshots/snapshot4.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 added art/6SidedDice-OwenO/snapshots/snapshot5.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 added art/6SidedDice-OwenO/snapshots/snapshot6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading