Skip to content

循环方案

¥Cyclical schemes

要使用 彩虹 配色方案创建循环连续色阶:

¥To create a cyclical continuous color scale using the Rainbow color scheme:

js
const color = d3.scaleSequential(d3.interpolateRainbow);

interpolateRainbow(t)

源代码 · 给定一个 [0,1] 范围内的数值 t,返回 d3.interpolateWarm 中对应颜色,其比例范围为 [0.0, 0.5],然后是 d3.interpolateCool 中比例范围为 [0.5, 1.0],从而实现循环的 柔和彩虹 配色方案。

¥Source · Given a number t in the range [0,1], returns the corresponding color from d3.interpolateWarm scale from [0.0, 0.5] followed by the d3.interpolateCool scale from [0.5, 1.0], thus implementing the cyclical less-angry rainbow color scheme.

interpolateSinebow(t)

源代码 · 给定一个 [0,1] 范围内的数值 t,返回 Jim BumgardnerCharlie Loyd 设计的“sinebow”配色方案中对应的颜色。

¥Source · Given a number t in the range [0,1], returns the corresponding color from the “sinebow” color scheme by Jim Bumgardner and Charlie Loyd.