This repository has been archived on 2022-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
GeometryDash3D/js/utils.js
2022-11-22 10:41:38 +01:00

18 lines
502 B
JavaScript

export const textureGradient = (width, height, color1, color2) => {
const cnv = document.createElement("canvas");
const ctx = cnv.getContext("2d");
ctx.rect(0, 0, cnv.width, cnv.height);
const gradient = ctx.createLinearGradient(0, 0, width / 4, 15 * height);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
ctx.fillStyle = gradient;
ctx.fill();
const texture = new THREE.Texture(cnv);
texture.needsUpdate = true;
return texture;
};