The Paynter
Module¶
The core module of the PaYnter project, this class will do most of the work when you use this library.
The Paynter
Class¶
-
class
paynter.paynter.
Paynter
¶ This class is the main object of the library and the one that will draw everything you ask. To create this class you can use the default constructor.
from paynter import * P = Paynter()
-
Paynter.
renderImage
(output='', show=True)¶ Renders the
Image
and outputs the final PNG file.Parameters: - output – A string with the output file path, can be empty if you don’t want to save the final image.
- show – A boolean telling the system to display the final image after the rendering is done.
Return type: Nothing.
Getters and setters¶
-
Paynter.
setColor
(color)¶ Sets the current
Color
to use.Parameters: color – The Color
to use.Return type: Nothing.
-
Paynter.
setColorAlpha
(fixed=None, proportional=None)¶ Change the alpha of the current
Color
.Parameters: - fixed – Set the absolute 0-1 value of the alpha.
- proportional – Set the relative value of the alpha (Es: If the current alpha is 0.8, a proportional value of 0.5 will set the final value to 0.4).
Return type: Nothing.
-
Paynter.
getColorAlpha
()¶ Retrieve the alpha of the current
Color
.Return type: A float 0-1 value of the current Color
alpha.
-
Paynter.
getBrushSize
()¶ Retrieve the size of the current
Brush
.Return type: An integer value of the current Brush
size in pixels.
-
Paynter.
swapColors
()¶ Swaps the current
Color
with the secondaryColor
.Return type: Nothing.
-
Paynter.
setBrush
(b, resize=0, proportional=None)¶ Sets the size of the current
Brush
.Parameters: - brush – The
Brush
object to use as a brush. - resize – An optional absolute value to resize the brush before using it.
- proportional – An optional relative float 0-1 value to resize the brush before using it.
Return type: Nothing.
- brush – The
-
Paynter.
setMirrorMode
(mirror)¶ Sets the mirror mode to use in the next operation.
Parameters: mirror – A string object with one of these values : ‘’, ‘h’, ‘v’, ‘hv’. “h” stands for horizontal mirroring, while “v” stands for vertical mirroring. “hv” sets both at the same time. Return type: Nothing.
Drawing functions¶
-
Paynter.
drawPoint
(x, y, silent=True)¶ Draws a point on the current
Layer
with the currentBrush
. Coordinates are relative to the original layer size WITHOUT downsampling applied.Parameters: - x1 – Point X coordinate.
- y1 – Point Y coordinate.
Return type: Nothing.
-
Paynter.
drawLine
(x1, y1, x2, y2, silent=False)¶ Draws a line on the current
Layer
with the currentBrush
. Coordinates are relative to the original layer size WITHOUT downsampling applied.Parameters: - x1 – Starting X coordinate.
- y1 – Starting Y coordinate.
- x2 – End X coordinate.
- y2 – End Y coordinate.
Return type: Nothing.
-
Paynter.
drawPath
(pointList)¶ Draws a series of lines on the current
Layer
with the currentBrush
. No interpolation is applied to these point anddrawLine()
will be used to connect all the points lineraly. Coordinates are relative to the original layer size WITHOUT downsampling applied.Parameters: pointList – A list of point like [(0, 0), (100, 100), (100, 200)]
.Return type: Nothing.
-
Paynter.
drawClosedPath
(pointList)¶ Draws a closed series of lines on the current
Layer
with the currentBrush
. No interpolation is applied to these point anddrawLine()
will be used to connect all the points lineraly. Coordinates are relative to the original layer size WITHOUT downsampling applied.Parameters: pointList – A list of point like [(0, 0), (100, 100), (100, 200)]
.Return type: Nothing.
-
Paynter.
drawRect
(x1, y1, x2, y2, angle=0)¶ Draws a rectangle on the current
Layer
with the currentBrush
. Coordinates are relative to the original layer size WITHOUT downsampling applied.Parameters: - x1 – The X of the top-left corner of the rectangle.
- y1 – The Y of the top-left corner of the rectangle.
- x2 – The X of the bottom-right corner of the rectangle.
- y2 – The Y of the bottom-right corner of the rectangle.
- angle – An angle (in degrees) of rotation around the center of the rectangle.
Return type: Nothing.
-
Paynter.
fillLayerWithColor
(color)¶ Fills the current
Layer
with the currentColor
.Parameters: color – The Color
to apply to the layer.Return type: Nothing.
-
Paynter.
addBorder
(width, color=None)¶ Add a border to the current
Layer
.Parameters: - width – The width of the border.
- color – The
Color
of the border, currentColor
is the default value.
Return type: Nothing.
Layer
operations¶
-
Paynter.
newLayer
(effect='')¶ Creates a new
Layer
to the currentImage
.Parameters: effect – A string with the blend mode for that layer that will be used when during the rendering process. The accepted values are: 'soft_light','lighten','screen','dodge','addition','darken','multiply','hard_light','difference','subtract','grain_extract','grain_merge','divide','overlay'
.Return type: Nothing.
-
Paynter.
setActiveLayerEffect
(effect)¶ Changes the effect of the current active
Layer
.Parameters: output – A string with the one of the blend modes listed in newLayer()
.Return type: Nothing.
-
Paynter.
duplicateActiveLayer
()¶ Duplicates the current active
Layer
.Return type: Nothing.