BubbleClipper constructor
BubbleClipper({})
Implementation
BubbleClipper({
required this.radius,
required this.showNip,
required this.nip,
required this.nipWidth,
required this.nipHeight,
required this.nipOffset,
required this.nipRadius,
required this.stick,
required this.padding,
}) : assert(nipWidth > 0),
assert(nipHeight > 0),
assert(nipRadius >= 0),
assert(nipRadius <= nipWidth / 2 && nipRadius <= nipHeight / 2),
super() {
if (nip == BubbleNip.no) return;
_startOffset = _endOffset = nipWidth;
final isCenter =
nip == BubbleNip.leftCenter || nip == BubbleNip.rightCenter;
final k = isCenter ? nipHeight / 2 / nipWidth : nipHeight / nipWidth;
final a = atan(k);
_nipCX = isCenter
? sqrt(nipRadius * nipRadius * (1 + 1 / k / k))
: (nipRadius + sqrt(nipRadius * nipRadius * (1 + k * k))) / k;
final nipStickOffset = (_nipCX - nipRadius).floorToDouble();
_nipCX -= nipStickOffset;
_nipCY = isCenter ? 0 : nipRadius;
_nipPX = _nipCX - nipRadius * sin(a);
_nipPY = _nipCY + nipRadius * cos(a);
_startOffset -= nipStickOffset;
_endOffset -= nipStickOffset;
if (stick) _endOffset = 0;
}