v2.0.1rainbow_color
简化多色插值。将数值域映射到平滑过渡的颜色范围。
Flutter 的颜色插值;将数值范围映射到平滑过渡的颜色范围。
^2.0.0{"sdk":"flutter"}{"sdk":"flutter"}以下为英文项目原文快照,最新内容请访问 GitHub。
RainbowColor simplifies interpolation a numerical domain onto a multi-color range. RainbowColor accepts a numerical domain
(i.e. a start and end number) and a spectrum of two or more colors, and offers the list access operator ([]) for
interpolation.
This package also provides RainbowColorTween, a multi-color variant of the standard ColorTween, eliminating the need
to build more complex TweenSequence for equal-weight transitions.
To interpolate a color among the spectrum, use the list access operator, e.g.
import 'package:rainbow_color/rainbow_color.dart';
var rb = Rainbow(spectrum: [Color(0xFFFF0000), Color(0xFFFFFFFF), Color(0xff00ff00)],
rangeStart: -10,
rangeEnd: 10);
Color warmColor = rb[-9.32];
Color coldColor = rb[8.44];
Or use RainbowColorTween in place of ColorTween to interpolate among multiple colors instead of two.
@override
void initState() {
super.initState();
_controller = AnimationController(duration: widget.duration, vsync: this);
_clAnim = RainbowColorTween([Color(0x33FFAAAA),
Color(0x33000000),
Color(0x00000000)]).animate(_controller)
..addListener(() {
setState(() {});
});
}
This is a Flutter-oriented version of the vanilla Dart package rainbow_vis.