Pentagram Snowflake
Pentagram Snowflake
Pentagram Snowflake
DOCTYPE html>
<html>
<head>
<title>Pentagram snowflake</title>
<script>
function generateRandomNumbers() {
// Create a list of the numbers to choose from
var numbers = [1, 2, 3, 4, 5];
// Initialize variables
var previousVertex = null;
var previousMidpoint = null;
var results = [];
// Repeat the process 1000000 times, with a delay of 1ms between each dot
var interval = setInterval(function() {
if (dotCounter >= 100000) {
clearInterval(interval);
// Display the results on the webpage
var resultsElement = document.getElementById('results');
resultsElement.textContent = results.join(', ');
} else {
// Remove the previous number from the list of choices
var choices = numbers.filter(function(n) { return n !==
previousVertex; });
// Choose a random number from the remaining choices
var vertexNumber = choices[Math.floor(Math.random() * choices.length)];
// Add the chosen number to the results
results.push(vertexNumber);
// Calculate the midpoint between the previous midpoint and the current
vertex
if (previousMidpoint) {
var midX = (previousMidpoint.x + vertex.x) / 2;
var midY = (previousMidpoint.y + vertex.y) / 2;
// Set the midpoint as the previous midpoint for the next iteration
previousMidpoint = { x: midX, y: midY };
} else {
// If this is the first midpoint, calculate it as the midpoint between
the first vertex and the current vertex
var midX = (getVertex(1, canvas.width, canvas.height).x + vertex.x) /
2;
var midY = (getVertex(1, canvas.width, canvas.height).y + vertex.y) /
2;
// Set the midpoint as the previous midpoint for the next iteration
previousMidpoint = { x: midX, y: midY };
}
// Set the chosen number as the previous number for the next iteration
previousVertex = vertexNumber;