Esempio n. 1
0
        protected override void paintFeature(Canvas canvas, Matrix4 transform)
        {
            Paint paint = new Paint {
                color = this.color.withAlpha(this._alpha.value)
            };
            Offset center = this._position;

            if (this._repositionToReferenceBox)
            {
                center = Offset.lerp(center, this.referenceBox.size.center(Offset.zero), this._radiusController.value);
            }

            Offset originOffset = transform.getAsTranslation();

            canvas.save();
            if (originOffset == null)
            {
                canvas.concat(transform.toMatrix3());
            }
            else
            {
                canvas.translate(originOffset.dx, originOffset.dy);
            }

            if (this._clipCallback != null)
            {
                Rect rect = this._clipCallback();
                if (this._customBorder != null)
                {
                    canvas.clipPath(this._customBorder.getOuterPath(rect));
                }
                else if (this._borderRadius != BorderRadius.zero)
                {
                    canvas.clipRRect(RRect.fromRectAndCorners(
                                         rect,
                                         topLeft: this._borderRadius.topLeft,
                                         topRight: this._borderRadius.topRight,
                                         bottomLeft: this._borderRadius.bottomLeft,
                                         bottomRight: this._borderRadius.bottomRight));
                }
                else
                {
                    canvas.clipRect(rect);
                }
            }

            canvas.drawCircle(center, this._radius.value, paint);
            canvas.restore();
        }