Graphics

EsColorBlend

uint32_t EsColorBlend(uint32_t under, uint32_t over, bool fullAlpha);

Blends the over color onto the under color and returns the result.

EsColorIsLight

bool EsColorIsLight(uint32_t color);

Returns true if you should black to draw atop the color.

EsColorConvertToRGB

uint32_t EsColorConvertToRGB(float h, float s, float v);

0 <= hue < 6; 0 <= saturation <= 1; 0 <= value <= 1.

EsColorConvertToHSV

bool EsColorConvertToHSV(uint32_t color, float *h, float *s, float *v);

Converts a color to hue, saturation, and value. Returns false if the color is gray.

EsColorParse

uint32_t EsColorParse(STRING string);

Parses a hexadecimal color string. Supports 3, 4, 5, 6, or 8 hex digits.

EsColorInterpolate

uint32_t EsColorInterpolate(uint32_t from, uint32_t to, float progress);

Linearly interpolates between the two colors by progress.

EsDrawBitmap

void EsDrawBitmap(EsPainter *painter, EsRectangle region, const uint32_t *bits, uintptr_t stride, uint16_t mode);

OR mode with alpha.

EsDrawBitmapScaled

void EsDrawBitmapScaled(EsPainter *painter, EsRectangle destinationRegion, EsRectangle sourceRegion, const uint32_t *bits, uintptr_t stride, uint16_t alpha);

Set alpha to 0xFFFF if source is opaque.

EsDrawBlock

void EsDrawBlock(EsPainter *painter, EsRectangle bounds, EsDeviceColor mainColor);

Fills the rectangle with a solid color. Does nothing if the color is fully transparent.

EsDrawClear

void EsDrawClear(EsPainter *painter, EsRectangle bounds);

Sets every pixel in the rectangle to zero.

EsDrawContent

void EsDrawContent(EsPainter *painter, EsElement *element, EsRectangle rectangle, STRING text, uint32_t iconID = 0, EsDrawContentFlags flags = ES_FLAGS_DEFAULT, const EsTextSelection *selectionProperties = ES_NULL);

Draws the text and optional icon of a themed element using the current style.

EsDrawInvert

void EsDrawInvert(EsPainter *painter, EsRectangle bounds);

Inverts the color of every pixel in the rectangle.

EsDrawLine

void EsDrawLine(EsPainter *painter, const float *vertices, size_t vertexCount, EsDeviceColor color, float width, EsDrawLineFlags flags);

Vertices are pairs of x,y coordinates.

EsDrawRectangle

void EsDrawRectangle(EsPainter *painter, EsRectangle bounds, EsDeviceColor mainColor, EsDeviceColor borderColor, EsRectangle borderSize);

Draws a rectangle with a solid interior and a border of the given size.

EsDrawRoundedRectangle

void EsDrawRoundedRectangle(EsPainter *painter, EsRectangle bounds, EsDeviceColor mainColor, EsDeviceColor borderColor, EsRectangle borderSize, EsCornerRadii cornerRadii);

Draws a rectangle with rounded corners.

EsDrawStandardIcon

bool EsDrawStandardIcon(EsPainter *painter, uint32_t id, int size, EsRectangle region, EsDeviceColor color);

Draws a standard icon, centered in the region and tinted with color. Returns false if the icon does not exist.

EsDrawPaintTarget

void EsDrawPaintTarget(EsPainter *painter, EsPaintTarget *source, EsRectangle destinationRegion, EsRectangle sourceRegion, uint8_t alpha);

Draws one paint target onto another. Scales the source to fit the destination.

EsDrawText

void EsDrawText(EsPainter *painter, EsTextPlan *plan, EsRectangle bounds, const EsRectangle *clip = ES_NULL, const EsTextSelection *selectionProperties = ES_NULL);

Draws a text plan within the given bounds. Optionally clips to clip and highlights the selection.

EsDrawTextSimple

void EsDrawTextSimple(EsPainter *painter, EsElement *element, EsRectangle bounds, STRING stringBytes, EsTextStyle style, uint32_t flags = ES_FLAGS_DEFAULT);

Creates a single-use text plan and draws the text with the given style.

EsDrawTextThemed

void EsDrawTextThemed(EsPainter *painter, EsElement *element, EsRectangle bounds, STRING stringBytes, EsStyleID style, uint32_t flags = ES_FLAGS_DEFAULT);

The style must be one of the ES_STYLE_TEXT_... styles.

EsDrawTextLayers

void EsDrawTextLayers(EsPainter *painter, EsTextPlan *plan, EsRectangle bounds, const EsTextSelection *selectionProperties = ES_NULL);

Draws the themed text layers of a text plan.

EsDrawVectorFile

void EsDrawVectorFile(EsPainter *painter, EsRectangle bounds, const void *data, size_t dataBytes);

Draws a vector icon from memory. data is the icon file data.

EsIconIDFromString

uint32_t EsIconIDFromString(STRING string = BLANK_STRING);

Returns the standard icon ID whose name matches the string. Returns 0 if there is no match.

EsIconIDFromDriveType

uint32_t EsIconIDFromDriveType(uint8_t driveType);

Returns the standard icon ID for the given drive type.

EsImageLoad

uint8_t *EsImageLoad(const void *file, size_t fileSize, uint32_t *width, uint32_t *height, int imageChannels);

Decodes a PNG or JPEG image from memory. Builds without stb_image support only PNG. imageChannels must be 4. PNG files with invalid chunk CRC-32 checksums are rejected. Returns the pixels in 0xAARRGGBB format, or NULL on failure. Free with EsHeapFree.

EsPainterBoundsClient

EsRectangle EsPainterBoundsClient(EsPainter *painter);

Returns the full painting area of the painter.

EsPainterBoundsInset

EsRectangle EsPainterBoundsInset(EsPainter *painter);

Returns the painting area, inset by the style insets.

EsPaintTargetClear

void EsPaintTargetClear(EsPaintTarget *target);

Sets every pixel of the paint target to zero.

EsPaintTargetEndDirectAccess

void EsPaintTargetEndDirectAccess(EsPaintTarget *target);

Ends direct access to the paint target bits.

EsPaintTargetStartDirectAccess

void EsPaintTargetStartDirectAccess(EsPaintTarget *target, uint32_t **bits, size_t *width, size_t *height, size_t *stride);

Returns the paint target bits for direct access. Do not use drawing functions until calling EsPaintTargetEndDirectAccess.

EsPaintTargetCreate

EsPaintTarget *EsPaintTargetCreate(size_t width, size_t height, bool hasAlphaChannel);

Allocates a new paint target. Returns NULL if there is not enough memory. Free with EsPaintTargetDestroy.

EsPaintTargetCreateFromBitmap

EsPaintTarget *EsPaintTargetCreateFromBitmap(uint32_t *bits, size_t width, size_t height, bool hasAlphaChannel);

Do not access the bits again until calling EsPaintTargetDestroy!

EsPaintTargetGetSize

void EsPaintTargetGetSize(EsPaintTarget *target, size_t *width, size_t *height);

Returns the width and height of the paint target.

EsPaintTargetDestroy

void EsPaintTargetDestroy(EsPaintTarget *target);

Frees the paint target and its bits.

EsTextPlanCreate

EsTextPlan *EsTextPlanCreate(EsElement *element, EsTextPlanProperties *properties, EsRectangle bounds, const char *string, const EsTextRun *textRuns, size_t textRunCount);

textRuns should point to an array of (textRunCount + 1) EsTextRuns; the last one should have its offset set to the total number of bytes in the string. The passed string must remain valid until the plan is destroyed. The element is used for UI scaling calculations.

EsTextPlanGetWidth

int EsTextPlanGetWidth(EsTextPlan *plan);

Returns the width of the text plan, in pixels.

EsTextPlanGetHeight

int EsTextPlanGetHeight(EsTextPlan *plan);

Returns the height of the text plan, in pixels.

EsTextPlanGetLineCount

size_t EsTextPlanGetLineCount(EsTextPlan *plan);

Returns the number of lines in the text plan.

EsTextPlanDestroy

void EsTextPlanDestroy(EsTextPlan *plan);

Frees a text plan created with EsTextPlanCreate.

EsTextPlanReplaceStyleRenderProperties

void EsTextPlanReplaceStyleRenderProperties(EsTextPlan *plan, const EsTextStyle *style);

Only render properties - like color or underline, but not font weight - will be replaced.

EsRichTextParse

void EsRichTextParse(const char *inString, ptrdiff_t inStringBytes, char **outString, EsTextRun **outTextRuns, size_t *outTextRunCount, EsTextStyle *baseStyle);

Parses rich text markup into a plain string and an array of text runs. Free both with EsHeapFree.

EsFontDatabaseEnumerate

EsFontInformation *EsFontDatabaseEnumerate(size_t *count);

Returns an array of all fonts in the database. Returns NULL on failure. Free with EsHeapFree.

EsFontDatabaseLookupByName

bool EsFontDatabaseLookupByName(STRING name, EsFontInformation *information);

Returns false if the font does not exist in the database.

EsFontDatabaseLookupByID

bool EsFontDatabaseLookupByID(EsFontFamily id, EsFontInformation *information);

Returns false if the font does not exist in the database.

EsFontDatabaseInsertFile

EsFontFamily EsFontDatabaseInsertFile(const EsFontInformation *information, EsFileStore *store);

Don't set the `id` field in EsFontInformation. The assigned ID will be returned. If nameBytes is 0, then the system will not try to match it with an existing font family. Set the corresponding bit in availableWeightsNormal/availableWeightsItalic for the file being added. The request is ignored if the specific variant is already in the database.

EsStyleIntern

EsStyleID EsStyleIntern(const EsStyle *style);

Once a style has been interned, it cannot be removed. Duplicate styles will be given the same ID.