AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Color mixer

Ein Thema von WojTec · begonnen am 27. Dez 2011 · letzter Beitrag vom 17. Aug 2012
Antwort Antwort
Seite 3 von 4     123 4      
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#21

Re: Color mixer

  Alt 24. Mai 2012, 15:25
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? Ah, I don't think so
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.686 Beiträge
 
Delphi 2007 Enterprise
 
#22

AW: Color mixer

  Alt 24. Mai 2012, 16:50
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.
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#23

Re: Color mixer

  Alt 24. Mai 2012, 17:03
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?
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.686 Beiträge
 
Delphi 2007 Enterprise
 
#24

AW: Re: Color mixer

  Alt 25. Mai 2012, 09:38
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
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#25

Re: Color mixer

  Alt 25. Mai 2012, 21:32
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?
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.686 Beiträge
 
Delphi 2007 Enterprise
 
#26

AW: Color mixer

  Alt 26. Mai 2012, 00:08
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.)
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#27

Re: Color mixer

  Alt 26. Mai 2012, 20:23
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)
Miniaturansicht angehängter Grafiken
cwccw.png  
  Mit Zitat antworten Zitat
Medium

Registriert seit: 23. Jan 2008
3.686 Beiträge
 
Delphi 2007 Enterprise
 
#28

AW: Color mixer

  Alt 26. Mai 2012, 21:26
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.
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat
freeway

Registriert seit: 11. Jul 2009
57 Beiträge
 
Delphi XE Professional
 
#29

AW: Color mixer

  Alt 26. Mai 2012, 22:32
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
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#30

Re: Color mixer

  Alt 16. Aug 2012, 18:21
I'm trying and nothing

For blend in HSL I have this. Please, how to get what I'm talking about
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 4     123 4      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:30 Uhr.
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