# How I Built a Mouse-Responsive Gradient Using Just CSS and Math

DevFeed: [How I Built a Mouse-Responsive Gradient Using Just CSS and Math](<https://devfeed.tech/articles/how-i-built-a-mouse-responsive-gradient-using-just-css-and-math-130187.md>)

Original publisher: [Read original article](<https://hackernoon.com/how-i-built-a-mouse-responsive-gradient-using-just-css-and-math?source=rss>)

Author: sammii

Published: 2026-11-12T07:04:16Z

Content type: article

Language: en

Sources: [HackerNoon](<https://devfeed.tech/sources/hackernoon.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [web animation](<https://devfeed.tech/topics/web-animation.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [web graphics](<https://devfeed.tech/topics/web-graphics.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [accelerometer](<https://devfeed.tech/tags/accelerometer.md>), [animation](<https://devfeed.tech/tags/animation.md>), [api](<https://devfeed.tech/tags/api.md>), [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [background](<https://devfeed.tech/tags/background.md>), [browser](<https://devfeed.tech/tags/browser.md>), [canvas](<https://devfeed.tech/tags/canvas.md>), [change](<https://devfeed.tech/tags/change.md>), [color](<https://devfeed.tech/tags/color.md>), [css](<https://devfeed.tech/tags/css.md>), [css-animation](<https://devfeed.tech/tags/css-animation.md>), [data-science](<https://devfeed.tech/tags/data-science.md>), [game-development](<https://devfeed.tech/tags/game-development.md>), [gradient](<https://devfeed.tech/tags/gradient.md>), [investing](<https://devfeed.tech/tags/investing.md>), [logo](<https://devfeed.tech/tags/logo.md>), [masks](<https://devfeed.tech/tags/masks.md>), [math](<https://devfeed.tech/tags/math.md>), [mouse](<https://devfeed.tech/tags/mouse.md>), [mouse-driven-animation](<https://devfeed.tech/tags/mouse-driven-animation.md>), [portfolio](<https://devfeed.tech/tags/portfolio.md>), [responsive](<https://devfeed.tech/tags/responsive.md>), [rgb-color-manipulation](<https://devfeed.tech/tags/rgb-color-manipulation.md>), [tracking](<https://devfeed.tech/tags/tracking.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

## AI overview

The portfolio logo's colors are generated by a TypeScript function that maps cursor percentages to RGB values, rotates those values across three radial gradients, and uses a CSS mask to show the gradient through text. Scrolling supplies different sine and cosine wave values to the same function; linear interpolation at 20% per animation frame smooths the changing inputs. When scrolling and pointer movement overlap, scrolling takes priority until 500 ms after the last scroll event, then mouse control resumes. The described effect uses CSS gradients, masking, and arithmetic without an animation library, canvas, or WebGL.

## Source excerpt

Build a color-changing portfolio logo using CSS masks, radial gradients, TypeScript, and mouse-tracking techniques.