相关疑难解决方法(0)

Is this possible to create 2-axis 4 color gradient in css (bilinear gradient)?

My exmaple in JavaScript and <canvas>. https://codepen.io/KonradLinkowski/pen/QWbjaPr

const canvas = document.querySelector('#box')
const ctx = canvas.getContext('2d')

const interpolate = (value, start, end) => (end - start) * value + start

const interpolateRGB = (value, start, end) => {
  return {
    r: interpolate(value, start.r, end.r),
    g: interpolate(value, start.g, end.g),
    b: interpolate(value, start.b, end.b)
   }
}

const calcColor = (point, topLeft, topRight, bottomLeft, bottomRight) => {
  const top = interpolateRGB(point.x, topLeft, topRight)
  const bottom = interpolateRGB(point.x, bottomLeft, bottomRight)
  const result = interpolateRGB(point.y, …
Run Code Online (Sandbox Code Playgroud)

css linear-gradients background-color css-gradients bilinear-interpolation

5
推荐指数
2
解决办法
1663
查看次数