Module gpanel :: Class GPanel
[hide private]
[frames] | no frames]

Class GPanel

source code

PyQt4.QtGui.QWidget --+
                      |
                     GPanel


Class to create a graphics window of default size 501x501 pixels (client drawing area)
using a coordinate system with x-axis from left to right, y-axis from bottom to top
(called user coordinates, default range 0..1, 0..1).

The drawing methods perform drawing operation in an offscreen buffer (QPixmap)
and automatically renders it on the screen, so the graphics is shown step-by-step.


The drawing methods perform drawing operation in an offscreen buffer (pixmap)
and automatically renders it on the screen, so the graphics is shown step-by-step.

User coordinates:  (ux, uy)
Pixel coordinates: (px, py) (screen pixels)
Transformation: px = px(ux), py = py(uy)
Pixel coordinate range: 0..winWidth - 1 (inclusive), 0..winHeight - 1 (inclusive); (0,0) upper left corner, x to the right, y downwards
User coordinate range: xmin..xmax (inclusive), ymin..ymax (inclusive); (0,0) lower left corner, x to the right, y upwards.

Transformation: user(ux, uy) to pixel(px, py):
(width = winWidth - 1, height = winHeight - 1)
px = a * ux + b
py = c * uy + d
with a = width / (xmax - xmin)
b = width * xmin / (xmin - xmax)
c = height / (ymin - ymax)
d = height * ymax / (ymax - ymin)

Inverse:
ux = (px - b) / a
uy = (py - d) / c

Because of the transformation from float to pixel coordinates, some rounding errors
may happen. If you need pixel accuracy, define a GPanel window with some user defined width x height,
e.g. GPanal(Size(501, 401)). Define then user coordinates in the range 0..width-1, 0..height-1, e.g.
setUserCoords(0, 500, 0, 400). Now pixels in the range 0..500 x 0..400 (inclusive) may be addressed with no
rounding errors. (This is a total of 501 x 401 pixels.)

If you prefer a coordinate system with the origin at the upper left corner, define the y-range in reverse
order, e.g. setUserCoords(0, 500, 400, 0).

WARNING: Because PyQt is not thread-safe, in principle all graphics drawings should be
executed in the GUI thread (for GPanel the main thread or a GUI callback).

Typical program:

from pygpanel import *

p = GPanel(0, 10, 0, 10)
for ypt in range(0, 11, 1):
    p.line(0, ypt, 10 - ypt, 0)
    time.sleep(0.1) # to see what happens
p.keep()

keep() is blocking and keeps the graphics panel open until the close button is hit or the
Python process terminates.

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
Constructs a GPanel and displays a non-resizable graphics window.
source code
 
_initUI(self) source code
 
_setDefaults(self) source code
 
clear(self)
Clears the graphics window and the offscreen buffer used by the window (fully paint with background color).
source code
 
erase(self)
Same as clear(), but lets the current graph cursor unganged.
source code
 
keep(self)
Blocks until the title bar's close button is hit.
source code
 
setTitle(self, title)
Sets the title in the window title bar.
source code
 
paintEvent(self, e) source code
 
setColor(self, *args)
Same as setPenColor()
source code
 
_toRGBA(self, *args) source code
 
setPenColor(self, *args)
Sets the current pen color.
source code
 
setPenSize(self, size)
Sets the current pen size (width) (>=1).
source code
 
toPixel(self, user)
Returns pixel coordinates (tuple) of given user coordinates (tupel).
source code
 
toPixelX(self, userX)
Returns pixel x-coordinate of given user x-coordinate.
source code
 
toPixelY(self, userY)
Returns pixel y-coordinate of given user y-coordinate.
source code
 
toPixelWidth(self, userWidth)
Returns pixel x-increment of given user x-increment (always positive).
source code
 
toPixelHeight(self, userHeight)
Returns pixel y-increment of given user y-increment (always positive).
source code
 
toUser(self, pixel)
Returns user coordinates (tuple) of given pixel coordinates (tuple).
source code
 
toUserX(self, pixelX)
Returns user x-coordinate of given pixel x-coordinate.
source code
 
toUserY(self, pixelY)
Returns user y-coordinate of given pixel y-coordinate.
source code
 
toUserWidth(self, pixelWidth)
Returns user x-increment of given pixel x-increment (always positive).
source code
 
toUserHeight(self, pixelHeight)
Returns user y-increment of given pixel y-increment (always positive).
source code
 
setUserCoords(self, xmin, xmax, ymin, ymax)
Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive).
source code
 
_adjust(self) source code
 
repaint(self)
Renders the offscreen buffer in the graphics window.
source code
 
enableRepaint(self, enable)
Enables/Disables automatic repaint in graphics drawing methods.
source code
 
line(self, x1, y1, x2, y2)
Draws a line with given user start and end coordinates and sets the graph cursor position to the end point.
source code
 
pos(self, x, y)
Sets the current graph cursor position to given user coordinates.
source code
 
move(self, x, y)
Sets the current graph cursor position to given user coordinates.
source code
 
draw(self, x, y)
Draws a line form current graph cursor position to (x, y).
source code
 
linePlot(self, *args)
Draws a line plot with given x,y data.
source code
 
getPos()
Returns a tuple with current graph cursor position (tuple, user coordinates).
source code
 
getPosX(self)
Returns the current graph cursor x-position (user coordinates).
source code
 
getPosY(self)
Returns the current graph cursor y-position (user coordinates).
source code
 
text(self, *args)
Draws a text at given position (user coordinates).
source code
 
addCloseListener(self, closeListener)
Registers the given function that is called when the title bar close button is hit.
source code
 
closeEvent(self, e) source code
 
setBgColor(self, *args)
Sets the background color.
source code
 
circle(self, radius)
Draws a circle with center at the current graph cursor position with given radius in horizontal window coordinates.
source code
 
fillCircle(self, radius)
Draws a filled circle with center at the current graph cursor position with given radius in horizontal window coordinates (fill color = pen color).
source code
 
ellipse(self, a, b)
Draws an ellipse with center at the current graph cursor position with given axes.
source code
 
fillEllipse(self, a, b)
Draws a filled ellipse with center at the current graph cursor position with given axes (fill color = pen color).
source code
 
rectangle(self, *args)
Draws a rectangle.
source code
 
fillRectangle(self, *args)
Draws a filled rectangle (fill color = pen color).
source code
 
polygon(self, *args)
Draws a polygon with given list of vertexes (list of [x, y] or (x, y)) (fill color = pen color).
source code
 
fillPolygon(self, *args)
Draws a filled polygon with given list of vertexes (list of [x, y] or (x, y)) (fill color = pen color).
source code
 
triangle(self, *args)
Draws a triangle with given corners.
source code
 
fillTriangle(self, *args)
Draws a filled triangle with given corners.
source code
 
arc(self, r, startAngle, spanAngle)
Draws a circle sector with center at the current graph cursor position, given radius and given start and span angles.
source code
 
fillArc(self, r, startAngle, spanAngle)
Draws a filled circle sector with center at the current graph cursor position, given radius and given start and span angles.
source code
 
chord(self, r, startAngle, spanAngle)
Draws a circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
source code
 
fillChord(self, r, startAngle, spanAngle)
Draws a filled circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
source code
 
startPath(self)
Starts recording the path vertexes.
source code
 
fillPath(self, color)
Closes the path started with startPath() and shows a filled polygon from the saved draw() positions with given color.
source code
 
showImage(self, *args)
Draws the picture with given file path or given image at given upper-left coordinates.
source code
 
point(self, *args)
Draws a single point with current pen size and pen color at given user coordinates.
source code
 
getPixelColor(self, *args)
Returns the RGBA color tuple of a pixel with given user coordinates.
source code
 
getPixelColorStr(self, *args)
Returns the X11 color string of a pixel with given user coordinates.
source code
 
_toColor(self, color) source code
 
fill(self, x, y, *args)
Fills the closed unicolored region with the inner point (x, y) with the replacement color (RGB, RGBA or X11 color string).
source code
 
getPainter(self)
Returns the QPainter reference used to draw into the offscreen buffer.
source code
 
getFullImage(self)
Returns the QImage reference of the whole graphics area.
source code
 
drawGrid(self, *args)
Draws a coordinate system with annotated axes.
source code
 
_drawGrid(self, xmin, xmax, ymin, ymax, xticks, yticks, color) source code
 
addMousePressListener(self, onMousePressed)
Registers a callback that is invoked when a mouse button is pressed.
source code
 
addMouseReleaseListener(self, onMouseReleased)
Registers a callback that is invoked when a mouse button is releases.
source code
 
addMouseDragListener(self, onMouseDragged)
Registers a callback that is invoked when the mouse is moved while a mouse button is pressed (drag).
source code
 
isLeftMouseButton(self)
Returns True, if the last mouse action was performed with the left mouse button.
source code
 
isRightMouseButton(self)
Returns True, if the last mouse action was performed with the right mouse button.
source code
 
addKeyPressListener(self, onKeyPressed)
Registers a callback that is invoked when a key is pressed (and the graphics window has the focus).
source code
 
addKeyReleaseListener(self, onKeyReleased)
Registers a callback that is invoked when a key is released (and the graphics window has the focus).
source code
 
getScreenWidth(self)
Returns the screen width in pixels.
source code
 
getScreenHeight(self)
Returns the screen height in pixels.
source code
 
setWindowCenter(self)
Sets the screen position to the center of the screen.
source code
 
setWindowPos(self, ulx, uly)
Sets the screen position of the graphics window.
source code
 
saveGraphics(self)
Saves the current graphics into a image buffer.
source code
 
restoreGraphics(self)
Restores the saved graphics from the image buffer.
source code
 
setXORMode(self, *args)
Performs pixel color XOR operation with the existing background pixel.
source code
 
setPaintMode(self)
Resets the drawing mode to standard (overwriting).
source code
 
windowPosition(self, ulx, uly)
Sets the screen position (pixel coordinates of upper left corner).
source code
 
windowCenter(self)
Sets the window to the center of the screen.
source code
 
arrow(self, *args)
Draws an arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] @param pt1 the starting point
source code
 
_arrow(self, pt0, pt1, size=10) source code
 
doubleArrow(self, *args)
Draws a double arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] (arrowheads on both ends).
source code
 
_doubleArrow(self, pt0, pt1, size=10) source code
 
_rotTri(self, tri, phi) source code
 
_transTri(self, tri, pt) source code
 
mousePressEvent(self, e) source code
 
mouseReleaseEvent(self, e) source code
 
mouseMoveEvent(self, e) source code
 
keyPressEvent(self, e) source code
 
keyReleaseEvent(self, e) source code
Static Methods [hide private]
 
loadImage(filename, pic_format=None)
Returns a QImage of the picture loaded from the given file.
source code
 
getPixelColorImg(image, xPix, yPix)
Returns a tuple with the RGBA values at given pixel position (pixel coordinates).
source code
 
scale(image, scaleFactor)
Returns a new QImage of the scaled picture of the given QImage.
source code
 
crop(image, x1, y1, x2, y2)
Returns a QImage of the sub-area of the given QImage.
source code
 
getDividingPoint(x1, y1, x2, y2, ratio)
Returns the tuple of user coordinates of the point on the line through the point pt1 = (x1, y1) and the point pt2 = (x2, y2) that is in distance ratio times the length from pt1 to pt2 from pt1.
source code
 
floodFill(pm, pt, oldColor, newColor)
Fills a bounded single-colored region with the given color.
source code
 
getRandomX11Color()
Returns a random X11 color string.
source code
 
getScreenCenter()
Returns x, y coordinates tuple of the screen's center point.
source code
Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

Constructs a GPanel and displays a non-resizable graphics window. Defaults with no parameter: Window size: 501x501 pixels Window title: "GPanel" User coordinates: 0, 1, 0, 1 Background color: white Pen color: black Pen size: 1

1 Parameter: Size(window_width, window_height) 4 Parameters: xmin, xmax, ymin, ymax

Parameters:
  • Size - a Size refererence that defines the width and height of the graphics window.

clear(self)

source code 

Clears the graphics window and the offscreen buffer used by the window (fully paint with background color). Sets the current graph cursor position to (0, 0). If enableRepaint(false) only clears the offscreen buffer.

keep(self)

source code 

Blocks until the title bar's close button is hit. Then cleans up the graphics system.

setTitle(self, title)

source code 

Sets the title in the window title bar.

Parameters:
  • title - the title text

setPenColor(self, *args)

source code 

Sets the current pen color. 1 parameter: - string value considered as X11 color string

  • list considered as [r, b, g] or [r, g, b, a]
  • tuple considered as (r, b, g) or (r, g, b, a)

3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA

setPenSize(self, size)

source code 

Sets the current pen size (width) (>=1). Returns the previous pen size.

Parameters:
  • width - the pen width >=1)

setUserCoords(self, xmin, xmax, ymin, ymax)

source code 

Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive).

Parameters:
  • xmin - the x coordinate (of a visible pixel) at left border
  • xmax - the x coordinate (of a visible pixel) at right border
  • ymin - the y coordinate (of a visible pixel) at bottom border
  • ymax - the y coordinate (of a visible pixel) at top border

enableRepaint(self, enable)

source code 

Enables/Disables automatic repaint in graphics drawing methods.

Parameters:
  • enable - if True, the automatic repaint is enabled; otherwise disabled

line(self, x1, y1, x2, y2)

source code 

Draws a line with given user start and end coordinates and sets the graph cursor position to the end point. Also with 2 parameters of type complex, list or tuple. 4 parameters: x1, y1, x2, y2 2 parameters: pt1, pt2 as complex/list/tuple

pos(self, x, y)

source code 

Sets the current graph cursor position to given user coordinates. (without drawing anything, same as move()).

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

move(self, x, y)

source code 

Sets the current graph cursor position to given user coordinates. (without drawing anything, same as pos()).

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

draw(self, x, y)

source code 

Draws a line form current graph cursor position to (x, y). Sets the graph cursor position to (x, y).

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

linePlot(self, *args)

source code 

Draws a line plot with given x,y data. 1 parameter: a list/tuple of subsequent data points [x, y] 2 parameters: two lists/tuples x, y of corresponding x-y pairs The graph cursor position remains unchanged.

text(self, *args)

source code 

Draws a text at given position (user coordinates). 1 parameter: at current graph cursor position 2 parameters: target point (comolex/list/tuple), text 3 parameters: x, y, text

addCloseListener(self, closeListener)

source code 

Registers the given function that is called when the title bar close button is hit. If a listener (!= None) is registered, the automatic closing is disabled. To close the window, call sys.exit().

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • closeListener - a callback function called when the close button is hit

setBgColor(self, *args)

source code 

Sets the background color. All drawings are erased and the current graph cursor is set to (0, 0).

1 parameter: - string value considered as X11 color string

  • list considered as [r, b, g] or [r, g, b, a]
  • tuple considered as (r, b, g) or (r, g, b, a)

3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA

circle(self, radius)

source code 

Draws a circle with center at the current graph cursor position with given radius in horizontal window coordinates.

Parameters:
  • radius - the radius of the circle

fillCircle(self, radius)

source code 

Draws a filled circle with center at the current graph cursor position with given radius in horizontal window coordinates (fill color = pen color).

Parameters:
  • radius - the radius of the circle

ellipse(self, a, b)

source code 

Draws an ellipse with center at the current graph cursor position with given axes.

Parameters:
  • a - the major ellipse axis
  • b - the minor ellipse axis

fillEllipse(self, a, b)

source code 

Draws a filled ellipse with center at the current graph cursor position with given axes (fill color = pen color).

Parameters:
  • a - the major ellipse axis
  • b - the minor ellipse axis

rectangle(self, *args)

source code 

Draws a rectangle.
2 parameters: Center at the current graph cursor position
              and given width and height.
4 parameters: Given diagonal

fillRectangle(self, *args)

source code 

Draws a filled rectangle (fill color = pen color).
2 parameters: Center at the current graph cursor position
              and given width and height.
4 parameters: Given diagonal

polygon(self, *args)

source code 

Draws a polygon with given list of vertexes (list of [x, y] or (x, y)) (fill color = pen color). 1 parameter: a list/tuple of the corners [x, y] or (x, y) 2 parameters: two lists/tuples x, y of corresponding x-y pairs

fillPolygon(self, *args)

source code 

Draws a filled polygon with given list of vertexes (list of [x, y] or (x, y)) (fill color = pen color). 1 parameter: a list/tuple of the corners [x, y] or (x, y) 2 parameters: two lists/tuples x, y of corresponding x-y pairs

triangle(self, *args)

source code 

Draws a triangle with given corners. 6 parameters: x1, y1, x2, y2, x3, y3 coordinates of corners 3 parameters: [x1, y1], [x2, y2], [x3, y3] lists of corners

fillTriangle(self, *args)

source code 

Draws a filled triangle with given corners. 6 parameters: x1, y1, x2, y2, x3, y3 coordinates of corners 3 parameters: [x1, y1], [x2, y2], [x3, y3] lists of corners

arc(self, r, startAngle, spanAngle)

source code 

Draws a circle sector with center at the current graph cursor position, given radius and given start and span angles.

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

fillArc(self, r, startAngle, spanAngle)

source code 

Draws a filled circle sector with center at the current graph cursor position, given radius and given start and span angles.

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

chord(self, r, startAngle, spanAngle)

source code 

Draws a circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

fillChord(self, r, startAngle, spanAngle)

source code 

Draws a filled circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).

Parameters:
  • radius - the radius of the arc
  • startAngle - starting angle in degrees, zero to east, positive counter-clockwise
  • spanAngle - span angle (sector angle) in degrees, positive counter-clockwise

startPath(self)

source code 

Starts recording the path vertexes. The positions of subsequent draw() operations are saved. The path is used to show a filled polygon when fillPath() is called.

showImage(self, *args)

source code 

Draws the picture with given file path or given image at given upper-left coordinates. 1st parameter: image path (string) or QImage reference 2nd, 3rd parameters: llx, lly (lower left corner in user coordinates)

point(self, *args)

source code 

Draws a single point with current pen size and pen color at given user coordinates. No params: draws a current graph cursor position

Parameters:
  • x - the x coordinate of the target point
  • y - the y coordinate of the target point
  • target - (alternative) the target point as complex, list or tuple

getPixelColor(self, *args)

source code 

Returns the RGBA color tuple of a pixel with given user coordinates. No params: Returns color at current graph cursor position.

getPixelColorStr(self, *args)

source code 

Returns the X11 color string of a pixel with given user coordinates. No params: Returns color at current graph cursor position.

fill(self, x, y, *args)

source code 

Fills the closed unicolored region with the inner point (x, y) with the replacement color (RGB, RGBA or X11 color string). The old color is not given, the color of the current (x, y) pixel is taken.

Parameters:
  • x - the x coordinate of the inner point
  • y - the y coordinate of the inner point
  • color - the old color (RGB list/tuple or X11 color string) (may be omitted)
  • replacementColor - the new color (RGB list/tuple or X11 color string)

drawGrid(self, *args)

source code 

Draws a coordinate system with annotated axes. (You must increase the user coordinate system at least 10% in both directions.) drawGrid(x, y): Grid with 10 ticks in range 0..x, 0..y. Label text depends if x, y or int or float drawGrid(x, y, color): same with given grid color drawGrid(x1, x2, y1, y2): same with given span x1..x2, y1..y2 drawGrid(x1, x2, y1, y2, color): same with given grid color drawGrid(x1, x2, y1, y2, x3, y3): same with given number of ticks x3, y3 in x- and y-direction

addMousePressListener(self, onMousePressed)

source code 

Registers a callback that is invoked when a mouse button is pressed. Use isLeftMouseButton() or isRightMouseButton() to check which button used.

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onMousePressed - a callback function called when a mouse button is pressed

addMouseReleaseListener(self, onMouseReleased)

source code 

Registers a callback that is invoked when a mouse button is releases. Use isLeftMouseButton() or isRightMouseButton() to check which button used.

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onMouseReleased - a callback function called when a mouse button is released

addMouseDragListener(self, onMouseDragged)

source code 

Registers a callback that is invoked when the mouse is moved while a mouse button is pressed (drag).

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onMouseDragged - a callback function called when the moused is dragged

addKeyPressListener(self, onKeyPressed)

source code 

Registers a callback that is invoked when a key is pressed (and the graphics window has the focus).

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onKeyPressed - a callback function called when a key is pressed

addKeyReleaseListener(self, onKeyReleased)

source code 

Registers a callback that is invoked when a key is released (and the graphics window has the focus).

KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.

Parameters:
  • onKeyReleased - a callback function called when a key is released

setWindowPos(self, ulx, uly)

source code 

Sets the screen position of the graphics window.

Parameters:
  • ulx - the upper left corner's x-coordinate
  • ulx - the upper left corner's y-coordinate

saveGraphics(self)

source code 

Saves the current graphics into a image buffer. Use restoreGraphics() to restore it.

restoreGraphics(self)

source code 

Restores the saved graphics from the image buffer. Use saveGraphics() to save it.

setXORMode(self, *args)

source code 

Performs pixel color XOR operation with the existing background pixel. Be aware that if the background is white, drawing with a white pen shows a black pixel. (Parameter not used, for TigerJython compatibility)

arrow(self, *args)

source code 

Draws an arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] @param pt1 the starting point

Parameters:
  • pt2 - the ending point (where is the arrowhead)
  • size - the length of the arrowhead's triangle (in pixels, default: 10)

    Overloaded versions: points as list/tuple or x, y coordinates

doubleArrow(self, *args)

source code 

Draws a double arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] (arrowheads on both ends). @param pt1 one end of the arrow

Parameters:
  • pt2 - the other end of the arrow
  • size - the length of the arrowhead's triangle (in pixels, default: 10)

    Overloaded versions: points as list/tuple or x, y coordinates

loadImage(filename, pic_format=None)
Static Method

source code 

Returns a QImage of the picture loaded from the given file. For pic_format = None, the picture format is guessed from the file data.

Parameters:
  • pic_format - format of picture, supported: "None" (default), "GIF", "JPG", "BMP", "PNG", "PBM", "PGM", "PPM", "TIFF", "XBM" "XPM".

getPixelColorImg(image, xPix, yPix)
Static Method

source code 

Returns a tuple with the RGBA values at given pixel position (pixel coordinates).

Parameters:
  • image - the QImage reference
  • xPix - the pixel x-coordinate
  • yPix - the pixel y-coordinate

scale(image, scaleFactor)
Static Method

source code 

Returns a new QImage of the scaled picture of the given QImage.

Parameters:
  • image - the original QImage reference
  • scaleFactor - the scale factor

crop(image, x1, y1, x2, y2)
Static Method

source code 

Returns a QImage of the sub-area of the given QImage.

Parameters:
  • image - the given QImage reference
  • xPix - the pixel ulx-coordinate
  • yPix - the pixel uly-coordinate

getDividingPoint(x1, y1, x2, y2, ratio)
Static Method

source code 

Returns the tuple of user coordinates of the point on the line through the point pt1 = (x1, y1) and the point pt2 = (x2, y2) that is in distance ratio times the length from pt1 to pt2 from pt1. For ratio < 0 the point is in the opposite direction. 3 parameteters: pt1, pt2 (complex/list/tuple), ratio 5 parameteters: x1, y1, x2, y2, ratio

floodFill(pm, pt, oldColor, newColor)
Static Method

source code 

Fills a bounded single-colored region with the given color. The given point is part of the region and used to specify it. @param pm the pixmap containing the connected region @param pt a point inside the region @param oldColor the old color of the region (RGB list/tuple) @param newColor the new color of the region (RGB list/tuple) @return a new qImage with the transformed region