### Pascal Function Documentation Comment Example Source: https://github.com/villavu/srl-development/blob/master/docs/docgen/README.md Illustrates the structure and content of a documentation comment block for a Pascal function, including its signature, parameters, return type, and usage examples. This format is parsed by the documentation generation tool. ```Pascal (* Mainscreen.PointToMM ~~~~~~~~~~~~~~~~~~~~ .. pascal:: function TRSMainScreen.PointToMM(MS: TPoint; Height: Int32=0; Accuracy:Double=0.2): Vector3; Takes a mainscreen point and converts it to a point on the minimap. Returns a Vector3 which includes input height. Conversion to a TPoint if that's what you need is simply done by calling `.ToPoint` on the result. **Example** WriteLn Mainscreen.PointToMM(Point(250,140), 2); WriteLn Mainscreen.PointToMM(Point(250,140), 2).ToPoint(); // as a TPoint (lost accuracy) *) ``` -------------------------------- ### Complete Example of TSRL.FindColors Usage in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding A full Pascal example demonstrating how to use srl.FindColors to locate points, check if any points were found, and print the count. It includes necessary includes and variable declarations for a runnable script. ```pascal {$I SRL/OSR.simba} var TPA: TPointArray; //the list in which we store the points begin if srl.FindColors(TPA, CTS2(1234567, 10), Box(4,4, 503, 336)) > 0 then WriteLn('I found ',Length(TPA),' points'); end; ``` -------------------------------- ### Linux Setup and Documentation Generation Commands Source: https://github.com/villavu/srl-development/blob/master/docs/docgen/README.md Provides the necessary commands for setting up the Python environment with Sphinx and Sphinx RTD Theme on Linux, followed by the command to execute the documentation generation script. ```Bash sudo apt-get install python3 python3-pip sudo pip install sphinx sphinx_rtd_theme python3 docgen.py ../../ ``` -------------------------------- ### Example Usage of T2DPointArray.SortByMiddle in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Demonstrates how to use T2DPointArray.SortByMiddle to reorder clustered point groups. After finding and clustering points, this example sorts the ATPA (groups) so the group closest to the main screen's middle is at the beginning of the list. ```pascal {$I SRL/OSR.simba} var TPA: TPointArray; //the list in which we store the points ATPA: T2DPointArray; //the groups we found begin if srl.FindColors(TPA, CTS2(1234567, 10), Box(4,4, 503, 336)) > 0 then begin WriteLn('I found ',Length(TPA),' points'); ATPA := TPA.Cluster(4); WriteLn('I split the points into ',Length(ATPA),' groups'); // Make the first group in the list of groups `ATPA` closest to us. ATPA.SortByMiddle(mainscreen.GetMiddle); end; end; ``` -------------------------------- ### Example Usage of TPointArray.Cluster in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Demonstrates how to use TPointArray.Cluster in a Pascal script to find colors, then group the resulting points into T2DPointArray groups based on proximity. It shows how to initialize point arrays and print the number of found points and groups. ```pascal {$I SRL/OSR.simba} var TPA: TPointArray; //the list in which we store the points ATPA: T2DPointArray; //the groups we found begin if srl.FindColors(TPA, CTS2(1234567, 10), Box(4,4, 503, 336)) > 0 then begin WriteLn('I found ',Length(TPA),' points'); ATPA := TPA.Cluster(4); WriteLn('I split the points into ',Length(ATPA),' groups'); end; end; ``` -------------------------------- ### Sort T2DPointArray Groups by Size in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding This Pascal example illustrates how to use T2DPointArray.SortBySize after finding and clustering points. It sorts the detected point groups by their size, allowing for easy identification and processing of the largest (or smallest) groups. The snippet also iterates through the sorted groups to display their sizes. ```Pascal {$I SRL/OSR.simba} var Group,TPA: TPointArray; //the list in which we store the points ATPA: T2DPointArray; //the groups we found begin if srl.FindColors(TPA, CTS2(1234567, 10), Box(4,4, 503, 336)) > 0 then begin WriteLn('I found ',Length(TPA),' points'); ATPA := TPA.Cluster(4); WriteLn('I split the points into ',Length(ATPA),' groups'); // Make the first group in the list of groups `ATPA` largest one ATPA.SortBySize(); // write the size of every group: for group in ATPA do WriteLn('This group has the size: ', Length(group)); end; end; ``` -------------------------------- ### SRL Core Data Types and Helper Functions API Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Documents the CTS2 function for creating color objects with tolerance, the Box function for defining search areas, and the TBox and TPoint record structures used for coordinates and bounding boxes in SRL. ```APIDOC function CTS2(Color, Tolerance: Int32; HueMod, SatMod: Extended = 0.2): TCTS2Color; function Box(X1, Y1, X2, Y2: Int32): TBox; TBox = record X1,Y1, X2,Y2: Int32 end; TPoint = record X,Y: Int32 end; ``` -------------------------------- ### SRL Pascal Object Finder with Color Detection and Mouse Interaction Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding This Pascal code snippet implements an object finder using the SRL library. It first finds points of a specific color, clusters them into groups, then filters these groups by size and sorts them by proximity to the screen's center. The script iterates through the sorted groups, moves the mouse to a random point within each group, checks for a specific uptext, and clicks if the text matches, breaking the loop upon successful interaction. ```pascal var TPA,Group: TPointArray; //the list in which we store the points ATPA: T2DPointArray; //the groups we found i: Int32; begin if srl.FindColors(TPA, CTS2(1234567, 10), Mainscreen.GetBounds) > 0 then begin WriteLn('I found ',Length(TPA),' points'); ATPA := TPA.Cluster(4); WriteLn('I split the points into ',Length(ATPA),' groups'); // remove none-interesting outliers so we don't have to mouse over them ATPA.FilterSize(250, 1500); // Make the first group in the list of groups `ATPA` closest to us. ATPA.SortByIndex(mainscreen.GetMiddle); // loop through every group, nearest to furthest away for Group in ATPA do begin // move mouse to a random point in the group // We access a random individual point in that group by indexing // // Breaking it down: // Length(Group) returns the number of points in the group // Random( .. ) generates a random value in the range 0..Length(Group)-1 // Group[ .. ] accesses the item at that random index. Mouse.Move( Group[Random(Length(Group))] ); // check if the uptext matches our expectations if MainScreen.IsUpText('Change me') then begin // click this object!! Mouse.Click(MOUSE_LEFT); if not MainScreen.DidRedClick() then break; // we should probably return False here, as we missed clicked. // stop the loop, we found what we were looking for! Break; end; // we end up here if the group didn't match our expectations // so we will move to the next group and see if that's any better. end; end; end; ``` -------------------------------- ### Create TCTS2Color Objects with CTS2 Function in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Demonstrates how to use the CTS2 function to create TCTS2Color objects, showing both basic usage with color and tolerance, and advanced usage including HueMod and SatMod for precise color matching. ```pascal myColor := CTS2($54323, 15); myAccurateColor := CTS2($54323, 15, 0.754, 0.094); ``` -------------------------------- ### Sort T2DPointArray Groups by Index Proximity in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding This snippet demonstrates how to find colors in a screen region, cluster the found points into groups (T2DPointArray), and then sort these groups based on their proximity to a reference point (e.g., the middle of the screen). This helps in prioritizing groups closest to a specific location. ```Pascal {$I SRL/OSR.simba} var TPA: TPointArray; //the list in which we store the points ATPA: T2DPointArray; //the groups we found begin if srl.FindColors(TPA, CTS2(1234567, 10), Box(4,4, 503, 336)) > 0 then begin WriteLn('I found ',Length(TPA),' points'); ATPA := TPA.Cluster(4); WriteLn('I split the points into ',Length(ATPA),' groups'); // Make the first group in the list of groups `ATPA` closest to us. ATPA.SortByIndex(mainscreen.GetMiddle); end; end; ``` -------------------------------- ### TSRL.FindColors Function Definition Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Defines the TSRL.FindColors function, a core method in SRL for OSRS that searches a specified screen area for pixels matching a given color and returns a list of found points as a TPointArray. ```APIDOC function TSRL.FindColors(out TPA: TPointArray; Color: TCTS2Color; Area: TBox): UInt32; ``` -------------------------------- ### Define Search Area with Box Function in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Illustrates how to use the Box function to define a rectangular search area on the screen. The TBox structure consists of two coordinates: an upper-left and a lower-right point. ```pascal myBox := Box(10,10, 100, 100); ``` -------------------------------- ### Filter T2DPointArray Groups by Size Range in Pascal Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding This Pascal snippet demonstrates the application of T2DPointArray.FilterSize to refine point groups. After finding and clustering points, it filters out groups that are either too small or too large based on defined minimum and maximum point counts, effectively removing outliers and focusing on relevant data. ```Pascal {$I SRL/OSR.simba} var TPA: TPointArray; //the list in which we store the points ATPA: T2DPointArray; //the groups we found begin if srl.FindColors(TPA, CTS2(1234567, 10), Box(4,4, 503, 336)) > 0 then begin WriteLn('I found ',Length(TPA),' points'); ATPA := TPA.Cluster(4); WriteLn('I split the points into ',Length(ATPA),' groups'); // filter out all groups that contains less than 200 points and more than 1000 points ATPA.FilterSize(200,1000); WriteLn('After filtering out outliers we have ',Length(ATPA),' groups left'); // Make the first group in the list of groups `ATPA` closest to us. ATPA.SortByIndex(mainscreen.GetMiddle); end; end; ``` -------------------------------- ### TPointArray.Cluster API Definition Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Defines the overloaded methods for density-based clustering of TPointArray objects, grouping points based on a specified distance threshold(s). ```APIDOC function TPointArray.Cluster(Dist: Int32): T2DPointArray; function TPointArray.Cluster(DistX, DistY: Int32): T2DPointArray; ``` -------------------------------- ### T2DPointArray.SortByIndex API Definition Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Defines the method for sorting T2DPointArray groups. It reorders groups based on the distance of their n-th coordinate (defaulting to the first, index 0) from a specified From point, addressing limitations of SortByMiddle. ```APIDOC procedure T2DPointArray.SortByIndex(From: TPoint; Index: Int32 = 0); ``` -------------------------------- ### Customize Sphinx ReadTheDocs Theme Layout Source: https://github.com/villavu/srl-development/blob/master/docs/docgen/layout.html This Jinja2 template code extends the default Sphinx layout, specifically targeting the ReadTheDocs theme. It overrides the 'footer' block to first include the parent's footer content and then injects a CSS rule. The CSS rule `max-width: none;` applied to `.wy-nav-content` ensures that the main content area of the documentation expands to the full width of the browser window, rather than being constrained by a fixed maximum width. ```Jinja2 {% extends "!layout.html" %} {% block footer %} {{ super() }} .wy-nav-content { max-width: none; } {% endblock %} ``` -------------------------------- ### T2DPointArray.SortByMiddle API Definition Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding Defines the method for sorting T2DPointArray groups. It reorders the groups so that the one closest to the specified From point (based on the group's geometric middle) appears first. ```APIDOC procedure T2DPointArray.SortByMiddle(From: TPoint); ``` -------------------------------- ### T2DPointArray.SortBySize API Reference Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding This API method sorts T2DPointArray groups by their individual size or length. It can be configured to sort in ascending or descending order, making it useful for prioritizing larger or smaller objects based on their point count. ```APIDOC procedure T2DPointArray.SortBySize(Size: Int32 = 0; ClosestFirst: Boolean = False); ``` -------------------------------- ### T2DPointArray.FilterSize API Reference Source: https://github.com/villavu/srl-development/wiki/The-Core-of-Colorfinding This overloaded API method filters T2DPointArray groups, removing those whose point count falls outside a specified minimum and maximum range. It is crucial for eliminating outlier groups that do not meet expected size criteria, thus refining the dataset for further processing. ```APIDOC procedure T2DPointArray.FilterSize(MinLen, MaxLen: Int32); overload; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.