Delphi-PRAXiS
Seite 3 von 4     123 4      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Color mixer (https://www.delphipraxis.net/165379-color-mixer.html)

WojTec 24. Mai 2012 14:25

Re: Color mixer
 
RGB(255, 0, 0) = HSL(0, 100, 50)
RGB(255, 0, 255) = HSL(300, 100, 50)
add H/S/L values and divide by 2
result HSL(300, 200, 100) = RGB(0, 255, 128)
result is similar to color 3 in sample

Is this good way? :cyclops: Ah, I don't think so :(

Medium 24. Mai 2012 15:50

AW: Color mixer
 
Well, there is a multitude of possible ways to tweak this. And since we do not know where your sample came from, if you need to reproduce it exactly and how your original reference actually does it, we can merely try and try and try to get closer to it step by step. With only one sample and no way to see what other border colors should produce, this is as far as it gets - at least if we exclude further utter guesswork.

WojTec 24. Mai 2012 16:03

Re: Color mixer
 
So, gradient haven't to be identical as in sample. I just want to know way to get something similar ;) Could you post some example, please?

Medium 25. Mai 2012 08:38

AW: Re: Color mixer
 
I just saw, that my HSL idea could still work, since you made an error in your example:

RGB(255, 0, 0) = HSL(0, 100, 50)
RGB(255, 0, 255) = HSL(300, 100, 50)
add H/S/L values and divide by 2 you forgot the latter ;)
result HSL(300150, 200100, 10050) = I don't have a converter handy, but I am pretty confident, that this will look a lot more like what you want

WojTec 25. Mai 2012 20:32

Re: Color mixer
 
Oh, you've right, thanks ;)

Ok, I'm trying make blender in HSL space and I did it:

Delphi-Quellcode:
// get both colors HSL values to HSL1 and HSL2

H := Round((MaxHue / 100) * AValue) * (HSL2[0] - HSL1[0]) shr 8 + HSL1[0];
S := Round((MaxSat / 100) * AValue) * (HSL2[1] - HSL1[1]) shr 8 + HSL1[1];
L := Round((MaxLum / 100) * AValue) * (HSL2[2] - HSL1[2]) shr 8 + HSL1[2];

// set result as TColor
This is working. Now 2 questions: this is working in CW mode (as you see on the image posted early), how to make it in CCW? And second one, how to get n colors form this gradient, like in you proposed in RGB mode?

Medium 25. Mai 2012 23:08

AW: Color mixer
 
CW or CCW depends a little on how you draw the color circle. The mathematical positive direction is CCW, which also seems to be the common way to draw it. To make it CW, you can just flip the two colors and reverse the generated gradient :)


The multicolor thingy is something quite different: It's for when you want to blend between two colors, but need to define a specific color that should be reached somewhere in the middle of that gradient. Say like you had red->blue, but now you want yellow in there red->yellow->blue. For this you can just make two gradients: red->yellow, yellow->blue, and draw them connected. For the individual gradient parts, you could use whatever gradient method you want, i.e. in RGB or HSL or any other color space of course.
This may seem blatant, but to avoid any confusion :) (And at first it seemed like you wanted a gradient with multiple color points defined along the gradient.)

WojTec 26. Mai 2012 19:23

Re: Color mixer
 
Liste der Anhänge anzeigen (Anzahl: 1)
CCW I mean something like in attachement (this is in HSB, but idea is identical) ;)

Ok, but problem is, how to get these gradient points? To draw I can use HSL blend function (above; and for example don't use 100 percents, but let's say 4, 8, ... and get 25 colors instead 100) and all will be ok. But I want to get up to 256 colors between 2 colors on HSL wheel (like 256 colors in RGB on begin of this thread) ;)

Medium 26. Mai 2012 20:26

AW: Color mixer
 
Internal color calculation should always be done in floating point, unless for realtime purposes. Usually channels (regardless of the color model) are considered to range from 0 to 1 (exception: YCC, where chroma is -.5 to .5). Only when performing the actual drawing, the float colors are scaled into the target image's color format. That way you would not have the problem, and also minimize quantization errors across the entire application, that are quite prone to emerge when doing multiple and different processes on the same image.

I do not however understand your issue with the (C)CW gradients. CCW -> blend Color1 to Color2. CW -> blend Color2 to Color1, and reverse the resulting list of colors.

freeway 26. Mai 2012 21:32

AW: Color mixer
 
what you call gradient is the result from HSL wheel reduced to 100

if you add the colors and the result goes over 100 what will you get then ?

100 - actual value = new value

WojTec 16. Aug 2012 17:21

Re: Color mixer
 
I'm trying and nothing :(

For blend in HSL I have this. Please, how to get what I'm talking about :?:


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:28 Uhr.
Seite 3 von 4     123 4      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz