Skip to content

Commit

Permalink
fix: make generator more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Apr 1, 2024
1 parent a742152 commit 73848c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sample-generator/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ document.addEventListener('DOMContentLoaded', () => {

function initialize() {
canvas = document.getElementById('my-canvas');
$objkt.rnd(null);
window.addEventListener('resize', () => draw(), false);
draw();
}

function draw(width = window.innerWidth, height = window.innerHeight) {
$objkt.rnd(null);
const ratio = width / height;

canvas.width = width;
canvas.height = height;

Expand All @@ -30,7 +32,6 @@ function draw(width = window.innerWidth, height = window.innerHeight) {
ctx.save();

const ellipseWidth = $objkt.rnd() * 4 + 3;
const ellipseHeight = $objkt.rnd() * 6 + 3;

$objkt.registerFeatures({
background: colorFeatures(colors.bgFill),
Expand All @@ -41,7 +42,7 @@ function draw(width = window.innerWidth, height = window.innerHeight) {
width / 2,
height / 2,
width / ellipseWidth,
height / ellipseHeight,
ratio * 20,
Math.PI / (($objkt.seed % 2) + 1) / 2,
0,
2 * Math.PI
Expand Down

0 comments on commit 73848c5

Please sign in to comment.