FLUTTER ECOSYSTEM

ilikerobots/rainbow_color

Flutter用のカラーリンタープォレーション;数値ドメインをスムーズな遷移色範囲にマッピングします。

rainbow_color のプロジェクト画像
Stars
12
Forks
1
最終プッシュ(UTC)
2021/03/04
プロジェクト状態
公開中
Mike Hoolehan GitHub avatar
GITHUB User

Mike Hoolehan ↗

Camper, baseball player, traveler; a long way from Terre Haute.

Tallinn, Estonia公式サイト ↗
言語DartSwiftKotlinObjective-C

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 3 件
  • rainbow_vis^2.0.0
  • flutter{"sdk":"flutter"}
  • flutter_test開発用{"sdk":"flutter"}

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

rainbow_color

Pub Travis

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.

https://github.com/ilikerobots/rainbow_color/raw/master/doc/assets/rainbow_color_example.gif

Usage

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(() {}); 
                                                    });
}

See Also

This is a Flutter-oriented version of the vanilla Dart package rainbow_vis.