Difference between revisions of "CountColorTolerance"

From SCAR Divi Manual
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
==Definition==
 
==Definition==
 
<source lang="scar" lines="false">
 
<source lang="scar" lines="false">
function CountColorTolerance(Color, xs, ys, xe, ye, Tol: Integer): Integer;
+
function CountColorTolerance(const Color, XS, YS, XE, YE, Tol: Integer): Integer;
 
</source>
 
</source>
  
Line 10: Line 10:
  
 
==Description==
 
==Description==
This function searches for a given color specified by '''Color''' within a [[tolerance]] range specified by '''Tol''' inside of a given search area specified by '''xs''', '''ys''', '''xe''', '''ye''' using a scan-line pattern. The search area is given as a set of upper-left ('''xs''', '''ys''') and lower-right ('''xe''', '''ye''') coordinates which are specified relative to the selected client window. The function returns the number of pixels it found, as a result of this 0 is returned when the color was not found.
+
This function searches for a given color specified by '''Color''' within a [[tolerance]] range specified by '''Tol''' using a scan-line pattern. The search area is given as a set of upper-left ('''XS''', '''YS''') and lower-right ('''XE''', '''YE''') coordinates which are specified relative to the selected client window. If the given search area is invalid ('''XS''' > '''XE''' or '''YS''' > '''YE'''), an exception is thrown.
 +
 
 +
The function returns the number of pixels it found, as a result of this 0 is returned when the color was not found.
 +
 
 +
The active tolerance algorithm can be changed using the [[ColorToleranceSpeed]] function.
  
 
==Example==
 
==Example==

Latest revision as of 14:42, 2 April 2012

CountColorTolerance.gif

Definition

function CountColorTolerance(const Color, XS, YS, XE, YE, Tol: Integer): Integer;

Availability

SCAR Divi 3.00 > Current

Description

This function searches for a given color specified by Color within a tolerance range specified by Tol using a scan-line pattern. The search area is given as a set of upper-left (XS, YS) and lower-right (XE, YE) coordinates which are specified relative to the selected client window. If the given search area is invalid (XS > XE or YS > YE), an exception is thrown.

The function returns the number of pixels it found, as a result of this 0 is returned when the color was not found.

The active tolerance algorithm can be changed using the ColorToleranceSpeed function.

Example

var
  w, h: Integer;

begin
  GetClientDimensions(w, h);
  WriteLn('Counted color ' + IntToStr(CountColorTolerance(4, 0, 0, w - 1, h - 1, 5)) + ' times');
end.

See Also