GdiGraphics

Classes

MeasureStringInfo

Methods

CalcTextHeight(str, font) → {number}

Calculates text height for GdiGraphics#GdiDrawText.
Note: this will only calculate the text height of one line.
Parameters:
Name Type Description
str string
font GdiFont
Returns:
number

CalcTextWidth(str, font) → {number}

Calculates text width for GdiGraphics#GdiDrawText.
Parameters:
Name Type Description
str string
font GdiFont
Returns:
number

DrawEllipse(x, y, w, h, line_width, colour)

Parameters:
Name Type Description
x number
y number
w number
h number
line_width number
colour number

DrawImage(img, dstX, dstY, dstW, dstH, srcX, srcY, srcW, srcH, angleopt, alphaopt)

Parameters:
Name Type Attributes Default Description
img GdiBitmap
dstX number
dstY number
dstW number
dstH number
srcX number
srcY number
srcW number
srcH number
angle float <optional>
0
alpha number <optional>
255 Valid values 0-255.

DrawLine(x1, y1, x2, y2, line_width, colour)

Parameters:
Name Type Description
x1 number
y1 number
x2 number
y2 number
line_width number
colour number

DrawPolygon(colour, line_width, points)

Parameters:
Name Type Description
colour number
line_width number
points Array.<Array.<number>>

DrawRect(x, y, w, h, line_width, colour)

Parameters:
Name Type Description
x number
y number
w number
h number
line_width number
colour number

DrawRoundRect(x, y, w, h, arc_width, arc_height, line_width, colour)

Parameters:
Name Type Description
x number
y number
w number
h number
arc_width number
arc_height number
line_width number
colour number

DrawString(str, font, colour, x, y, w, h, flagsopt)

Should be only used when GdiGraphics#GdiDrawText is not applicable.
Parameters:
Name Type Attributes Default Description
str string
font GdiFont
colour number
x number
y number
w number
h number
flags number <optional>
0 See Flags.js > StringFormatFlags

EstimateLineWrap(str, font, max_width) → {Array.<Array>}

Parameters:
Name Type Description
str string
font GdiFont
max_width number
Returns:
Array.<Array> - index | meaning
[0] text line 1
[1] width of text line 1 (in pixel)
[2] text line 2
[3] width of text line 2 (in pixel)
...
[2n + 2] text line n
[2n + 3] width of text line n (px)

FillEllipse(x, y, w, h, colour)

Parameters:
Name Type Description
x number
y number
w number
h number
colour number

FillGradRect(x, y, w, h, angle, colour1, colour2, focusopt)

Note: this may appear buggy depending on rectangle size. The easiest fix is to adjust the "angle" by a degree or two.
Parameters:
Name Type Attributes Default Description
x number
y number
w number
h number
angle float
colour1 number
colour2 number
focus float <optional>
1.0 Specify where the centred colour will be at its highest intensity. Valid values between 0 and 1.

FillPolygon(colour, fillmode, points)

Parameters:
Name Type Description
colour number
fillmode number 0 alternate, 1 winding.
points Array.<Array.<number>>

FillRoundRect(x, y, w, h, arc_width, arc_height, colour)

Parameters:
Name Type Description
x number
y number
w number
h number
arc_width number
arc_height number
colour number

FillSolidRect(x, y, w, h, colour)

Parameters:
Name Type Description
x number
y number
w number
h number
colour number

GdiAlphaBlend(img, dstX, dstY, dstW, dstH, srcX, srcY, srcW, srcH, alphaopt)

Parameters:
Name Type Attributes Default Description
img GdiRawBitmap
dstX number
dstY number
dstW number
dstH number
srcX number
srcY number
srcW number
srcH number
alpha number <optional>
255 Valid values 0-255.

GdiDrawBitmap(img, dstX, dstY, dstW, dstH, srcX, srcY, srcW, srcH)

Always faster than GdiGraphics#DrawImage, does not support alpha channel.
Parameters:
Name Type Description
img GdiRawBitmap
dstX number
dstY number
dstW number
dstH number
srcX number
srcY number
srcW number
srcH number

GdiDrawText(str, font, colour, x, y, w, h, formatopt) → {Array.<number>}

Provides faster and better rendering than GdiGraphics#DrawString.

Do not use this to draw text on transparent background or with GdiGraphics other than the one passed in on_paint callback: this will result in visual artifacts caused by ClearType hinting.
Use GdiGraphics#DrawString instead in such cases.

To calculate text dimensions use GdiGraphics#CalcTextHeight, GdiGraphics#CalcTextWidth or DT_CALCRECT flag.

Note: uses special rules for `&` character by default, which consumes the `&` and causes the next character to be underscored. This behaviour can be changed (or disabled) via `format` parameter.
Parameters:
Name Type Attributes Default Description
str string
font GdiFont
colour number
x number
y number
w number
h number
format number <optional>
0 See Flags.js > DT_*
Returns:
Array.<number> - index | meaning
[0] left (DT_CALCRECT)
[1] top (DT_CALCRECT)
[2] right (DT_CALCRECT)
[3] bottom (DT_CALCRECT)
[4] characters drawn

MeasureString(str, font, x, y, w, h, flagsopt) → {MeasureStringInfo}

Calculates text dimensions for GdiGraphics#DrawString.
Parameters:
Name Type Attributes Default Description
str string
font GdiFont
x number
y number
w number
h number
flags number <optional>
0 See Flags.js > StringFormatFlags
Returns:
MeasureStringInfo

SetInterpolationMode(modeopt)

Parameters:
Name Type Attributes Default Description
mode number <optional>
0 See Flags.js > InterpolationMode

SetSmoothingMode(modeopt)

Parameters:
Name Type Attributes Default Description
mode number <optional>
0 See Flags.js > SmoothingMode

SetTextRenderingHint(modeopt)

Parameters:
Name Type Attributes Default Description
mode number <optional>
0 See Flags.js > TextRenderingHint