// Tests for tipVelocityWidthScale (physical tip model). import 'package:flutter_test/flutter_test.dart'; import 'package:badnote/editor/engine/brush.dart'; import 'package:badnote/editor/engine/pen_physics.dart'; void main() { group('tipVelocityWidthScale', () { test('idle speed leaves all brushes at 1.0', () { for (final k in BrushKind.values) { expect(tipVelocityWidthScale(k, 0.0), closeTo(1.0, 1e-9)); } }); test('fountain thins more than ballpoint at the same speed', () { const speed = 2.0; // reference fast handwriting final fountain = tipVelocityWidthScale(BrushKind.fountainPen, speed); final ballpoint = tipVelocityWidthScale(BrushKind.ballpoint, speed); expect(fountain, closeTo(0.85, 1e-9)); expect(ballpoint, closeTo(0.98, 1e-9)); expect(fountain, lessThan(ballpoint)); }); test('highlighter ignores velocity', () { expect(tipVelocityWidthScale(BrushKind.highlighter, 5.0), 1.0); }); test('NaN / negative speed treated as idle', () { expect(tipVelocityWidthScale(BrushKind.fountainPen, double.nan), 1.0); expect(tipVelocityWidthScale(BrushKind.fountainPen, -1.0), 1.0); }); }); }