搜尋套件、儲存庫與 APP 分類

套件詳情v3.0.0

color

一個簡單的 Dart 套件,公開了一個 Color 類別,可用於在多種色彩空間中建立、轉換、修改和比較顏色。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
82.9萬
喜歡數
36
Pub 分數
130

安裝套件

flutter pub add color

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

color 套件是一個輕量級的 Dart 庫,提供一個完整的 Color 類,用於在多個色彩空間中建立、操作和比較顏色。它支援顏色轉換、混合和比較等運算,非常適合需要精確顏色處理的應用程式。設計上簡潔且效能優異,可無縫整合至所有主要平台上的 Flutter 專案。此套件在設計工具、主題系統和視覺應用中特別實用,這些情境下準確的顏色管理至關重要。

適用情境

  • 主題自定義
  • 配色方案生成
  • 視覺設計工具
  • 圖像處理
  • UI 原型設計
  • 跨平台顏色一致性

主要特色

  • 支援多種色彩空間
  • 顏色轉換工具
  • 顏色比較方法
  • 易於使用的 API
  • Platform-agnostic
  • 可擴展的顏色操作

適合對象

  • Flutter 開發者
  • 設計系統創建者
  • UI/UX 設計師
  • 顏色敏感的應用程式
  • 跨平台應用
  • 原型設計工具

使用建議

  • 僅限基本顏色操作
  • 無內建色彩選擇器 UI
  • 需要手動管理色彩空間
  • 未針對複雜圖像分析進行優化
  • 除了程式碼註釋外,文件極少
  • 無執行時間顏色驗證

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Color

A simple Dart package exposing a Color class which can be used to create, convert, and compare colors.

Installation

  1. Add this to your package's pubspec.yaml file:
dependencies:
  color: any
  1. Get the package using your IDE's GUI or via command line with
$ pub get
  1. Import the color.dart file in your app
import 'package:color/color.dart';

Usage

Color objects can be constructed using any of a few available constructors.

To create a color from rgb values, call

Color rgbColor = new Color.rgb(192, 255, 238);
RgbColor rgbColor = new RgbColor(192, 255, 238);

Alternatively, a color can be created directly in a number of other color spaces.

RgbColor rgb = new RgbColor(192, 255, 238);
HexColor hex = new HexColor('c0ffee');
HslColor hsl = new HslColor(163.8, 100, 87.6);
XyzColor xyz = new XyzColor(72.931, 88.9, 94.204);
CielabColor cielab = new CielabColor(95.538, -23.02, 1.732);

Colors are immutable, and can be created using const constructors.

RgbColor rgb = const RgbColor(192, 255, 238);

Colors can be created directly from CSS3 color names.

RgbColor black = new RgbColor.name('black'); //factory constructor that returns a const RgbColor
RgbColor white = RgbColor.namedColors['black']; //directly reference the const RgbColor without the factory

Colors implementing the CssColorSpace interface can output a css string representation.

RgbColor rgb = new RgbColor(192, 255, 238);
HexColor hex = new HexColor('c0ffee');
HslColor hsl = new HslColor(163.8, 100, 87.6);
assert(rgb is CssColorSpace, true);
assert(hex is CssColorSpace, true);
assert(hsl is CssColorSpace, true);
print(rgb.toCssString()); //rgb(192, 255, 238)
print(hex.toCssString()); //#c0ffee
print(hsl.toCssString()); //hsl(163.8, 100.0%, 87.6%)

Colors can be compared using the == operator, which will evaluate to true if the two colors share identical rgb values after being rounded to integers.

assert(new Color.hex('c0ffee') == new Color.hex('c0ffee'));
assert(new Color.rgb('192, 255, 238') == new Color.hex('c0ffee'));

Colors can be converted from one color space to another by calling the appropriate toXXXColor method on them.

HslColor hsl = new RgbColor(192, 255, 238).toHslColor();

Colors can be altered using a ColorFilter, which will return a new color in the same color space as the input color with that filter applied to it.

RgbColor grey = ColorFilter.greyscale(new RgbColor(192, 255, 238));
HslColor sepia = ColorFilter.sepia(new HslColor(163.8, 100, 87.6));

所屬分類

原始碼儲存庫

使用此套件的專案