gdi

Functions for working with graphics. Most of them are wrappers for Gdi and GdiPlus methods.

Methods

static CreateImage(w, h) → {GdiBitmap}

Parameters:
Name Type Description
w number
h number
Returns:
GdiBitmap

static Font(name, size_px, styleopt)nullable {GdiFont}

Performance note: avoid using inside `on_paint`.
Performance note II: try caching and reusing `GdiFont` objects, since the maximum amount of such objects is hard-limited by Windows. `GdiFont` creation will fail after reaching this limit.
Parameters:
Name Type Attributes Default Description
name string
size_px number See Helper.js > Point2Pixel function for conversions
style number <optional>
0 See Flags.js > FontStyle
Returns:
GdiFont - null, if font is not present.

static Image(path)nullable {GdiBitmap}

Load image from file.

Performance note: consider using gdi.LoadImageAsync or gdi.LoadImageAsyncV2 if there are a lot of images to load or if the image is big.
Parameters:
Name Type Description
path string
Returns:
GdiBitmap - null, if image failed to load.
Example
let img = gdi.Image('e:\\images folder\\my_image.png');

static LoadImageAsync(window_id, path) → {number}

Load image from file asynchronously.
Parameters:
Name Type Description
window_id number unused
path string
Returns:
number - a unique id, which is used in on_load_image_done.
Example
// See `samples/basic/LoadImageAsync.js`

static LoadImageAsyncV2(window_id, path) → {Promise.<?GdiBitmap>}

Load image from file asynchronously. Returns a `Promise` object, which will be resolved when image loading is done.
Parameters:
Name Type Description
window_id number unused
path string
Returns:
Promise.<?GdiBitmap>
Example
// See `samples/basic/LoadImageAsyncV2.js`