Table of Contents

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

int

Width

The canvas's width in pixels.

int Width { get; }

Property Value

int

Methods

Clear(PluginColor)

Fills the whole canvas with one colour; transparent black clears it.

void Clear(PluginColor color)

Parameters

color PluginColor

The colour to fill with.

DrawImage(PluginImage, PluginRect, PluginColor)

Draws an image stretched over a rectangle.

void DrawImage(PluginImage image, PluginRect destination, PluginColor tint)

Parameters

image PluginImage

An image from IPluginImages; a released or invalid image draws nothing.

destination PluginRect

The rectangle the image fills.

tint PluginColor

A 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

image PluginImage

An image from IPluginImages; a released or invalid image draws nothing.

destination PluginRect

The rectangle the image would fill unturned and unscaled.

tint PluginColor

A colour the image is multiplied by; White leaves it unchanged.

rotationRadians double

How far to turn the rectangle about the pivot, in radians, clockwise on screen.

pivot PluginPoint

The point, in pixels from the rectangle's top-left corner, the rectangle turns and scales about.

scaleX double

How much to stretch the rectangle sideways about the pivot; 1 leaves it.

scaleY double

How 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

from PluginPoint

Where the line starts.

to PluginPoint

Where the line ends.

color PluginColor

The line's colour.

thickness float

The 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

text string

The text to draw.

position PluginPoint

Where the text's top-left corner goes.

color PluginColor

The text colour.

outline bool

Whether 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

rect PluginRect

The rectangle to fill.

color PluginColor

The fill colour.

MeasureText(string)

How much room one line of text takes when drawn.

PluginSize MeasureText(string text)

Parameters

text string

The 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

rect PluginRect

The 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

rect PluginRect

The rectangle to outline.

color PluginColor

The outline colour.

thickness float

The outline's width in pixels.