July 18, 2019, 09:18:34 am

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Recent posts

Pages1 2 3 ... 10
1
GUI Central / GetSysColors
Last post by Brian - Today at 07:48:35 am
Hello,

I was looking at GetSysColors, and trying to determine which colour I wanted. I thought it would be easiest to put them all together in one program

The MS API call GetSysColors(number) run from 0 to 30. If a call returns a value that is not usable, ie, GetSysColors(8), it returns 0, which is black, and still a valid RGB colour

Some values return the same colour. It was easier to put 0 to 30 in a loop, rather than sift out the values that don't do anything

No includes needed - should just compile as is

Brian

PS: Doesn't like 8 in parenths, it seems!
2
Games and Graphics / Re: Sorting Colors
Last post by billhsln - Yesterday at 07:41:51 pm
Exactly, you understand what I am trying to do and having no luck, which is why I asked for more help.  It is very difficult to do a sort based on color. I have searched the web for at least 6 months off and on and using different search engines (just in case they would come up with a different result).  I have not seen the site you found, so will give it a try and see what comes out of it.

Thanks for trying, I know it is difficult, but since I don't have a good sense of color, I was hoping some thing like this would make it easier to pick out color variations.

Thanks again,
Bill
3
Games and Graphics / Re: Sorting Colors
Last post by fasecero - Yesterday at 04:05:15 pm
I've been watching the web and I've found some info.

https://stackoverflow.com/questions/3014402/sorting-a-list-of-colors-in-one-dimension

QuoteI would like to sort a one-dimensional list of colors so that colors that a typical human would perceive as "like" each other are near each other. Obviously this is a difficult or perhaps impossible problem to get "perfectly", since colors are typically described with three dimensions, but that doesn't mean that there aren't some sorting methods that look obviously more natural than others.

- You cannot do this without reducing the 3 color dimensions to a single measurement. There are many (infinite) ways of reducing this information, but it is not mathematically possible to do this in a way that ensures that two data points near each other on the reduced continuum will also be near each other in all three of their component color values. As a result, any formula of this type will potentially end up grouping dissimilar colors.

So the solution lies on search the web for a way to reduce 3 color properties to a single measurement. I tried sortValue = L * 5 + S * 2 + H but no cigar.

Code Select
INT sortValuea = va * 5 + ha * 3 + sa
 INT sortValueb = vb * 5 + hb * 3 + sb
 RETURN sortValuea - sortValueb
4
Games and Graphics / Re: Sorting Colors
Last post by fasecero - July 16, 2019, 07:43:23 am
I do not know if what you want is possible, because you have a great dispersion in hue and brightness at the same time in those colors. One way to get a rainbow like sequence is to sort them by HUE but only with some carefully selected colors following color theory

Basic explanation: https://www.canva.com/colors/color-wheel/
Color palette generator: http://paletton.com

1) Pick a base color
2) Choose a color combination: monochromatic, analogous, triadic, tetradic, free style (your own)
3) Relatively low variance in brightness

Example
5
Games and Graphics / Re: Sorting Colors
Last post by billhsln - July 15, 2019, 10:45:30 pm
Here is the view program with the logic to sort by the different types.  But, it still does not sort the colors in a Rainbow like sort sequence.  I need a better algorithm to do the sort on.

Bill
6
Games and Graphics / Re: Sorting Colors
Last post by billhsln - July 15, 2019, 08:36:56 pm
Sorting by HSL does not give me what I am looking for.  I can add logic for sorting within, but until I can find an algorithm that will sort the colors in an order that at least looks kind of like a Rainbow, then I am stuck.

Bill
7
Games and Graphics / Re: Sorting Colors
Last post by fasecero - July 15, 2019, 07:41:01 pm
I see. It seems I followed another path. if I had to choose, I would just create the Colors.txt I need without any sorting in it. Then implement the sort inside cmpFunc, because in there I will be able to add more sorting options if I need to. Inside there you can now compare brightness, saturation, hue and r,g,b values very easy.
8
Games and Graphics / Re: Sorting Colors
Last post by billhsln - July 15, 2019, 07:05:33 pm
Ignore the internal sort, I use the Z.bat to sort by the major different types of algorithms.  There are too many sort styles that I tried and it is easier to use the batch file and keep the headers.  I figured it would be too complicated to use the sort in the program to do all the sorting I needed, so I just did it outside.  Internal does sort by Base color or RGB only.  With the algorithms I have tried I am way past that.  But none of them do a Rainbow type or at least have the major colors together, reds with reds, blues with blue, etc.

Examples:

Z lab
Z luma
Z hsl
Z hsv
Z de (supposed to give me the color difference between black and every color thereafter)
Z ncol (this is pretty much useless)
Z xyz (weird off shoot from LAB)

I know with the logic I am using, I could modify the sort, but right now it is easier with the batch file.  In fact, your sort putting the logic into CmpFunc is much cleaner than what I am doing.

Bill
9
Games and Graphics / Re: Sorting Colors
Last post by fasecero - July 15, 2019, 06:49:05 pm
OK, with that file all your code makes perfect sense. First you made an amazing grid. It is very easy to spot each color, its name and its rgb values.

The problem is inside cmpFunc. You are currently comparing 2 strings with a format like the one below

Quote045,047,040,#282F2D,077.142857,008.045976,017.058824,00.424920,02633517, 002.481706, 002.744120, 002.406351, 018.988529,-002.478642, 004.199197,012.843614,Y28,077,000.148936,000.184314,Yellow-Green  ,Green      ,Eternity

If you want to order those colors according to the brightness you must "extract" the brightness of each of th0se strings inside cmpFunc and compare them with each other. So you need to replace cmpFunc with the code below. Run the program and then select a listbox item to see the change.

Code Select
$INCLUDE "Shlwapi.inc"

SUB cmpFunc(a:POINTER,b:POINTER),INT
INT ra, ga, ba
INT rb, gb, bb

ExtractRGB(*<string>a, ra, ga, ba)
ExtractRGB(*<string>b, rb, gb, bb)

INT colorA = RGB(ra, ga, ba)
INT colorB = RGB(rb, gb, bb)

INT ha, sa, va
INT hb, sb, vb

ColorToHSV(colorA, ha, sa, va)
ColorToHSV(colorB, hb, sb, vb)

RETURN va - vb ' bv - va if you want to reverse the order
ENDSUB

SUB ExtractRGB(string text, INT r BYREF, INT g BYREF, INT b BYREF)
string red, green, blue

INT pos1 = INSTR(text, ",")
IF pos1 THEN
INT pos2 = INSTR(text, ",", pos1 + 1)
IF pos2 THEN
INT pos3 = INSTR(text, ",", pos2 + 1)
IF pos3 THEN
red = LEFT$(text, pos1-1)
green = MID$(text, pos1 +1, pos2 - pos1 -1)
blue = MID$(text, pos2 +1, pos3 - pos2 -1)

r = VAL(red)
g = VAL(green)
b = VAL(blue)
ENDIF
ENDIF
ENDIF
ENDSUB

 SUB ColorToHSV(UINT value, INT h BYREF, INT s BYREF, INT v BYREF)
word hue, sat, _val
 
ColorRGBToHLS(value, &hue, &_val, &sat) ' see https://source.winehq.org/WineAPI/ColorRGBToHLS.html
h = hue
s = sat
v = _val
 ENDSUB
10
Games and Graphics / Re: Sorting Colors
Last post by billhsln - July 15, 2019, 03:56:42 pm
Here is the file that goes into the 'Colors_View.iwb', this will allow you to view the colors.

This includes all the weird calculated results from the 'Colors_Convert.iwb'.

Bill
Pages1 2 3 ... 10