Camel
2014-10-27 16:26:06
In this mouse overload procedure, why is it like this? I can't think of a use
Random(x) only returns positive values. For example, random(5) could possibly return 0,1,2,3, or 4.
To explain my problem with this I'll make a picture.
EDIT: PRetend the following circular shapes are rectangles. The issue i'm bringing up is still represented by these pictures but I had a moment of math stupidity when I made this.
The procedure as is will only mouse the orange area. It seems to me that this method was intended to mouse all around the given point. So if one uses
Instead of random(x) like so…
The effect is (another picture)
So yeah, I don't know if this procedure is working as intended or a mistake. I'm going to use the latter mouse(x,y,ranX,RanY) in my srl regardless, but I figured I would bring this up.
(*
mouse overload
~~~~~~~~~~~~~~
.. code-block:: pascal
procedure mouse(x, y, randX, randY, button: integer = MOUSE_MOVE);
Moves the mouse to x, y, coords adding random randX, and randY onto x and y,
button is a default parameter and by default is set to MOUSE_MOVE.
.. note::
- by Olly
Example:
.. code-block:: pascal
mouse(100, 100, 5, 5, MOUSE_LEFT);
mouse(100, 100, 5, 5);
*)
procedure mouse(x, y, randX, randY, button: integer = MOUSE_MOVE); overload;
begin
mouse(point(x+random(randX), y+random(randY)), button); // <---- + random(x)
end; Random(x) only returns positive values. For example, random(5) could possibly return 0,1,2,3, or 4.
To explain my problem with this I'll make a picture.
EDIT: PRetend the following circular shapes are rectangles. The issue i'm bringing up is still represented by these pictures but I had a moment of math stupidity when I made this.
The procedure as is will only mouse the orange area. It seems to me that this method was intended to mouse all around the given point. So if one uses function gaussRangeInt(minI, maxI: Integer): Integer;
begin
Result := Round(gaussRangeExt(minI, maxI));
end; Instead of random(x) like so…
procedure mouse(x, y, randX, randY, button: integer = MOUSE_MOVE); overload;
begin
mouse(point(x+GaussRangeInt(-randX,randX), y+GaussRangeInt(-randY,randY)), button);
end; The effect is (another picture)
So yeah, I don't know if this procedure is working as intended or a mistake. I'm going to use the latter mouse(x,y,ranX,RanY) in my srl regardless, but I figured I would bring this up.
