alin2012 Posted July 2, 2011 Share Posted July 2, 2011 Hello, is it possible to search for a color (with tolerance) only in pixels from a tpointarray ? Sorry if this is a dumb question.I'm new to Scar and to programming . Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 3, 2011 Share Posted July 3, 2011 Yes, it is, but not using just 1 function. There's several ways you can actually do this. You could use [wiki=GetColors]GetColors[/wiki] to get the colors at all of these coordinates and manually search them. You could build a [wiki=TPointArray]TPointArray[/wiki] with all points you do not want to search and use [wiki=FindColorSkipCoords]FindColorSkipCoords[/wiki]. I would however advice to use [wiki=FindColorsTolerance]FindColorsTolerance[/wiki] to find all of the colors you are looking for in a search area and then filter out the points that you wanted to look for. function FindColorToleranceCoords(var x, y: Integer; const Color: Integer; const Points: TPointArray; const Tolerance: Integer): Boolean; var b: TBox; p: TPointArray; i, j, k, l: Integer; begin Result := False; b := GetTPABounds(Points); if not FindColorsTolerance(p, Color, b.x1, b.y1, b.x2, b.y2, Tolerance) then Exit; l := Length(p); k := Length(Points); for i := 0 to k - 1 do for j := 0 to l - 1 do if (p[j].X = Points[i].X) and (p[j].Y = Points[i].Y) then begin x := Points[i].X; y := Points[i].Y; Result := True; Exit; end; end; var TPA: TPointArray; x, y: Integer; begin TPA := [Point(273, 60), Point(475, 63)]; if FindColorToleranceCoords(x, y, 0, TPA, 1) then WriteLn(IntToStr(x) + ',' + IntToStr(y)); end. SCAR Divi 3.26 will contain TPA functions to make this a lot faster and do it far more efficiently, but since it's still in beta I wrote the code for SCAR Divi 3.25 Quote Link to comment Share on other sites More sharing options...