Recent

Author Topic: mbColor Lib T-AxisColorPicker(s) T-ColorPicker(s)  (Read 3741 times)

PaulANormanNZ

  • Full Member
  • ***
  • Posts: 115
mbColor Lib T-AxisColorPicker(s) T-ColorPicker(s)
« on: March 24, 2018, 05:05:10 am »
Hi,

1.  If you drop say a TRColorPicker onto a form. its initial color value might be expected to be clRed?

Instead it is $008080FF not $000000FF - why would that be planned to be?

Green and Blue components are also not "pure" with the same 80 offsets,
Blue: $00FF8080
Green: $0080FF80

Is this some colour space /gamut thing I have not taken into account please?

2. Also in the wiki the following appears:

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

Code: Pascal  [Select][+][-]
  1. procedure TForm1.RAxisColorPickerChange(Sender: TObject);
  2. begin
  3.   RAxisColorPicker.Red := RColorPicker.Red;
  4. 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.

http://wiki.lazarus.freepascal.org/mbColorLib#RGB_color_pickers

When you run it it seems to be a nullity.
I've missed something here - or is that code back to front?

Why when the Axis component is changing colour, would it pick up its new value from the RColorPicker?

Could it be meant to have actually read:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.RAxisColorPickerChange(Sender: TObject);
  2. begin
  3.    RColorPicker.Red:= RAxisColorPicker.Red;
  4. end;

Any help appreciated please.

Paul

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: mbColor Lib T-AxisColorPicker(s) T-ColorPicker(s)
« Reply #1 on: March 24, 2018, 11:41:22 am »
Color is something like a three-dimensional vector. Depending on the color model it consists of R, G, B components, or H, S, L, etc. The essence of mbColorLib is to provide input controls for changing the vector components. Since the screen is a 2D-object you always have to combine at least two of the components in order to be able to reach every color.

I think the basic idea of the original author for the R/G/BColorPicker was (and I did not change this when porting the components) to cooperate with the corresponding R/G/BAxisColorPicker. The R/G/BColorPickers are sliders, i.e. they modify only 1 component, the other 2 are held fixed, the R/G/BAxisColorPickers are 2D-"pads", i.e. they modify 2 components, the other one is held fixed. This way all three coordinates can be changed. From this point of view the RColorPicker should display along the slider all colors which can be reached when varying the R component alone. In the same way, the RAxisColorPicker displays all colors which can be reached in its planar section through the RGB space. To complete visual feedback to all accessibility color, the gradient in the RAxisColorPicker should be adapted whenever the R is changed by the RColorPicker. (Unfortunately there was a bug in the corresponding units which is fixed in the trunk version of the ColorLib now). To achieve this effect both controls must be hooked into the OnChange event of the its companion:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.RAxisColorPicker1Change(Sender: TObject);
  2. begin
  3.   RColorPicker1.SelectedColor := RAxisColorPicker1.SelectedColor;
  4. end;
  5.  
  6. procedure TForm1.RColorPicker1Change(Sender: TObject);
  7. begin
  8.   RAXisColorPicker1.SelectedColor := RColorPicker1.SelectedColor;
  9. end;  

Please have a look at the demo in folder examples/axispickers.

In fact, there was a typo in the wiki, but opposite to your suggestion. Fixed.

Of course, this is not the only way to use the ColorPickers. The way you understand them is a simple slider for the R,G,B components, alone. Of course, then their visual appearance is misleading, just set R=255, G=0 and B=0 for the RColorPicker (and for the others accordingly), and don't establish a feedback from another color picker. Check out the demo in examples/trackbars

PaulANormanNZ

  • Full Member
  • ***
  • Posts: 115
Re: mbColor Lib T-AxisColorPicker(s) T-ColorPicker(s)
« Reply #2 on: March 27, 2018, 02:01:23 am »
Thanks RB, for the explanation and history of the components.

It has been a great help in understanding the possibilities of these sliders and axis controls.

I have gone over to using them as you first describe, the subtleties of precision are very worth while.

I will also use the RGB sliders as straight R G B sliders in another area of the program.

I use the Online Package Manger for these components, and they are showing as needing no updating as at 2.2.0.0.
Does that tally with what you refer to in the trunk?

Many thanks again for the full explanation.

Paul


wp

  • Hero Member
  • *****
  • Posts: 11830
Re: mbColor Lib T-AxisColorPicker(s) T-ColorPicker(s)
« Reply #3 on: March 27, 2018, 10:37:16 am »
I just uploaded a new release version 2.2.1 which makes the current trunk version available through OPM.

 

TinyPortal © 2005-2018