SRL Archive - Help and Support

Using FindSimColorMany function.


XxKanexX

2006-02-27 02:03:39


Available in, SRL/SRL/Core/Color.scar.
Made By XxKanexX


Information:
This will search for 1 - 3 similar colors as the inputted color. (Will not result as the given color).

It results in how many colors were found. If a color wasn't found, the array is made -1.

Parameter description:
    function FindSimColorMany(var save: array of integer; many, color, xs, ys, xe, ye, tol, dist: integer; hardsearch: boolean): integer;

It uses an array to save the colors in. Make an array.

var
i: array of integer;

Then, put "i" as the save parameter. (Or whatever your array is named).
Then fill out the rest of the parameters.
  • many: Many colors to find. (Can only be 1, 2 or 3.).
If you're only looking for one color, Just use the FindSimColor function.

  • color: The main color that the others will be similar to.

  • xs, ys, xe, ye: The box to find them in. (Look around for tutorials on these.).

  • tol: The tolerance to start at. (Will rise if the color(s) arn't found.).

  • dist: How far away it can look for similar colors.

  • hardsearch: Will triple check if a color is not found. (97% more chance of finding a color)

Example:
Once this has compiled, it will save all the colors it has found in the array.
Here's a sample script:


{.include SRL/SRL.scar}

var
i: array of integer;
w, h, found: integer;
Begin
SetupSRL;
Getclientdimensions(w, h);
Found:= FindSimColorMany(i, 3, 4380267, 0, 0, w, h, 5, 10, true);
Writeln('Found '+inttostr(found)+' Colors.');
Writeln('1: '+inttostr(i[1])+', 2: '+inttostr(i[2])+', 3: '+inttostr(i[3]));
End.

Similar:
Similar color finding scripts to this (Made By XxKanexX):
    function FindSimColor(color, xs, ys, xe, ye, tol, dist: integer; hardsearch: boolean): integer;
Used to find only 1 color.

Author:
Made By XxKanexX

masquerader

2006-02-27 16:58:50

only up to 3?
couldnt you set it up to do as many as you want?
the loops dont look that difficult

i thought this was like FindColorsTolerance, but then i realized it returned a color instead of point, i suppose you could do FindColorsTolerance and then to GetColor at all of them :p

XxKanexX

2006-02-28 18:55:34

I could set it to do more, but it would lag.

And 3 is a good enough amount for a scripts colors.