Giter VIP home page Giter VIP logo

dart-color-picker's Introduction

Dart Color Picker

The Color Picker control creates a Adobe Photoshop style HSV color picker where the RGB values can be picked based on the Hue, Saturation and Value parameters.

Color Picker

Start by adding a dependency of the Color Picker library in pubspec.yaml

dependencies:
  color_picker: ">=1.0.0 <2.0.0"

Import the library into your project

import 'package:color_picker/color_picker_lib.dart';

Create the color picker by instantiating the ColorPicker object with the desired size

	var colorPicker = new ColorPicker(256);

The size represents the no. of pixels of the gradient canvas. Since the color range is from 0-255, specify a size of 256 for pixel perfect color range.

Add the color picker element to the DOM

	query("#my_picker").nodes.add(colorPicker.element);

The initial color and the currently selected color are shown on the top right corner along with the RGB values and its corresponding HSV values.

Small Color Picker

A smaller color picker can be created with the following code:

	var smallColorPicker = new ColorPicker(128, showInfoBox: false);

The details on the right are hidden to save space by setting the showInfoBox parameter to false

Tiny Color Picker

Initial Color

Specify an initial color when launching the color picker by setting an optional initialColor parameter.

	var smallColorPicker = new ColorPicker(256, initialColor: new ColorValue.fromRGB(60, 190, 220));

Color Change Callback

Listen for color change events:

	colorPicker.colorChangeListener = (ColorValue color, num hue, num saturation, num brightness) {
		// Process new color value here ...
	};

Read the selected color value at any time from the color picker:

	var color = colorPicker.currentColor;

Cleanup

Call the dispose() method to remove the color picker from the DOM and then remove all references of the color picker object in your code. The GC should cleanup the rest.

	colorPicker.dispose();

Demo

Check out the live demo here

dart-color-picker's People

Contributors

coderespawn avatar lejard-h avatar kleak avatar butlermatt avatar

Stargazers

Ravi Teja Gudapati avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.