SRL Archive - OSR Help

FindColorsSpiralTolerance Question


bambe

2012-07-24 03:29:22

Hi i have a quick question.

I read somewhere that FindColorsSpiralTolerance starts the search from the centre of the main-screen which is fine, but could the spiral start position be changed to say the top left, top right, bottom left, bottom right?

I want to know because i was thinking that when looking for a colour and couldn't find it, it could then go to the next function that would do the same search again but from a corner rather then the middle.

thanks

Daniel

2012-07-24 03:30:55

It starts from what you put in the cx, cy parameters (c = centre, so cx = Centre X, cy = Centre Y). :)

EDIT: Also, changing corners won't make the colour appear, as it still has to search the entire client area nonetheless.

But, for learning purposes (if you are unsure of how to approach the solution), you can do something like the following:

var
I, Colour, Tolerance: Integer;
centrePoints, Points: TPointArray;
begin
Colour := 16777215; // The colour to look for.
Tolerance := 16; // The tolerance you are allowing for.
centrePoints := [Point(0, 0), Point(MSX2, 0), Point(0, MSY2), Point(MSX2, MSY2)]; // The corners of the client area. If you are using it for RuneScape, then you can just leave it the way it is :)

// Go and find the colour and each of the four corners, and when found, break out of the loop.
for I := 0 to High(centrePoints) do
if(FindColorsSpiralTolerance(centrePoints[I].X, centrePoints[I].Y, Colour, Points, MSX1, MSY1, MSX2, MSY2, Tolerance)) then
Break;

// Check if the colour was actually found or not.
if(I = High(centrePoints) + 1) then
begin
Writeln('Could not find the colour in any of the four corners! :-(');
Exit;
end;

// ... Do other stuff here.
end;

:)

Please note, I wrote that inside of my browser and off the top of my head, so it may/may not compile and require a few additional changes/fixes.

bambe

2012-07-24 03:55:00

thanks ill give it ago and see what happens :)

Daniel

2012-07-24 03:56:47

From: bambe
thanks ill give it ago and see what happens :)


Good luck! :) Remember what I said, though. Chances are, that if the colour isn't found the first time round, searches immediately after the failed ones will probably result in the same failure: the colour not being found.