패키지, 저장소 및 앱 카테고리 검색

hsluv 표지
패키지 상세v1.1.3

hsluv

인간 실험을 기반으로 한 인간 친화적인 HSL의 대안인 HSLuv의 Dart 포트.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2.5천
좋아요
11
Pub 점수
140

패키지 설치

flutter pub add hsluv

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

HSLuv는 전통적인 HSL의 더 직관적이고 인지적으로 균일한 대안으로 설계된 HSLuv 색 공간의 Dart 구현입니다. 인간 시각 실험을 기반으로 하여 다양한 색조에서 일관된 밝기와 채도를 보장함으로써 색상 선택을 향상시킵니다. 이 패키지는 개발자가 RGB와 HSLuv 색 모델 간에 정확하고 인간 중심의 결과로 변환할 수 있도록 해줍니다. 접근성과 시각적 균형이 중요한 디자인 도구, UI 프레임워크, 접근성 중심 앱과 같은 응용 프로그램에 이상적입니다.

사용 사례

  • 접근성 있는 색상 팔레트 만들기
  • 지각적 일관성을 갖춘 사용자 인터페이스 설계
  • 개선된 색조 분포를 갖춘 컬러 피커 구현
  • 접근성 기능에서 색 대비 향상
  • 조화로운 색상 테마 생성

주요 기능

  • 인지적으로 균일한 색 전환
  • 밝기와 채도 일관성 향상
  • 실험을 기반으로 한 인간 중심 색상 모델
  • 양방향 RGB ↔ HSLuv 변환
  • 모든 주요 플랫폼을 지원합니다

적합한 대상

  • 더 나은 색상 정확도를 원하는 UI/UX 디자이너
  • 색상 선택 도구를 개발하는 개발자
  • 접근성과 시각적 명확성에 중점을 둔 앱
  • 크리에이티브 코딩 및 생성 예술 프로젝트
  • 일관된 색상 렌더링이 필요한 크로스플랫폼 애플리케이션

고려 사항

  • HSL에 익숙한 사람들에게는 학습 곡선이 필요할 수 있습니다
  • 표준 색상 모델에 비해 문서가 제한적
  • 고주파 색상 연산에서의 성능 영향
  • HSL에 의존하는 레거시 시스템에는 적합하지 않습니다
  • 색 대비 검증 도구와 함께 사용하는 것이 가장 좋습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Logo of HSLuv for Dart & Flutter

HSLuv (and HPLuv) for Dart & Flutter

Dart port of HSLuv (revision 4) with a Flutter sample. This was a direct conversion of the reference implementation. The sample is available as a web app.

HSLuv is a human-friendly alternative to HSL.

It is like HSL, but color only gets perceptually lighter or darker when the Lightness attribute changes. In HSL, if you go from a green hue to a red one, there will be big differences in the perceived lightness. In HSLuv, almost none.

If you want to see for yourself, check the sample app and open the Color Compare screen. Contrast "only" changes when Lightness changes. When Hue or Saturation attributes change, there might be minimal changes in contrast (in the 0.01 range), but nothing perceivable and certainly better than HSV/HSL.

This is specially useful when building acessible color systems. For more information, check: Designing Color Spaces / Wikipedia article

HPLuv

HPLuv is a similar color space where the perceptual saturation/chroma of a color always stays the same under hue changes. HPL is illustrated by the smaller circle within the hsluv homepage color picker, which consists of the maximum saturation HPL values available for the given lightness level. HPL is restricted to Pastel colors, as many hues cannot reach saturation levels that equal the other hues (eg, in the image, at lightness = 60.2, the most saturated cyan is only about half as saturated as the most saturated possible orange, so the maximum saturation of HPL colors there is constrained to that of cyan).

You can make a Color in HPLuv with toColor(Hsluv.hpluvToRgb([hue, saturation, lightness)) where hue: [0...360], saturation: [0..100], lightness: [0..100].

Usage

In the pubspec.yaml of your flutter project, add the following dependency:

pub package

dependencies:
  hsluv: ^VERSION

In your project you can use it in two different ways, either low level (directly accessing values as a list<double>) or high level (similar to HSLColor). HSLuvColor is easier to use, but has less flexibility than a raw list.

import 'package:hsluv/hsluv.dart';

void main() {

  // Low level usage.
  final List<double> hsluvLow = Hsluv.rgbToHsluv([0.2,0.5,0.7]);
  print(Hsluv.hsluvToHex(hsluvLow));

  // High level usage.
  final hsluvFromColor = HSLuvColor.fromColor(Colors(0xffef3e4a));
  print(hsluvFromColor.toString());

  final hsluvFromHSL = HSLuvColor.fromHSL(300, 70, 60);
  print(hsluvFromHSL.toString());
}

Sample app showing HSV (top) vs HSLuv (bottom). See how the perceived lightness changes as the hue slider moves.

Color values ranges
  • RGB values are ranging in [0...1]
  • HSLuv and HPLuv values have different ranging for their components
    • H : [0...360]
    • S and L : [0...100]
  • LUV has different ranging for their components
    • L* : [0...100]
    • u* and v* : [-100...100]
  • LCh has different ranging for their components
    • L* : [0...100]
    • C* : [0...?] Upper bound varies depending on L* and H*
    • H* : [0...360]
  • XYZ values are ranging in [0...1]

Important: Flutter's HSLColor has lightness and saturation ranging from 0 to 1.0. HSLuv uses 0 to 100. There is a class, called HSInterColor in the sample that tries to mitigate this.

API functions
Note

The passing/returning values, when not String are List<double> containing each component of the given color space/system in the name's order :

  • RGB : [red, blue, green]
  • XYZ : [X, Y, Z]
  • LCH : [L, C, H]
  • LUV : [L, u, v]
  • HSLuv/HPLuv : [H, S, L]
Function listing
  • xyzToRgb(List<double> tuple)
  • rgbToXyz(List<double> tuple)
  • xyzToLuv(List<double> tuple)
  • luvToXyz(List<double> tuple)
  • luvToLch(List<double> tuple)
  • lchToLuv(List<double> tuple)
  • hsluvToLch(List<double> tuple)
  • lchToHsluv(List<double> tuple)
  • hpluvToLch(List<double> tuple)
  • lchToHpluv(List<double> tuple)
  • lchToRgb(List<double> tuple)
  • rgbToLch(List<double> tuple)
  • hsluvToRgb(List<double> tuple)
  • rgbToHsluv(List<double> tuple)
  • hpluvToRgb(List<double> tuple)
  • rgbToHpluv(List<double> tuple)
  • hsluvToHex(List<double> tuple)
  • hpluvToHex(List<double> tuple)
  • hexToHsluv(String s)
  • hexToHpluv(String s)
  • rgbToHex(List<double> tuple)
  • hexToRgb(String hex)
Reporting Issues

Issues and Pull Requests are welcome. You can report here.

License
Copyright 2020 Bernardo Ferrari

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트