A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(look): a dab with a taper drew nothing
yhhfb112bc9128a
diff --git a/pipeline/src/image/imageRaster.ts b/pipeline/src/image/imageRaster.tsindex 88ae725ae..1a88f45da 100644--- a/pipeline/src/image/imageRaster.ts+++ b/pipeline/src/image/imageRaster.ts@@ -778,8 +778,8 @@ function paintStrand(c: Canvas, s: ImageStroke, path: readonly PathPoint[], straconst t = span > 0 ? Math.max(0, Math.min(1, (distance - a.along) / span)) : 0;const position = total > 0 ? distance / total : 0;let narrowing = 1;- if (taperIn > 0 && position < taperIn) narrowing *= smoothed(position / taperIn);- if (taperOut > 0 && position > 1 - taperOut) narrowing *= smoothed((1 - position) / taperOut);+ if (total > 0 && taperIn > 0 && position < taperIn) narrowing *= smoothed(position / taperIn);+ if (total > 0 && taperOut > 0 && position > 1 - taperOut) narrowing *= smoothed((1 - position) / taperOut);const width = size * (a.pressure + (b.pressure - a.pressure) * t) * narrowing;const radius = strand.radius === null ? width / 2 : Math.min(strand.radius, Math.max(width, strand.radius * 0.4));const [nx, ny] = span > 0 ? [-(b.y - a.y) / span, (b.x - a.x) / span] : [0, 0];diff --git a/pipeline/tests/image-raster.test.ts b/pipeline/tests/image-raster.test.tsindex 28890626a..8ae02a7c2 100644--- a/pipeline/tests/image-raster.test.ts+++ b/pipeline/tests/image-raster.test.ts@@ -625,6 +625,11 @@ describe('brushes', () => {expect(px(dab, 32, 45)[3]).toBe(0);});+ it('draws a dab whatever its taper, as it has no length to taper along', () => {+ const dab = draw([paint([{ points: [[32, 32]], color: BLUE, size: 10, hardness: 1, taper: [0.1, 0.25] }])]);+ expect(px(dab, 32, 32)).toEqual([0, 0, 255, 255]);+ });+it('passes through each point of a curve', () => {const img = draw([paint([{ points: [[8, 50], [32, 12], [56, 50]], color: RED, size: 6, hardness: 1 }])]);expect(px(img, 32, 12)[3]).toBe(255);