### Start New Path (Nim) Source: https://treeform.github.io/pixie/pixie/contexts Starts a new path by emptying the list of sub-paths. This is an inline procedure that does not raise errors. ```nim proc beginPath(ctx: Context) {.inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Path Operations Source: https://treeform.github.io/pixie/pixie/contexts Functions for creating and manipulating drawing paths, including starting, closing, and adding segments. ```APIDOC ## Path Operations ### beginPath Starts a new path. ### Method GET ### Endpoint /pixie/contexts/beginPath ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. ### Request Example ```json { "ctx": "context_object" } ``` ### bezierCurveTo Adds a cubic Bézier curve to the current path. ### Method GET ### Endpoint /pixie/contexts/bezierCurveTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **cp1, cp2, to** (Vec2) - Required - The control points and the end point of the curve. ### Request Example ```json { "ctx": "context_object", "cp1": {"x": 10, "y": 10}, "cp2": {"x": 20, "y": 20}, "to": {"x": 30, "y": 30} } ``` ### bezierCurveTo (alternative) Adds a cubic Bézier curve to the current path using coordinates. ### Method GET ### Endpoint /pixie/contexts/bezierCurveTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **cp1x, cp1y, cp2x, cp2y, x, y** (float32) - Required - The coordinates of the control points and the end point of the curve. ### Request Example ```json { "ctx": "context_object", "cp1x": 10, "cp1y": 10, "cp2x": 20, "cp2y": 20, "x": 30, "y": 30 } ``` ### closePath Closes the current path by connecting the last point to the first point. ### Method GET ### Endpoint /pixie/contexts/closePath ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. ### Request Example ```json { "ctx": "context_object" } ``` ### lineTo Adds a straight line segment to the current path. ### Method GET ### Endpoint /pixie/contexts/lineTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **v** (Vec2) - Required - The end point of the line. ### Request Example ```json { "ctx": "context_object", "v": {"x": 10, "y": 10} } ``` ### lineTo (alternative) Adds a straight line segment to the current path using coordinates. ### Method GET ### Endpoint /pixie/contexts/lineTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **x, y** (float32) - Required - The coordinates of the end point of the line. ### Request Example ```json { "ctx": "context_object", "x": 10, "y": 10 } ``` ### moveTo Moves the current point of the path without drawing a line. ### Method GET ### Endpoint /pixie/contexts/moveTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **v** (Vec2) - Required - The new position for the current point. ### Request Example ```json { "ctx": "context_object", "v": {"x": 10, "y": 10} } ``` ### moveTo (alternative) Moves the current point of the path without drawing a line using coordinates. ### Method GET ### Endpoint /pixie/contexts/moveTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **x, y** (float32) - Required - The new coordinates for the current point. ### Request Example ```json { "ctx": "context_object", "x": 10, "y": 10 } ``` ### quadraticCurveTo Adds a quadratic Bézier curve to the current path. ### Method GET ### Endpoint /pixie/contexts/quadraticCurveTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **cpx, cpy, x, y** (float32) - Required - The coordinates of the control point and the end point of the curve. ### Request Example ```json { "ctx": "context_object", "cpx": 10, "cpy": 10, "x": 20, "y": 20 } ``` ### quadraticCurveTo (alternative) Adds a quadratic Bézier curve to the current path using vector points. ### Method GET ### Endpoint /pixie/contexts/quadraticCurveTo ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **ctrl, to** (Vec2) - Required - The control point and the end point of the curve. ### Request Example ```json { "ctx": "context_object", "ctrl": {"x": 10, "y": 10}, "to": {"x": 20, "y": 20} } ``` ``` -------------------------------- ### Create a New Paint Object Source: https://treeform.github.io/pixie/pixie/paints Procedure to create a new Paint object, initialized with a specified PaintKind. This is the starting point for defining any new fill or stroke. ```Nim proc newPaint(kind: PaintKind): Paint {.raises: [], tags: [], forbids: [].} ``` -------------------------------- ### Create New Path in Pixie Source: https://treeform.github.io/pixie/pixie/paths Initializes a new, empty path object. This is the starting point for defining vector graphics paths. No specific inputs are required, and it returns a Path object. ```nim proc newPath(): Path { ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Define JPEG Start of Image Marker Source: https://treeform.github.io/pixie/pixie/fileformats/jpeg This code defines the byte sequence that marks the beginning of a JPEG image. It is a constant array of unsigned 8-bit integers. ```nim jpegStartOfImage = [uint8(0x000000FF), 0x000000D8] ``` -------------------------------- ### Draw Quadratic Bézier Curve Source: https://treeform.github.io/pixie/pixie/contexts Adds a quadratic Bézier curve to the current sub-path. It requires a control point and an end point. The starting point is the most recent point in the path. This function is available in Nim. ```nim proc quadraticCurveTo(ctx: Context; cpx, cpy, x, y: float32) {.inline, ...raises: [], tags: [], forbids: []}. proc quadraticCurveTo(ctx: Context; ctrl, to: Vec2) {.inline, ...raises: [], tags: [], forbids: []}. ``` -------------------------------- ### Add Cubic Bézier Curve (Nim) Source: https://treeform.github.io/pixie/pixie/contexts Adds a cubic Bézier curve to the current sub-path using three points: two control points and the end point. The starting point is the latest point in the current path. This is an inline proc. ```nim proc bezierCurveTo(ctx: Context; cp1, cp2, to: Vec2) {.inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### XML Signature Constant for Pixie Source: https://treeform.github.io/pixie/pixie/fileformats/svg Defines the xmlSignature constant, which is a string representing the starting marker for XML files. This is useful for distinguishing XML-based formats. ```nim const xmlSignature = "", "v": {"x": 5.0, "y": 15.0} } ``` or ```json { "ctx": "", "x": 5.0, "y": 15.0 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Proc: paint Source: https://treeform.github.io/pixie/pixie/fonts Gets the paint associated with a Font. ```APIDOC ## Procedure: paint ### Description Retrieves the sequence of paints associated with a font. ### Parameters - **font** (Font) - The font from which to get the paints. ### Returns - **seq[Paint]** - The sequence of paints. ``` -------------------------------- ### Convert QOI to Image Source: https://treeform.github.io/pixie/pixie/fileformats/qoi Procedure to convert a Qoi object into an Image object. This conversion is optimized for speed by moving the data, implying it can only be performed once. It raises no specific exceptions and has no forbidden operations. ```nim proc convertToImage(qoi: Qoi): Image {....raises: [], tags: [], forbids: [].} ``` -------------------------------- ### Define QOI Data Structure Source: https://treeform.github.io/pixie/pixie/fileformats/qoi Defines the Qoi ref object structure, which holds the width, height, channels, colorspace, and pixel data (as a sequence of ColorRGBA) for a QOI image. This structure is central to handling QOI image information. ```nim Qoi = ref object width*, height*, channels*: int colorspace*: Colorspace data*: seq[ColorRGBA] ``` -------------------------------- ### Proc: scale (Typeface) Source: https://treeform.github.io/pixie/pixie/fonts Gets the scaling factor of a typeface. ```APIDOC ## Procedure: scale ### Description Retrieves the default scaling factor associated with the typeface, often related to its units per em. ### Parameters - **typeface** (Typeface) - The typeface object. ### Returns - **float32** - The scale factor. ``` -------------------------------- ### Filling and Stroking Source: https://treeform.github.io/pixie/pixie/contexts Functions for filling and stroking paths, shapes, and text. ```APIDOC ## Filling and Stroking ### fill Fills the current path with the current fill style. ### Method GET ### Endpoint /pixie/contexts/fill ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **path** (Path) - Optional - The path to fill. If not provided, the current path is used. - **windingRule** (WindingRule) - Optional - The winding rule to use (default: NonZero). ### Request Example ```json { "ctx": "context_object", "path": "path_object", "windingRule": "NonZero" } ``` ### fill (alternative) Fills the current path with the current fill style without specifying a path. ### Method GET ### Endpoint /pixie/contexts/fill ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **windingRule** (WindingRule) - Optional - The winding rule to use (default: NonZero). ### Request Example ```json { "ctx": "context_object", "windingRule": "NonZero" } ``` ### fillCircle Fills a circle on the canvas. ### Method GET ### Endpoint /pixie/contexts/fillCircle ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **circle** (Circle) - Required - The circle object. ### Request Example ```json { "ctx": "context_object", "circle": {"center": {"x": 10, "y": 10}, "radius": 5} } ``` ### fillEllipse Fills an ellipse on the canvas. ### Method GET ### Endpoint /pixie/contexts/fillEllipse ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **center** (Vec2) - Required - The center of the ellipse. - **rx, ry** (float32) - Required - The radii of the ellipse along the x and y axes. ### Request Example ```json { "ctx": "context_object", "center": {"x": 10, "y": 10}, "rx": 5, "ry": 3 } ``` ### fillPolygon Fills a regular polygon on the canvas. ### Method GET ### Endpoint /pixie/contexts/fillPolygon ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **pos** (Vec2) - Required - The center of the polygon. - **size** (float32) - Required - The size of the polygon. - **sides** (int) - Required - The number of sides of the polygon. ### Request Example ```json { "ctx": "context_object", "pos": {"x": 10, "y": 10}, "size": 5, "sides": 6 } ``` ### fillRect Fills a rectangle on the canvas. ### Method GET ### Endpoint /pixie/contexts/fillRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **rect** (Rect) - Required - The rectangle object. ### Request Example ```json { "ctx": "context_object", "rect": {"x": 10, "y": 10, "width": 20, "height": 30} } ``` ### fillRect (alternative) Fills a rectangle on the canvas using coordinates. ### Method GET ### Endpoint /pixie/contexts/fillRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **x, y, width, height** (float32) - Required - The coordinates and dimensions of the rectangle. ### Request Example ```json { "ctx": "context_object", "x": 10, "y": 10, "width": 20, "height": 30 } ``` ### fillRoundedRect Fills a rounded rectangle on the canvas. ### Method GET ### Endpoint /pixie/contexts/fillRoundedRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **rect** (Rect) - Required - The rectangle object. - **nw, ne, se, sw** (float32) - Required - The radii for the top-left, top-right, bottom-right, and bottom-left corners. ### Request Example ```json { "ctx": "context_object", "rect": {"x": 10, "y": 10, "width": 20, "height": 30}, "nw": 5, "ne": 5, "se": 5, "sw": 5 } ``` ### fillRoundedRect (alternative) Fills a rounded rectangle on the canvas using a single radius for all corners. ### Method GET ### Endpoint /pixie/contexts/fillRoundedRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **rect** (Rect) - Required - The rectangle object. - **radius** (float32) - Required - The radius for all corners. ### Request Example ```json { "ctx": "context_object", "rect": {"x": 10, "y": 10, "width": 20, "height": 30}, "radius": 5 } ``` ### fillText Fills text on the canvas. ### Method GET ### Endpoint /pixie/contexts/fillText ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **text** (string) - Required - The text to fill. - **at** (Vec2) - Required - The position to fill the text at. ### Request Example ```json { "ctx": "context_object", "text": "Hello", "at": {"x": 10, "y": 10} } ``` ### fillText (alternative) Fills text on the canvas using coordinates. ### Method GET ### Endpoint /pixie/contexts/fillText ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **text** (string) - Required - The text to fill. - **x, y** (float32) - Required - The coordinates to fill the text at. ### Request Example ```json { "ctx": "context_object", "text": "Hello", "x": 10, "y": 10 } ``` ### stroke Strokes the current path with the current stroke style. ### Method GET ### Endpoint /pixie/contexts/stroke ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **path** (Path) - Optional - The path to stroke. If not provided, the current path is used. ### Request Example ```json { "ctx": "context_object", "path": "path_object" } ``` ### stroke (alternative) Strokes the current path with the current stroke style without specifying a path. ### Method GET ### Endpoint /pixie/contexts/stroke ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. ### Request Example ```json { "ctx": "context_object" } ``` ### strokeCircle Strokes a circle on the canvas. ### Method GET ### Endpoint /pixie/contexts/strokeCircle ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **circle** (Circle) - Required - The circle object. ### Request Example ```json { "ctx": "context_object", "circle": {"center": {"x": 10, "y": 10}, "radius": 5} } ``` ### strokeEllipse Strokes an ellipse on the canvas. ### Method GET ### Endpoint /pixie/contexts/strokeEllipse ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **center** (Vec2) - Required - The center of the ellipse. - **rx, ry** (float32) - Required - The radii of the ellipse along the x and y axes. ### Request Example ```json { "ctx": "context_object", "center": {"x": 10, "y": 10}, "rx": 5, "ry": 3 } ``` ### strokePolygon Strokes a regular polygon on the canvas. ### Method GET ### Endpoint /pixie/contexts/strokePolygon ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **pos** (Vec2) - Required - The center of the polygon. - **size** (float32) - Required - The size of the polygon. - **sides** (int) - Required - The number of sides of the polygon. ### Request Example ```json { "ctx": "context_object", "pos": {"x": 10, "y": 10}, "size": 5, "sides": 6 } ``` ### strokeRect Strokes a rectangle on the canvas. ### Method GET ### Endpoint /pixie/contexts/strokeRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **rect** (Rect) - Required - The rectangle object. ### Request Example ```json { "ctx": "context_object", "rect": {"x": 10, "y": 10, "width": 20, "height": 30} } ``` ### strokeRect (alternative) Strokes a rectangle on the canvas using coordinates. ### Method GET ### Endpoint /pixie/contexts/strokeRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **x, y, width, height** (float32) - Required - The coordinates and dimensions of the rectangle. ### Request Example ```json { "ctx": "context_object", "x": 10, "y": 10, "width": 20, "height": 30 } ``` ### strokeRoundedRect Strokes a rounded rectangle on the canvas. ### Method GET ### Endpoint /pixie/contexts/strokeRoundedRect ### Parameters #### Path Parameters - **ctx** (Context) - Required - The drawing context. - **rect** (Rect) - Required - The rectangle object. - **nw, ne, se, sw** (float32) - Required - The radii for the top-left, top-right, bottom-right, and bottom-left corners. ### Request Example ```json { "ctx": "context_object", "rect": {"x": 10, "y": 10, "width": 20, "height": 30}, "nw": 5, "ne": 5, "se": 5, "sw": 5 } ``` ``` -------------------------------- ### Get Font Name Source: https://treeform.github.io/pixie/pixie/fonts Returns the name of the font associated with the typeface. ```nim proc name(typeface: Typeface): string { ....raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Proc: scale (Font) Source: https://treeform.github.io/pixie/pixie/fonts Gets the scaling factor applied to a font. ```APIDOC ## Procedure: scale ### Description Retrieves the scaling factor applied to the font. ### Parameters - **font** (Font) - The font object. ### Returns - **float32** - The scale factor. ``` -------------------------------- ### save Source: https://treeform.github.io/pixie/pixie/contexts Saves the entire current state of the context by pushing it onto a stack. ```APIDOC ## save ### Description Saves the entire state of the context by pushing the current state onto a stack. ### Method POST (or equivalent for state management) ### Endpoint /context/save ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **ctx** (Context) - Required - The drawing context. ### Request Example ```json { "ctx": "" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Create Image from QOI Object Source: https://treeform.github.io/pixie/pixie/fileformats/qoi Procedure to create a new Image object from a given Qoi object. This function may raise a PixieError if there are issues during image creation from the QOI data. ```nim proc newImage(qoi: Qoi): Image {....raises: [PixieError], tags: [], forbids: [].} ``` -------------------------------- ### Proc: getKerningAdjustment Source: https://treeform.github.io/pixie/pixie/fonts Gets the kerning adjustment between two adjacent runes in a typeface. ```APIDOC ## Procedure: getKerningAdjustment ### Description Calculates the adjustment in spacing between two adjacent runes based on kerning rules defined in the typeface. ### Parameters - **typeface** (Typeface) - The typeface. - **left** (Rune) - The left rune in the pair. - **right** (Rune) - The right rune in the pair. ### Returns - **float32** - The kerning adjustment value. ``` -------------------------------- ### Move To Point Source: https://treeform.github.io/pixie/pixie/contexts Begins a new sub-path at the specified point (x, y). This function is available in Nim and can accept coordinates as a Vec2 object or individual float32 values. ```nim proc moveTo(ctx: Context; v: Vec2) {.inline, ...raises: [], tags: [], forbids: [].} proc moveTo(ctx: Context; x, y: float32) {.inline, ...raises: [], tags: [], forbids: [].} ``` -------------------------------- ### Proc: getAdvance Source: https://treeform.github.io/pixie/pixie/fonts Gets the horizontal advance width for a specific rune in a typeface. ```APIDOC ## Procedure: getAdvance ### Description Retrieves the horizontal distance the cursor should advance after the given rune in the specified typeface. ### Parameters - **typeface** (Typeface) - The typeface containing the rune. - **rune** (Rune) - The rune character. ### Returns - **float32** - The advance width in font units. ``` -------------------------------- ### Get Font Paint Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the Paint object associated with a Font. This is an inlined procedure. ```nim proc paint(font: Font): Paint { .inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Path Construction and Modification Procedures Source: https://treeform.github.io/pixie/pixie/paths Provides a comprehensive set of procedures for creating and modifying paths. These include `moveTo`, `lineTo`, `arc`, `bezierCurveTo`, `circle`, `rect`, `ellipse`, `polygon`, `quadraticCurveTo`, `roundedRect`, `closepath`, `copy`, `transform`, `parsePath`, and `newPath`. Some procedures may have optional parameters with default values. ```nim proc addPath(path: Path; other: Path) proc arc(path: Path; pos: Vec2; r: float32; a: Vec2; ccw: bool = false) proc arc(path: Path; x, y, r, a0, a1: float32; ccw: bool = false) proc arcTo(path: Path; a, b: Vec2; r: float32) proc arcTo(path: Path; x1, y1, x2, y2, r: float32) proc bezierCurveTo(path: Path; ctrl1, ctrl2, to: Vec2) proc bezierCurveTo(path: Path; x1, y1, x2, y2, x3, y3: float32) proc circle(path: Path; circle: Circle) proc circle(path: Path; cx, cy, r: float32) proc closePath(path: Path) proc copy(path: Path): Path proc ellipse(path: Path; center: Vec2; rx, ry: float32) proc ellipse(path: Path; cx, cy, rx, ry: float32) proc ellipticalArcTo(path: Path; rx, ry: float32; xAxisRotation: float32; largeArcFlag, sweepFlag: bool; x, y: float32) proc lineTo(path: Path; v: Vec2) proc lineTo(path: Path; x, y: float32) proc moveTo(path: Path; v: Vec2) proc moveTo(path: Path; x, y: float32) proc newPath(): Path proc parsePath(path: string): Path proc polygon(path: Path; pos: Vec2; size: float32; sides: int) proc polygon(path: Path; x, y, size: float32; sides: int) proc quadraticCurveTo(path: Path; ctrl, to: Vec2) proc quadraticCurveTo(path: Path; x1, y1, x2, y2: float32) proc rect(path: Path; rect: Rect; clockwise = true) proc rect(path: Path; x, y, w, h: float32; clockwise = true) proc roundedRect(path: Path; rect: Rect; nw, ne, se, sw: float32; clockwise = true) proc roundedRect(path: Path; x, y, w, h, nw, ne, se, sw: float32; clockwise = true) proc transform(path: Path; mat: Mat3) ``` -------------------------------- ### Get Rune Advance Width Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the advance width for a given rune in pixels from a typeface. This is an inlined procedure. ```nim proc getAdvance(typeface: Typeface; rune: Rune): float32 { .inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Get Transform Matrix in Pixie Source: https://treeform.github.io/pixie/pixie/contexts Retrieves the current transformation matrix being applied to the graphics context. This matrix defines scaling, rotation, and translation operations. ```Nim proc getTransform(ctx: Context): Mat3 {.inline, ...raises: [], tags: [], forbids: [].} ``` -------------------------------- ### Image Conversion Functions (PNG and QOI) Source: https://treeform.github.io/pixie/theindex Provides functions to convert specific image data formats (PNG and QOI) into a generic Image object. These functions are crucial for loading and processing images from different file types. ```nim proc convertToImage(png: Png): Image proc convertToImage(qoi: Qoi): Image ``` -------------------------------- ### Get Default Line Height Source: https://treeform.github.io/pixie/pixie/fonts Calculates the default line height in pixels for the current font size. This is an inlined procedure. ```nim proc defaultLineHeight(font: Font): float32 { .inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### QOI File Signature Constant Source: https://treeform.github.io/pixie/pixie/fileformats/qoi Defines the constant qoiSignature as the string "qoif". This signature is used to identify QOI files and is a critical part of the QOI file format specification. ```nim qoiSignature = "qoif" ``` -------------------------------- ### Get Pixel Color from Image Source: https://treeform.github.io/pixie/theindex Retrieves the color of a specific pixel at given integer coordinates (x, y) from an image. Dependency: Image, Color types. ```nim proc getColor(image: Image; x, y: int): Color ``` -------------------------------- ### Create a ColorStop Source: https://treeform.github.io/pixie/pixie/paints Procedure to create a new ColorStop object with a specified color and position. This is a fundamental step in defining gradient fills. ```Nim proc colorStop(color: Color; position: float32): ColorStop {.raises: [], tags: [], forbids: [].} ``` -------------------------------- ### Get Image Size (Nim) Source: https://treeform.github.io/pixie/pixie/images Retrieves the dimensions of an image as a string. This is a fundamental operation for understanding image properties. ```nim proc `$`(image: Image): string {"....raises: [], tags: [], forbids: []."} ``` -------------------------------- ### Create New Image in Nim Source: https://treeform.github.io/pixie/pixie/common Initializes a new image with specified width and height. This procedure can raise a PixieError if image creation fails. ```nim proc newImage(width, height: int): Image {....raises: [PixieError], tags: [], forbids: [].} ``` -------------------------------- ### Encode Image to QOI Format Source: https://treeform.github.io/pixie/pixie/fileformats/qoi Procedure to encode an Image object into the QOI file format, returning the data as a string. This process may raise a PixieError if encoding fails. ```nim proc encodeQoi(image: Image): string {....raises: [PixieError], tags: [], forbids: [].} ``` -------------------------------- ### Get Default Line Height in Font Units Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the default line height in font units for a typeface. This is an inlined procedure. ```nim proc lineHeight(typeface: Typeface): float32 { .inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Path Rendering Procedures Source: https://treeform.github.io/pixie/pixie/paths Procedures for rendering paths onto an image. `fillPath` fills the interior of a path according to a specified winding rule. `strokePath` renders the outline of a path with configurable stroke properties like width, line cap, and join styles. Both require an `Image` and `Paint` object. ```nim proc fillPath(image: Image; path: SomePath; paint: Paint; transform = mat3(); windingRule = NonZero) proc strokePath(image: Image; path: SomePath; paint: Paint; transform = mat3(); strokeWidth: float32 = 1.0; lineCap = ButtCap; lineJoin = MiterJoin; miterLimit = defaultMiterLimit; dashes: seq[float32] = @[]) ``` -------------------------------- ### Get Font Line Gap Value Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the line gap value of a typeface in font units. This is the spacing between lines of text. ```nim proc lineGap(typeface: Typeface): float32 { ....raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Get Font Cap Height Value Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the cap height value of a typeface in font units. This is the height of a capital letter. ```nim proc capHeight(typeface: Typeface): float32 { ....raises: [], tags: [], forbids: []. } ``` -------------------------------- ### SIMD Operations Source: https://treeform.github.io/pixie/theindex Constants and procedures related to Single Instruction, Multiple Data (SIMD) optimizations. ```APIDOC ## SIMD Operations ### Description Constants and procedures related to Single Instruction, Multiple Data (SIMD) optimizations. ### Endpoints #### `allowSimd` * **Method**: N/A (Constant) * **Description**: A constant indicating whether SIMD instructions are allowed or available. #### `applyOpacityAvx2` * **Method**: N/A (Procedure) * **Description**: Applies opacity to an image using AVX2 SIMD instructions. * **Parameters**: * `image` (Image) - The image to modify. * `opacity` (float32) - The opacity value. #### `applyOpacitySse2` * **Method**: N/A (Procedure) * **Description**: Applies opacity to an image using SSE2 SIMD instructions. * **Parameters**: * `image` (Image) - The image to modify. * `opacity` (float32) - The opacity value. #### `blendLineCoverageMaskAvx2` * **Method**: N/A (Procedure) * **Description**: Blends line coverage using AVX2 SIMD instructions, applying a mask. * **Parameters**: * `line` (ptr UncheckedArray[ColorRGBX]) - Pointer to the line colors. * `coverages` (ptr UncheckedArray[uint8]) - Pointer to coverage values. * `rgbx` (ColorRGBX) - The color to blend. * `len` (int) - The number of elements. #### `blendLineCoverageMaskSse2` * **Method**: N/A (Procedure) * **Description**: Blends line coverage using SSE2 SIMD instructions, applying a mask. * **Parameters**: * `line` (ptr UncheckedArray[ColorRGBX]) - Pointer to the line colors. * `coverages` (ptr UncheckedArray[uint8]) - Pointer to coverage values. * `rgbx` (ColorRGBX) - The color to blend. * `len` (int) - The number of elements. #### `blendLineCoverageNormalAvx2` * **Method**: N/A (Procedure) * **Description**: Blends line coverage using AVX2 SIMD instructions with normal blending. * **Parameters**: * `line` (ptr UncheckedArray[ColorRGBX]) - Pointer to the line colors. * `coverages` (ptr UncheckedArray[uint8]) - Pointer to coverage values. * `rgbx` (ColorRGBX) - The color to blend. * `len` (int) - The number of elements. #### `blendLineCoverageNormalSse2` * **Method**: N/A (Procedure) * **Description**: Blends line coverage using SSE2 SIMD instructions with normal blending. * **Parameters**: * `line` (ptr UncheckedArray[ColorRGBX]) - Pointer to the line colors. * `coverages` (ptr UncheckedArray[uint8]) - Pointer to coverage values. * `rgbx` (ColorRGBX) - The color to blend. * `len` (int) - The number of elements. #### `blendLineCoverageOverwriteAvx2` * **Method**: N/A (Procedure) * **Description**: Blends line coverage using AVX2 SIMD instructions, overwriting existing colors. * **Parameters**: * `line` (ptr UncheckedArray[ColorRGBX]) - Pointer to the line colors. * `coverages` (ptr UncheckedArray[uint8]) - Pointer to coverage values. * `rgbx` (ColorRGBX) - The color to blend. * `len` (int) - The number of elements. #### `blendLineCoverageOverwriteSse2` * **Method**: N/A (Procedure) * **Description**: Blends line coverage using SSE2 SIMD instructions, overwriting existing colors. * **Parameters**: * `line` (ptr UncheckedArray[ColorRGBX]) - Pointer to the line colors. * `coverages` (ptr UncheckedArray[uint8]) - Pointer to coverage values. * `rgbx` (ColorRGBX) - The color to blend. * `len` (int) - The number of elements. #### `blendLineMaskAvx2` * **Method**: N/A (Procedure) * **Description**: Applies a mask blend to a line using AVX2 SIMD instructions. * **Parameters**: Not fully specified in the provided text. ``` -------------------------------- ### Get Line Dash Array in Pixie Source: https://treeform.github.io/pixie/pixie/contexts Retrieves the current line dash array used for drawing dashed lines. This function is useful for customizing line styles. ```Nim proc getLineDash(ctx: Context): seq[float32] {.inline, ...raises: [], tags: [], forbids: [].} ``` -------------------------------- ### Luminosity, Mask, Multiply, Normal, Overlay, Saturation, Screen, SoftLight, SubtractMask Blend Modes Source: https://treeform.github.io/pixie/theindex Defines procedures for various color blending modes including Luminosity, Mask, Multiply, Normal, Overlay, Saturation, Screen, SoftLight, and SubtractMask. Each function takes a backdrop and source ColorRGBX and returns the resulting ColorRGBX after applying the blend mode. ```nim proc blendLuminosity(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendMask(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendMultiply(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendNormal(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendOverlay(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendSaturation(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendScreen(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendSoftLight(backdrop, source: ColorRGBX): ColorRGBX ``` ```nim proc blendSubtractMask(backdrop, source: ColorRGBX): ColorRGBX ``` -------------------------------- ### Get Kerning Adjustment Source: https://treeform.github.io/pixie/pixie/fonts Calculates the kerning adjustment in pixels for a pair of adjacent runes (left and right) within a typeface. This is an inlined procedure. ```nim proc getKerningAdjustment(typeface: Typeface; left, right: Rune): float32 { ....inline, ...raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Fill Image with Paint (Nim) Source: https://treeform.github.io/pixie/pixie Fills an image with a specified paint. This procedure is tagged with RootEffect and can raise a PixieError. It takes an Image and a Paint object as input. ```nim proc fill(image: Image; paint: Paint) {....raises: [PixieError], tags: [RootEffect], forbids: [].} ``` -------------------------------- ### Ceiling Image Function with AVX2 and SSE2 Optimizations Source: https://treeform.github.io/pixie/theindex Provides functions to adjust image pixel values to the nearest greater or equal integer. Includes a general purpose function and optimized versions using AVX2 and SSE2 instruction sets for improved performance. ```nim proc ceil(image: Image) ``` ```nim proc ceilAvx2(image: Image) ``` ```nim proc ceilSse2(image: Image) ``` -------------------------------- ### Get Font Descender Value Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the descender value of a typeface in font units. This indicates the distance from the baseline to the bottom of the lowest characters. ```nim proc descent(typeface: Typeface): float32 { ....raises: [], tags: [], forbids: []. } ``` -------------------------------- ### OpenType Font Metrics and Glyph Access Source: https://treeform.github.io/pixie/pixie/fontformats/opentype Functions for retrieving font metrics, kerning information, and glyph paths. ```APIDOC ## getAdvance ### Description Gets the advance width for a given rune (character) in the OpenType font. ### Method `getAdvance` ### Parameters - **opentype** (OpenType) - Required - The parsed OpenType font object. - **rune** (Rune) - Required - The rune for which to get the advance width. ### Response #### Success Response (200) - **float32** - The advance width of the rune. ## getGlyphPath ### Description Retrieves the path data for a given rune (character) in the OpenType font. ### Method `getGlyphPath` ### Parameters - **opentype** (OpenType) - Required - The parsed OpenType font object. - **rune** (Rune) - Required - The rune for which to get the glyph path. ### Response #### Success Response (200) - **Path** - The path data representing the glyph. ## getKerningAdjustment ### Description Calculates the kerning adjustment between two adjacent runes. ### Method `getKerningAdjustment` ### Parameters - **opentype** (OpenType) - Required - The parsed OpenType font object. - **left** (Rune) - Required - The left rune in the pair. - **right** (Rune) - Required - The right rune in the pair. ### Response #### Success Response (200) - **float32** - The kerning adjustment value. ## getLeftSideBearing ### Description Gets the left side bearing for a given rune (character) in the OpenType font. ### Method `getLeftSideBearing` ### Parameters - **opentype** (OpenType) - Required - The parsed OpenType font object. - **rune** (Rune) - Required - The rune for which to get the left side bearing. ### Response #### Success Response (200) - **float32** - The left side bearing of the rune. ## hasGlyph ### Description Checks if the OpenType font contains a glyph for the given rune (character). ### Method `hasGlyph` ### Parameters - **opentype** (OpenType) - Required - The parsed OpenType font object. - **rune** (Rune) - Required - The rune to check for. ### Response #### Success Response (200) - **bool** - True if the font has the glyph, false otherwise. ## isCCW ### Description Determines if the contour winding order of the font is counter-clockwise (CCW). ### Method `isCCW` ### Parameters - **opentype** (OpenType) - Required - The parsed OpenType font object. ### Response #### Success Response (200) - **bool** - True if the winding order is CCW, false otherwise. ``` -------------------------------- ### Get Font Ascender Value Source: https://treeform.github.io/pixie/pixie/fonts Retrieves the ascender value of a typeface in font units. This indicates the distance from the baseline to the top of the highest characters. ```nim proc ascent(typeface: Typeface): float32 { ....raises: [], tags: [], forbids: []. } ``` -------------------------------- ### Get Font Scale Factor with Pixie Source: https://treeform.github.io/pixie/pixie/fonts Provides the scale factor for transforming font units into pixels. This is an inline procedure with no specified exceptions or effects. ```Nim proc scale(font: Font): float32 {.inline, ...raises: [], tags: [], forbids: [].} The scale factor to transform font units into pixels. Source Edit ``` ```Nim proc scale(typeface: Typeface): float32 {.inline, ...raises: [], tags: [], forbids: [].} The scale factor to transform font units into pixels. Source Edit ``` -------------------------------- ### newContext Source: https://treeform.github.io/pixie/pixie/contexts Creates a new drawing context. Can be initialized with an existing image or with specified dimensions for a new image. ```APIDOC ## newContext ### Description Create a new Context that will draw to the parameter image or a new image of specified width and height. ### Method POST ### Endpoint /contexts ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image** (Image) - Optional - The image to draw on. - **width** (int) - Optional - The width of the new image if no image is provided. - **height** (int) - Optional - The height of the new image if no image is provided. ### Request Example ```json { "image": "" } ``` or ```json { "width": 800, "height": 600 } ``` ### Response #### Success Response (200) - **context** (Context) - The newly created drawing context. #### Response Example ```json { "context": "" } ``` ```