public override void paint(Canvas canvas, Rect rect,
            float gapStart,
            float gapExtent = 0.0f,
            float gapPercentage = 0.0f
        ) {
            if (this.borderRadius.bottomLeft != Radius.zero || this.borderRadius.bottomRight != Radius.zero) {
                canvas.clipPath(this.getOuterPath(rect));
            }

            canvas.drawLine(rect.bottomLeft, rect.bottomRight, this.borderSide.toPaint());
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        public void paint(Canvas canvas, Rect rect, Path clipPath, ImageConfiguration configuration)
        {
            D.assert(canvas != null);
            D.assert(rect != null);
            D.assert(configuration != null);

            ImageStream newImageStream = this._details.image.resolve(configuration);

            if (newImageStream.key != this._imageStream?.key)
            {
                this._imageStream?.removeListener(this._imageListener);
                this._imageStream = newImageStream;
                this._imageStream.addListener(this._imageListener);
            }

            if (this._image == null)
            {
                return;
            }

            if (clipPath != null)
            {
                canvas.save();
                canvas.clipPath(clipPath);
            }

            ImageUtils.paintImage(
                canvas: canvas,
                rect: rect,
                image: this._image.image,
                scale: this._image.scale,
                colorFilter: this._details.colorFilter,
                fit: this._details.fit,
                alignment: this._details.alignment,
                centerSlice: this._details.centerSlice,
                repeat: this._details.repeat
                );

            if (clipPath != null)
            {
                canvas.restore();
            }
        }
Esempio n. 4
0
        public void paint(Canvas canvas, Rect rect, Path clipPath, ImageConfiguration configuration)
        {
            D.assert(canvas != null);
            D.assert(rect != null);
            D.assert(configuration != null);

            bool flipHorizontally = false;

            if (_details.matchTextDirection)
            {
                D.assert(() => {
                    // We check this first so that the assert will fire immediately, not just
                    // when the image is ready.
                    if (configuration.textDirection == null)
                    {
                        throw new UIWidgetsError(new List <DiagnosticsNode>()
                        {
                            new ErrorSummary(
                                "DecorationImage.matchTextDirection can only be used when a TextDirection is available."),
                            new ErrorDescription(
                                "When DecorationImagePainter.paint() was called, there was no text direction provided " +
                                "in the ImageConfiguration object to match."
                                ),
                            new DiagnosticsProperty <DecorationImage>("The DecorationImage was", _details,
                                                                      style: DiagnosticsTreeStyle.errorProperty),
                            new DiagnosticsProperty <ImageConfiguration>("The ImageConfiguration was", configuration,
                                                                         style: DiagnosticsTreeStyle.errorProperty)
                        });
                    }

                    return(true);
                });
                if (configuration.textDirection == TextDirection.rtl)
                {
                    flipHorizontally = true;
                }
            }

            ImageStream newImageStream = _details.image.resolve(configuration);

            if (newImageStream.key != _imageStream?.key)
            {
                ImageStreamListener listener = new ImageStreamListener(
                    _handleImage,
                    onError: _details.onError
                    );
                _imageStream?.removeListener(listener);
                _imageStream = newImageStream;
                _imageStream.addListener(listener);
            }

            if (_image == null)
            {
                return;
            }

            if (clipPath != null)
            {
                canvas.save();
                canvas.clipPath(clipPath);
            }

            painting_.paintImage(
                canvas: canvas,
                rect: rect,
                image: _image.image,
                scale: _image.scale,
                colorFilter: _details.colorFilter,
                fit: _details.fit,
                alignment: _details.alignment.resolve(configuration.textDirection),
                centerSlice: _details.centerSlice,
                repeat: _details.repeat,
                flipHorizontally: flipHorizontally,
                filterQuality: FilterQuality.low
                );

            if (clipPath != null)
            {
                canvas.restore();
            }
        }