Repository navigation
Releases
v0.1.0
The first tagged release of pntr. Since there was no previous tag, the entries below are written against the untagged master history, so they are aimed at anyone who has been vendoring pntr.h directly or shipping one of the integrations.
Breaking Changes
-
The drawing bounds convention was settled ([#245], [#232]). Whether a shape covers its far edge now depends on how the shape is described, and every primitive follows the same rule:
- Point-valued parameters and radii are inclusive.
pntr_draw_line(image, 0, 0, 10, 0, color)paints 11 pixels,x = 0throughx = 10.pntr_draw_circle_fill(image, 50, 50, 10, color)is 21 pixels across, and covers exactly the pixels thatpntr_draw_circle()outlines for the same center and radius. The same holds forpntr_draw_line_aa(),pntr_draw_line_thick(),pntr_draw_line_curve(),pntr_draw_polyline(),pntr_draw_polygon(),pntr_draw_triangle(), their fills, and the ellipses. - Extent-valued parameters stop short of the far edge.
pntr_draw_rectangle(image, x, y, width, height, color)paints columnsxthroughx + width - 1, sowidthandheightare pixel counts, not second coordinates.pntr_draw_rectangle_fill(),pntr_draw_rectangle_rounded(),pntr_draw_line_horizontal(),pntr_draw_line_vertical()andpntr_image_set_clip()read their sizes the same way.
What to do: rendered output changed for lines, polygon and triangle fills, filled circles and ellipses, rounded rectangles, and line thicknesses 2 and 3. Nothing in the API signatures changed, so nothing stops compiling, but anything doing a pixel-exact comparison against pntr output (reference screenshots, golden-image tests, hashes) needs its baselines regenerated. A rounded rectangle now occupies the same pixels as a plain rectangle with the same
x,y,widthandheight, and a thick line is the same length as the thin line through the same two endpoints. The full rule is written out under Bounds. - Point-valued parameters and radii are inclusive.
-
The rotation offset became a pivot ([#249], [#255]).
offsetX/offsetYonpntr_draw_image_rotated()andpntr_draw_image_rotated_rec(), andoriginX/originYonpntr_draw_image_rotozoom(), are now a pivot expressed in unrotated, unscaled source pixels: the source pixel at that offset lands onposX,posY, at every angle. Previously an offset of0, 0effectively placed the rotated bounding box rather than a source pixel.What to do: any call passing
0, 0with a non-zero rotation will see its sprite move. To rotate a sprite about its center, pass the center of the source in source pixels,(width - 1) / 2.0fand(height - 1) / 2.0f; to pin a sprite by its top-left source pixel,0, 0is now correct and stays correct as the sprite turns. This reaches the integrations that draw rotated sprites, including [pntr_app], [pntr_aseprite] and [pntr_tiled]. Rotozoom is now continuous through a rotation of zero and through the quarter turns, so sweeping an angle no longer jumps by a pixel as it crosses 0, 90, 180 or 270 degrees ([#249], [#255]).
Added
pntr_image_get_color_bilinear(), for sampling an image at a floating point coordinate with bilinear interpolation ([#231]).pntr_draw_image_dest_rec(), for drawing a source rectangle into an arbitrary destination rectangle, scaling and tinting to fit.PNTR_VERSION,PNTR_VERSION_MAJOR,PNTR_VERSION_MINORandPNTR_VERSION_PATCH, so a consumer can report or#ifon the version ofpntr.hit was built against.PNTR_ERROR_FAILED_TO_READandPNTR_ERROR_INVALID_DATA, which distinguish a file that opened but could not be read from data that is not what it claimed to be ([#242]).PNTR_ERROR_STORAGE, the storage class holding the last reported error. It defaults tostatic, which every thread shares; define it as a thread-local storage class, likestatic _Thread_local, to give each thread an error of its own ([#242]).PNTR_NO_BMP, to drop BMP loading and save roughly 6.5 KB. BMP saving is unaffected.pntr_draw_image_rotozoom(), which rotates, scales and tints a source rectangle in one pass ([#121], [#219]).- A
tintparameter onpntr_draw_image_scaled_rec()([#217]). pntr_draw_line_aa(), for anti-aliased lines ([#212]).pntr_color_grayscale()andpntr_image_color_grayscale()([#214]).pntr_draw_text_aligned(), withPNTR_TEXT_ALIGN_LEFT,CENTERandRIGHT([#215]).- A thickness variant for every primitive:
pntr_draw_line_thick(),pntr_draw_line_thick_vec(),pntr_draw_line_horizontal_thick(),pntr_draw_line_vertical_thick(),pntr_draw_line_curve_thick(),pntr_draw_rectangle_thick(),pntr_draw_rectangle_thick_rec(),pntr_draw_rectangle_thick_rounded(),pntr_draw_circle_thick(),pntr_draw_ellipse_thick(),pntr_draw_triangle_thick(),pntr_draw_triangle_thick_vec(),pntr_draw_arc_thick(),pntr_draw_polygon_thick()andpntr_draw_polyline_thick(). - Documentation for every public function, parameter, macro and configuration define, published at https://robloach.github.io/pntr/. The docs build now fails on Doxygen warnings, and no longer needs Graphviz ([#251]).
Changed
- BMP loading is now enabled by default, matching the formats pntr can save. Opt out with
PNTR_NO_BMP. JPEG loading still needsPNTR_ENABLE_JPEG, costing roughly 21 KB. pntr_load_image()no longer masks the underlying file error with a generic one, so a missing file, an unreadable file and a corrupt image are now told apart throughpntr_get_error()andpntr_get_error_code()([#242]).- Failure paths that used to return
NULLorfalsesilently now report an error, sopntr_get_error()is meaningful after any failed call ([#242]). - Internal symbols have internal linkage, so including the implementation in a translation unit no longer leaks private helpers into the link.
PNTR_NO_LOAD_IMAGEandPNTR_NO_SAVE_IMAGEare honored throughout, instead of being partially ignored, and a disabled save reports a size of zero rather than leaving the caller's size untouched.- The smallest circles and ellipses are drawn at their own radius, so a radius of one is three pixels across, a radius of zero is the center pixel on its own, and an ellipse with a zero radius on one axis is the straight line through its center ([#250]).
- Every pixel of a primitive is blended exactly once, so overlapping spans in a single shape no longer double-blend a translucent color.
- The committed example screenshots were regenerated against the settled conventions.
Fixed
-
A thick brush no longer costs the square of its thickness ([#268]).
_pntr_draw_thick_point()walked its whole thickness box for every point of a line, without clipping it to the image first, and searched each row for its first column rather than solving for it. A thick stroke was therefore quadratic in a thickness the caller chooses, whether or not any of it landed on the canvas. The rows are clamped to the clip now, and each row's edge comes from an integer square root.A 100 pixel line on a 200x200 image at a thickness of 2048 went from 61 ms to 2.4 ms, and the cost now flattens once the brush is wider than the canvas instead of growing.
pntr_draw_line_thick(image, 0, 10, 19, 10, 1000000, color)on a 20x20 image did not finish before; it returns immediately. Thicknesses small enough to fit on the canvas are unchanged in cost. Rendered output is byte-identical, verified by hashing every thickness from 1 to 200 across seven primitives, three clip configurations and brushes straddling each clip edge and corner. -
pntr_image_resize_canvas()moves pixels rather than blending them ([#269]). It used to draw the original onto the filled canvas, which composites: a semi-transparent pixel came out mixed with the fill, and underPNTR_NO_ALPHABLENDit was skipped entirely and the fill was left in its place, so a partially transparent image came back as a blank rectangle. The rows are copied now, which is independent of what the build does about blending.Resizing the canvas of an image with any non-opaque pixel in it previously changed those pixels; it no longer does. Measured on an image with a different alpha in every pixel: 30 of 30 wrong in the default build and 67 of 71 under
PNTR_NO_ALPHABLEND, now 0 in both. -
A coordinate near the end of the int range no longer overflows ([#267]).
pntr_draw_rectangle_fill(image, INT_MAX - 1, 0, 10, 10, color)segfaulted: the clip test computedx + width, which overflowed and wrapped negative, so the far edge came back smaller than the near one and the subtraction wrapped again into a positive width. An entirely off-image rectangle was reported as visible and written through. Squaring a radius or a thickness overflowed above 46340 as well, and the sum of two squares above about 32767, so a circle wide enough to cover the canvas was drawn from a wrapped radius.Measured over 30 entry points called with extreme but legal arguments: 21 reached undefined behavior, now 0. Rendered output for ordinary values is unchanged, verified by hashing 20 primitives across 6 parameter variations against the previous
master. -
Bilinear interpolation rounds instead of truncating ([#263]). Interpolating between four copies of the same color now returns that color exactly, on every channel and at every fractional coordinate. The four weights sum to one in exact arithmetic but not in float, so truncating the result shaved a unit off: a bilinear-scaled draw of a fully opaque image produced pixels at an alpha of 254, which
PNTR_NO_ALPHABLENDthen discarded outright and left holes in the fill. Red, green and blue were losing the same unit in the same places.What to do: rendered output changes by at most one unit per channel for anything scaled, resized or rotated with
PNTR_FILTER_BILINEAR, so pixel-exact baselines against bilinear output ...