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

套件詳情v0.1.1+2

gradients

支援 CMYK、HSI、HSL、HSP、HSB、LAB、Oklab、RGB 與 XYZ 顏色空間的 Flutter 線性、徑向與掃掠漸變實作。

近 30 天下載
5
喜歡數
26
Pub 分數
60

安裝套件

flutter pub add gradients

套件介紹

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

該 gradients 套件提供對 Flutter 的線性、徑向和掃掠漸變的增強實作,支援多種色彩空間,包括 CMYK、HSI、HSL、HSP、HSB、LAB、Oklab、RGB 和 XYZ。它讓開發者能夠使用超越標準 RGB 的進階色彩模型,創造豐富且可自訂的漸變效果。適用於需要精確色彩控制的設計導向應用,此套件在不增加執行時開銷的情況下擴展了 Flutter 的原生功能。該程式庫輕量級,並能順暢整合至現有的 Flutter 專案中。

適用情境

  • 使用自定漸變背景創建視覺豐富的UI
  • 使用非RGB色彩空間設計色彩主題介面
  • 在移動應用中實現漸變動畫
  • 使用高級顏色混合功能建構設計工具
  • 透過感知均勻漸變增強可及性

主要特色

  • 支援9種色彩空間,包含LAB與Oklab
  • 用於線性、徑向和掃掠類型的可擴展漸變生成器
  • 與 Flutter 繪畫系統的無縫整合
  • 跨多種色彩模型的精確顏色插值
  • 輕量且無依賴

適合對象

  • UI/UX 設計師建構自訂主題
  • 開發創意或藝術類應用的開發者
  • 需要高級顏色操作的應用程式
  • 專注於視覺美學和品牌建設的項目
  • 注重可存取性的應用程式開發

使用建議

  • 需要理解非RGB色彩空間
  • 可能增加初學者的建構複雜性
  • 有限的平台特定優化
  • 最適合用於對色彩精確度有要求的應用程式
  • 不適用於效能關鍵的渲染迴圈

原始 README

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

gradients

Implementations of Flutter's [LinearGradient], [RadialGradient], and [SweepGradient] with support for the CMYK, HSI, HSL, HSP, HSB, LAB, Oklab, RGB, and XYZ color spaces.

gradients depends on and exposes the flutter_color_models package.

See: flutter_palette, a package for generating color palettes.

Usage

import 'package:gradients/gradients.dart';

The 3 classes in gradients can be used interchangeably with Flutter's [Gradient]s: [LinearGradientPainter], [RadialGradientPainter], and [SweepGradientPainter].

final colors = <Color>[Colors.lime, Colors.pink, Colors.cyan];
final linearGradient = LinearGradientPainter(colors: colors);
final radialGradient = RadialGradientPainter(colors: colors);
final sweepGradient = SweepGradientPainter(colors: colors);

Like [Gradient]s, [GradientPainter]s can be provided to a [BoxDecoration], or the [createShader] method can be used to paint directly to a [Canvas].

final widget = Container(
  decoration: BoxDecoration(
    gradient: LinearGradientPainter(
      colors: <Color>[Colors.lime, Colors.pink, Colors.cyan],
    ),
  ),
);

Color Spaces

By default, [Color]s are interpolated in the RGB color space; A [colorSpace] can be provided to set the color space colors will be interpolated in.

final colors = <Color>[Colors.lime, Colors.pink, Colors.cyan];
final oklabGradient = LinearGradientPainter(
  colorSpace: ColorSpace.oklab,
  colors: colors,
);

Oklab Gradient

Color Models

However, if [ColorModel]s are utilized and no [colorSpace] is provided, the gradient will be interpolated in the color space defined by the starting color within any pair of colors.

final colors = <Color>[
  RgbColor(0, 188, 212),
  HsbColor(35, 100, 100),
  OklabColor(0.9, -0.05, 0.033),
  HspColor(175, 100, 50),
];

// This gradient will be interpolated in the RGB color space,
// then the HSB color space, then the Oklab color space.
final gradient = LinearGradientPainter(colors: colors);

Color Models Example Gradient

If [invert] is set to true, the gradient will be interpolated in the color space defined by the ending color within any pair of colors.

// This gradient will be interpolated in the HSB color space,
// then the Oklab color space, then the HSP color space.
final gradient = LinearGradientPainter(colors: colors, invert: true);

Color Models Inverted Example Gradient

Output

Below is the same set of colors interpolated in each of the supported color spaces.

final colors = <Color>[Colors.lime, Colors.pink, Colors.cyan];
CMYK
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.cmyk);

CMYK Gradient

HSB
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsb);

HSB Gradient

HSI
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsi);

HSI Gradient

HSL
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsl);

HSL Gradient

HSP
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsp);

HSP Gradient

LAB
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.lab);

LAB Gradient

Oklab
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.oklab);

Oklab Gradient

RGB
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.rgb);

RGB Gradient

XYZ
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.xyz);

XYZ Gradient

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。