A Pen by Monica.dev on CodePen.
Created
February 4, 2025 15:14
-
-
Save M0nica/f6c21096b9061b794b0f9fea3f438278 to your computer and use it in GitHub Desktop.
Genuary Day 1 - Vertical or horizontal lines only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() { | |
createCanvas(windowWidth, windowHeight); | |
noStroke(); | |
frameRate(10); | |
} | |
function draw() { | |
clear(); | |
let from = color("#ba1e58"); | |
let to = color("#b4aaff"); | |
background(to); | |
let stripes = frameCount % 50 || 1; | |
for (let x = 0; x < height; x += height / stripes - 1) { | |
fill(lerpColor(from, to, x / height)); | |
rect(0, x, width, height / stripes); | |
} | |
} | |
function keyPressed() { | |
const SPACEBAR = " "; | |
// pause/play animation when spacebar is pressed for sketches that animate from draw to draw | |
if (key == SPACEBAR) { | |
isLooping() ? noLoop() : loop(); | |
} | |
if (key === "g") { | |
saveGif("canvas", 15); | |
} | |
if (key === "s") { | |
saveCanvas("canvas"); | |
} | |
} | |
function windowResized() { | |
resizeCanvas(windowWidth, windowHeight); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas { | |
/* center canvas in middle of page */ | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
transform: translate(-50%, -50%); | |
height: 50%; | |
text-align: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment