P4 Software P4 Software / BarcoderX English

Add these docs to Claude

Ask Claude questions about these docs. Claude reads the published pages and links you back to them. Copy this address:

https://docs.p4software.cloud/mcp

In claude.ai or Claude Desktop: open Settings, then Connectors, choose Add custom connector and paste the address.

In Claude Code, run:

claude mcp add --transport http docs https://docs.p4software.cloud/mcp

Drawing shapes

Drawing shapes

Applies to: BarcoderX Basic and Ultimate

Status: Built, not yet released. The first part of the drawing engine exists and is tested, but nothing is released yet and there is nothing to download. It can work out what a filled shape covers. It cannot yet draw outlines, blend colors or place pictures. This page says what it does today and what comes later.

BarcoderX draws labels with its own drawing engine. It does not use the drawing functions of the operating system, so a label looks the same on Windows x64, Linux x64 and Linux arm64. This page describes the core of that engine, the part that works out what a filled shape covers. Everything else on a label, such as text, barcodes and pictures, is built on it.

Shapes

A shape is a path: a series of moves, straight lines and curves. A path can hold several separate pieces, and each piece can be open or closed. You can build a path from these steps:

  • A move to a point, and a straight line to a point.
  • A smooth curve with one control point, and a smooth curve with two control points.
  • Closing the current piece.

Four ready-made shapes save you the steps: a rectangle, a rectangle with rounded corners (each corner has its own horizontal and vertical radius), an ellipse and an arc of an ellipse.

Moving, scaling and turning

A transform places a shape on the page. You can shift it, scale it by different amounts across and down, and turn it by any angle, around the origin or around a point you choose. Transforms combine in the order you give, and a transform that can be undone has an inverse. Turning by an angle that is not a multiple of 90 degrees is drawn directly, and the result is smooth.

Filling a shape

Filling works out which pixels the inside of a shape covers, and by how much. Two rules decide what is inside when a path crosses itself or holds a piece inside another piece:

  • Non-zero. A point is inside if the path winds around it at all. A piece drawn inside another piece in the same direction stays filled.
  • Even-odd. A point is inside if a line from it to the outside crosses the path an odd number of times. A piece drawn inside another piece makes a hole.

The edges are smooth. For every pixel, the engine works out how much of the pixel the shape covers, as a number from 0 (none) to 255 (all). Putting a color on a surface in that proportion is blending, which is not built yet (see the end of this page). A pixel that the shape covers completely is exactly 255, and one that it does not touch is exactly 0. A rectangle whose edges lie on pixel boundaries is therefore filled with no soft edge at all.

For printers that print in black and white, the engine can draw on a 1-bit surface instead. There it fills rectangles on whole printer dots, and it turns a shape's coverage into black where the coverage is 128 or more.

Surfaces

A surface is the grid of pixels that you draw on. Three kinds exist:

SurfaceWhat it holds
Color with transparencyRed, green, blue and opacity for each pixel, 8 bits each.
GrayOne 8-bit value for each pixel.
Black and whiteOne bit for each pixel, eight to a byte.

A list of drawing steps

Instead of drawing at once, you can record the steps in a list: fill a path, fill rectangles, start a clip area (a rectangle or a path) and end it. The list can be written out as plain text in one fixed form, so two lists can be compared exactly. Running a list is not built yet.

Precision

  • Points are moved onto a grid of 1/4096 of a pixel before the fill, and the fill then uses whole-number arithmetic only. That is why the result does not depend on the processor.
  • Curves are cut into short straight pieces that stay within 0.1 of a pixel of the true curve.
  • In BarcoderX's automatic tests, the coverage of seven test scenes (curves, a turn by an angle that is not a right angle, and scenes cut by each side of the window) has the same fingerprint on Windows x64, Linux x64 and Linux arm64.
  • A rectangle whose edges lie on pixel boundaries is exact. A shape with slanted edges is within 0.6 of one step (out of 255) of the exact coverage.
  • Where several overlapping pieces of a path cross the same pixel, the result can differ slightly from the true covered area. One piece on its own, and pieces that only touch, are exact to within the rounding of the grid.

Limits

BarcoderX checks every limit before it allocates the memory it protects. A drawing that is too large or too complex is refused with a diagnostic code from 3001 to 3005. See Diagnostic codes.

LimitValue
Pixels in one surface, window or coverage area64,000,000 (64 million)
Longest side of a surface, window or coverage area262,144 pixels. This is a fixed property of the design and cannot be raised.
Steps in one path1,000,000
Straight pieces that the curves of one fill are cut into4,000,000
Work for one fill100,000,000 units, which is about five seconds on a recent desktop processor
Size of a coordinate after the transformAbout one billion pixels (2 to the power 30)

The drawing code checks for cancellation at every row and at every 1,024 pieces, so the program that calls it can enforce its own time limit, such as 2 seconds for one label. A coordinate that is not a number, or is too large, is refused.

What is not built yet

  • Outlines. Lines with a width, caps, joins and dashes. The engine can fill a shape, but it cannot yet draw its outline.
  • Blending. Drawing with partial transparency over what is already there.
  • Clipping while drawing. Clip areas can be recorded in a list, but they are not applied yet.
  • Pictures. Placing a picture on a surface, with scaling.
  • Text. Drawing text needs the font support described in Font support and layout that is not built yet.
  • Running a list of drawing steps, and reading one back from its text form.

BarcoderX is a product of P4 Software.

Was this page helpful?