RWESharp.utils¶
Functions
|
Turns position and radius into rectangle |
|
Returns the line closest to one in 8 directions |
|
Interpolates between 2 colors |
|
Calculates distance between a and b |
|
Calls callback for each point ellipse intersects with |
|
Calls callback function for each point line intersected with |
|
Calls callback for each point inside rectangle |
|
Creates rectangle from 2 points and more |
|
|
|
Tries to find file in path without checking case |
|
linear interpolation or something |
|
Logs a message in both terminal and log file |
|
converts specified path to file url |
|
Paints svg image with caching |
|
Paints svg image with caching |
|
Paints svg image with caching |
|
Converts from Cartesian to polar coordinates |
|
Converts from polar to Cartesian coordinates |
|
Converts value from one range to another |
|
Rotates point with some angle |
Classes
|
- RWESharp.utils.log(message, error=False) None[source]¶
Logs a message in both terminal and log file
- Parameters:
message – message to log
error – Whether it’s error or not
- Returns:
None
- Return type:
None
- RWESharp.utils.draw_line(pointa: QPoint, pointb: QPoint, callback: Callable) None[source]¶
Calls callback function for each point line intersected with
- RWESharp.utils.insensitive_path(path) str | None[source]¶
Tries to find file in path without checking case
- Parameters:
path – path to file
- Returns:
Path to fixed file if found
- Return type:
- RWESharp.utils.fit_rect(lastpos: QPoint, pos: QPoint, shift: bool, alt: bool) QRect[source]¶
Creates rectangle from 2 points and more
Literally stolen from photoshop
- RWESharp.utils.draw_rect(rect: QRect, hollow: bool, callback: Callable) None[source]¶
Calls callback for each point inside rectangle
- RWESharp.utils.draw_ellipse(rect: QRect, hollow: bool, callback: Callable) None[source]¶
Calls callback for each point ellipse intersects with
NOTE: Callback may be called multiple times on same point
- RWESharp.utils.paint_svg(filename: str, color: QColor) str[source]¶
Paints svg image with caching
works with resources too
if file is already stored in cache, passes it instead
- RWESharp.utils.paint_svg_qicon(filename: str, color: QColor) QIcon[source]¶
Paints svg image with caching
works with resources too
if file is already stored in cache, passes it instead
- RWESharp.utils.paint_svg_qpixmap(filename: str, color: QColor) QPixmap[source]¶
Paints svg image with caching
works with resources too
if file is already stored in cache, passes it instead
- RWESharp.utils.remap(x: float, in_min: float, in_max: float, out_min: float, out_max: float) float[source]¶
Converts value from one range to another
- RWESharp.utils.color_lerp(c1: QColor, c2: QColor, t: float) QColor[source]¶
Interpolates between 2 colors
- RWESharp.utils.closest_line(pos, lastpos) QLineF[source]¶
Returns the line closest to one in 8 directions
- Parameters:
pos – start of line
lastpos – end of line
- Returns:
closest line to given argument
- Return type:
QLineF
- RWESharp.utils.rotate_point(point: QPointF, angle) QPointF[source]¶
Rotates point with some angle
- Parameters:
point (QPointF) – point to rotate
angle – angle to rotate in degrees
- Returns:
rotated point
- Return type:
QPointF
- RWESharp.utils.circle2rect(pos: QPointF, radius: float) QRectF[source]¶
Turns position and radius into rectangle
- RWESharp.utils.point2polar(pos: QPointF) QPointF[source]¶
Converts from Cartesian to polar coordinates
- Parameters:
pos (QPointF) – Position in cartesian coordinates
- Returns:
Point in polar coordinates where x is angle and y is distance
- Return type:
QPointF
- RWESharp.utils.polar2point(pos: QPointF) QPointF[source]¶
Converts from polar to Cartesian coordinates
- Parameters:
pos (QPointF) – Position in polar coordinates where x is angle and y is distance
- Returns:
Point in Cartesian coordinates
- Return type:
QPointF
- class RWESharp.utils.Delegate(func)[source]¶
- Deprecated:
Delegate allows for adding hooks to methods
!!!Does not work for methods!!!
To make method hookable, add @Delegate attribute
To hook prefix to delegate, use *= or @method.prefix attribute
To hook postfix to delegate, use += or @method.postfix attribute
Prefixes get called before delegate and can change arguments before passing it to delegate
simply return (args, kwargs, returnval)
if returnval is not None, stops delegate from being called
Postfixes can change return value of delegate by returning not None and can get value of delegate or previous postfix
To unhook your method from delegate, use -=