How do I calculate a four colour gradient?

前端 未结 3 2054
甜味超标
甜味超标 2020-12-13 11:25

If I have four colours (A, B, C & D) on four corners of a square and I want to fill that square with a gradient that blends nicely between the four colours how would I c

3条回答
  •  臣服心动
    2020-12-13 11:26

    1. Determine the distance of point E to each point A,B,C,D
    2. The color for point E will be the combination of Red / Green / Blue. Calculate each color axis as the average of the same color axis for A,B,C,D, ponderating by distance.

      distance_a = sqrt((xa-xe)^2+(ya-ye)^2)

      distance_b = ....

      sum_distances = distance_a + distance_b ...

      red = (red_adistance_a + red_bdistance_b ... ) / sum_distances

      color_E = ColorFromARgb(red,green,blue)

提交回复
热议问题