Difference between revisions of "mbColorLib"

From Lazarus wiki
Jump to navigationJump to search
(→‎RGB color pickers: CMYK color model)
Line 22: Line 22:
  
 
=== RGB color pickers ===
 
=== RGB color pickers ===
 +
[[image:rgb_pickers.png|Component palette icons of the R/G/B color pickers]]
 
The RColorPicker, GColorPicker, BColorPicker, as well as the RAxisColorPicker, GAxisColorPicker, BAxisColorPicker can be used to select a color using the RGB color model. In this model, the colors red, green and blue are used as base colors. If these color components are turned off the resulting color is black, like on a monitor screen. Increasing the red, green, blue values adds color to the monitor until the final color, white, is reached. Therefore, this is called ''addtive color mixing''.
 
The RColorPicker, GColorPicker, BColorPicker, as well as the RAxisColorPicker, GAxisColorPicker, BAxisColorPicker can be used to select a color using the RGB color model. In this model, the colors red, green and blue are used as base colors. If these color components are turned off the resulting color is black, like on a monitor screen. Increasing the red, green, blue values adds color to the monitor until the final color, white, is reached. Therefore, this is called ''addtive color mixing''.
  

Revision as of 19:07, 26 December 2016

Template:mbColorLib

In preparation

About

FullDemo screenshot

Comprehensive library with more than 30 components for color selection in several color models (RGB, CYMK, HSV, HSL, CIE-Lab). The components can be combined to create numerous new tools and color dialogs.

Authors

  • Original author: Marko Binić
  • Lazarus port: Werner Pamler

License

Original license text by Marko Binić from the file Readme.rtf in the installation folder: "License is granted to use, modify and redistribute these units in your applications as you see fit. You are given COMPLETE FREEDOM with the sources found in this pack; you're free to use it in ANY kind of app without even mentioning my name, my site or any other stuff, that depends on your good will and nothing else. I will accept any modifications and incorporate them in this pack if they'll help make it better. You are under NO obligation to pay for these components to neither me nor anyone else trying to sell them in their current form. If you wish to support development of these components you can do so by contributing some source or making a donation, again this solely depends on your good will."


Usage

Component palette with mgColorLib components

Currently, the mbColorLib consists of 30 visual multi-purpose color picker components, a color selection dialog and 1 standard action for picking color from the desktop. The visual components can be classified by the color model to which they apply.

RGB color pickers

Component palette icons of the R/G/B color pickers The RColorPicker, GColorPicker, BColorPicker, as well as the RAxisColorPicker, GAxisColorPicker, BAxisColorPicker can be used to select a color using the RGB color model. In this model, the colors red, green and blue are used as base colors. If these color components are turned off the resulting color is black, like on a monitor screen. Increasing the red, green, blue values adds color to the monitor until the final color, white, is reached. Therefore, this is called addtive color mixing.

The RColorPicker is a simple 1-dimensional slider which can be used to adjust the red component of the final color which is accessible from the property SelectedColor. Whenever the color changes an event OnChange is generated. The green and blue components can be set by corresponding properties.

Correspondingly, the GColorPicker and BColorPicker components are responsible for the green and blue base color values.

The RAxisColorPicker is a 2-dimensional color picker. It is the complement of the RColorPicker and varies the green and blue color values in the rectangle defined by the rectangle spanned by the component. The blue value increases horizontally, and the green value increases vertically. The red value is held fixed. The point of the SelectedColor is marked by a circle or a cross (property MarkerStyle) and can be controlled by dragging the mouse or using the arrow keys. Whenever the selected color changed, the event OnChange is fired.

The event OnChange can be used to link the red color component of the RAxisColorPicker to the red color component selected by a RColorPicker:

procedure TForm1.RAxisColorPickerChange(Sender: TObject);
begin
  RAxisColorPicker.Red := RColorPicker.Red;
end;

Similarly, the GAxisColorPicker and BAxisColorPicker are the complements of the GColorPicker and BColorPicker. The GAxisColorPicker varies blue and red, the BAxisColorPicker green and red on the horizontal and vertical axes, respectively.

CMYK color pickers

The CMYK color model is usually employed by color printers. The unprinted sheet of paper is white, i.e. reflects all light. Printing a cyan dye onto the paper absorbs its complementary color, red, from the spectrum; green and blue can pass the dye without being changed (ideally). Similarly magenta and yellow are used to subtract the green and blue colors from the white color of the paper. Since colors are subtracted this process is called subtractive color mixing. Cyan, magenta, and yellow are the base colors of the CMY color model, but usually a black dye is added for achieving better color saturation, and this leads to the name CMYK.

Demo projects

Two demo projects are contained in the folder examples of the component installation directory:

  • fulldemo shows application of all the components included in the mbColorLib.
  • axispickers demonstrates the combination of RAxisColorPicker and RColorPicker, GAxisColorPicker and GColorPicker and BAxisColorPicker and BColorPicker.
  • trackbars demonstrates all trackbar color selectors.

Download and installation

Change Log

Version 2.2

  • Initial commit of the library to the Lazarus Components and Code Repository. It is based on the last published Delphi version 2.0.1 available from http://mxs.bergsoft.net. In the Lazarus version Delphi support has been dropped.