Interface IPluginPainter
- Namespace
- AcDream.Plugin.Abstractions
- Assembly
- AcDream.Plugin.Abstractions.dll
What a canvas's paint callback draws with. Coordinates are pixels from the canvas's own top-left corner, y down; everything is clipped to the canvas. The painter is valid only for the duration of the paint callback: keeping it and drawing later throws.
Text is drawn in the client's own interface font, at its one size, which is why there is no font or size to choose. Every clip pushed during a paint must be popped before it returns.
public interface IPluginPainter
Properties
Height
The canvas's height in pixels.
int Height { get; }
Property Value
Width
The canvas's width in pixels.
int Width { get; }
Property Value
Methods
Clear(PluginColor)
Fills the whole canvas with one colour; transparent black clears it.
void Clear(PluginColor color)
Parameters
colorPluginColorThe colour to fill with.
DrawImage(PluginImage, PluginRect, PluginColor)
Draws an image stretched over a rectangle.
void DrawImage(PluginImage image, PluginRect destination, PluginColor tint)
Parameters
imagePluginImageAn image from IPluginImages; a released or invalid image draws nothing.
destinationPluginRectThe rectangle the image fills.
tintPluginColorA colour the image is multiplied by; White leaves it unchanged.
DrawImageTransformed(PluginImage, PluginRect, PluginColor, double, PluginPoint, double, double)
Draws an image over a rectangle after scaling and turning that rectangle about a pivot. The pivot is measured in pixels from the rectangle's own top-left corner, so (0, 0) turns the image about its top-left and (width / 2, height / 2) about its middle. Rotation is clockwise on screen.
void DrawImageTransformed(PluginImage image, PluginRect destination, PluginColor tint, double rotationRadians, PluginPoint pivot, double scaleX = 1, double scaleY = 1)
Parameters
imagePluginImageAn image from IPluginImages; a released or invalid image draws nothing.
destinationPluginRectThe rectangle the image would fill unturned and unscaled.
tintPluginColorA colour the image is multiplied by; White leaves it unchanged.
rotationRadiansdoubleHow far to turn the rectangle about the pivot, in radians, clockwise on screen.
pivotPluginPointThe point, in pixels from the rectangle's top-left corner, the rectangle turns and scales about.
scaleXdoubleHow much to stretch the rectangle sideways about the pivot; 1 leaves it.
scaleYdoubleHow much to stretch the rectangle vertically about the pivot; 1 leaves it.
DrawLine(PluginPoint, PluginPoint, PluginColor, float)
Draws a straight line, centred on the segment, with square ends.
void DrawLine(PluginPoint from, PluginPoint to, PluginColor color, float thickness = 1)
Parameters
fromPluginPointWhere the line starts.
toPluginPointWhere the line ends.
colorPluginColorThe line's colour.
thicknessfloatThe line's width in pixels.
DrawText(string, PluginPoint, PluginColor, bool)
Draws one line of text with its top-left corner at a position.
void DrawText(string text, PluginPoint position, PluginColor color, bool outline = false)
Parameters
textstringThe text to draw.
positionPluginPointWhere the text's top-left corner goes.
colorPluginColorThe text colour.
outlineboolWhether to draw a dark outline around the glyphs, as the client does over the world.
FillRect(PluginRect, PluginColor)
Fills a rectangle.
void FillRect(PluginRect rect, PluginColor color)
Parameters
rectPluginRectThe rectangle to fill.
colorPluginColorThe fill colour.
MeasureText(string)
How much room one line of text takes when drawn.
PluginSize MeasureText(string text)
Parameters
textstringThe text to measure.
Returns
- PluginSize
The text's width and the font's line height, in pixels.
PopClip()
Undoes the most recent PushClip(PluginRect).
void PopClip()
PushClip(PluginRect)
Restricts what follows to a rectangle, intersected with whatever clip is already in force. Every push must be matched by a PopClip() before the paint callback returns.
void PushClip(PluginRect rect)
Parameters
rectPluginRectThe rectangle to clip to.
StrokeRect(PluginRect, PluginColor, float)
Draws a rectangle's outline, inside its edges.
void StrokeRect(PluginRect rect, PluginColor color, float thickness = 1)
Parameters
rectPluginRectThe rectangle to outline.
colorPluginColorThe outline colour.
thicknessfloatThe outline's width in pixels.