Skip to content

Commit

Permalink
Refactroring gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
andwin committed Feb 17, 2024
1 parent 03b099f commit acfca35
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/rektron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ const createBackground = () => {
const color2 = color('#1A1423')

const bg = createGraphics(width, height)
const ctx = bg.canvas.getContext('2d')

bg.noFill()
for (let i = 0; i <= height; i++) {
const inter = map(i, 0, height, 0, 1)
const c = lerpColor(color1, color2, inter)
bg.stroke(c)
bg.line(0, i, width, i)
}
const gradient = ctx.createRadialGradient(width / 2, height / 2, height / 2, width / 2, height / 2, 100)

gradient.addColorStop(0, color1)
gradient.addColorStop(1, color2)

ctx.fillStyle = gradient
bg.rect(0, 0, width, height)
return bg
}

0 comments on commit acfca35

Please sign in to comment.