fix: stroke arcs and splines analytically — opaque core, angle-independent weight

LICE_Arc never reaches opacity and ThickFLine's width is minor-axis. One
distance-to-polyline coverage mask, blended once, replaces both.
This commit is contained in:
2026-08-01 13:18:21 -04:00
parent ae9019465e
commit 2e09776342
16 changed files with 1001 additions and 72 deletions
+50
View File
@@ -0,0 +1,50 @@
// editor_stroke.h — the editor's LICE side of the analytic stroker: build a coverage mask with
// the pure `core/ui/stroke_aa` module, blend it into the bitmap ONCE.
//
// Every radial and spline stroke on the editor goes through here. LICE's own primitives cannot
// serve these two shapes: LICE_Arc rasterizes a whole circle clipped per 90-degree box and splits
// one unit of ink across two pixels by the radius's fractional part (so a stacked-radii arc never
// reaches an opaque core), and LICE_ThickFLine lays its width along the MINOR axis (so a curve's
// perpendicular weight falls off as cos(theta) and thins at every diagonal).
#pragma once
#ifdef _WIN32
#include <cstddef>
#include <vector>
#include "lice/lice.h"
#include "wdltypes.h"
#include "core/ui/rect.h"
#include "core/ui/stroke_aa.h"
namespace reasampler::vst {
// Blends a polyline as one antialiased stroke of `widthPx`. Clipped to the bitmap. Takes a raw
// span so a short stroke (a knob needle) can pass a stack array and cost no allocation.
void strokePolylineAA(LICE_IBitmap* bmp, const ui::StrokePoint* pts, std::size_t count,
float widthPx, LICE_pixel color, float alpha = 1.0f);
inline void strokePolylineAA(LICE_IBitmap* bmp, const std::vector<ui::StrokePoint>& pts,
float widthPx, LICE_pixel color, float alpha = 1.0f) {
strokePolylineAA(bmp, pts.data(), pts.size(), widthPx, color, alpha);
}
// A single antialiased segment — the two-point polyline, spelled out for the call sites that
// have exactly two endpoints.
inline void strokeLineAA(LICE_IBitmap* bmp, float x0, float y0, float x1, float y1, float widthPx,
LICE_pixel color, float alpha = 1.0f) {
const ui::StrokePoint pts[2] = {{x0, y0}, {x1, y1}};
strokePolylineAA(bmp, pts, 2, widthPx, color, alpha);
}
// Blends a circular arc as one antialiased stroke of `widthPx`. Angles are radians in LICE's
// convention (0 = 12 o'clock, increasing clockwise), matching what LICE_Arc took.
void strokeArcAA(LICE_IBitmap* bmp, float cx, float cy, float radius, float startRad, float endRad,
float widthPx, LICE_pixel color, float alpha = 1.0f);
} // namespace reasampler::vst
#endif // _WIN32