示例#1
0
        public override void paint(Canvas canvas, Rect rect, TextDirection?textDirection = null)
        {
            switch (side.style)
            {
            case BorderStyle.none:
                break;

            case BorderStyle.solid:
                float width = side.width;
                if (width == 0.0)
                {
                    canvas.drawRRect(borderRadius.resolve(textDirection).toRRect(rect), side.toPaint());
                }
                else
                {
                    RRect outer = borderRadius.resolve(textDirection).toRRect(rect);
                    RRect inner = outer.deflate(width);
                    Paint paint = new Paint {
                        color = side.color,
                    };
                    canvas.drawDRRect(outer, inner, paint);
                }

                break;
            }
        }
        public override void paint(
            PaintingContext context,
            Offset center,
            Animation <float> activationAnimation = null,
            Animation <float> enableAnimation     = null,
            bool?isDiscrete             = null,
            TextPainter labelPainter    = null,
            RenderBox parentBox         = null,
            SliderThemeData sliderTheme = null,
            float?value = null
            )
        {
            Canvas     canvas      = context.canvas;
            FloatTween radiusTween = new FloatTween(
                begin: 0.0f,
                end: this.overlayRadius
                );

            canvas.drawCircle(
                center,
                radiusTween.evaluate(activationAnimation),
                new Paint {
                color = sliderTheme.overlayColor
            }
                );
        }
示例#3
0
        void paintArrowhead(Canvas canvas, Size size)
        {
            float arcEnd = this.arcStart + this.arcSweep ?? 0.0f;
            float ux     = Mathf.Cos(arcEnd);
            float uy     = Mathf.Sin(arcEnd);

            D.assert(size.width == size.height);
            float radius          = size.width / 2.0f;
            float?arrowheadPointX = radius + ux * radius + -uy * this.strokeWidth * 2.0f * this.arrowheadScale;
            float?arrowheadPointY = radius + uy * radius + ux * this.strokeWidth * 2.0f * this.arrowheadScale;
            float?arrowheadRadius = this.strokeWidth * 1.5f * this.arrowheadScale;
            float?innerRadius     = radius - arrowheadRadius;
            float?outerRadius     = radius + arrowheadRadius;

            Path path = new Path();

            path.moveTo(radius + ux * innerRadius ?? 0.0f, radius + uy * innerRadius ?? 0.0f);
            path.lineTo(radius + ux * outerRadius ?? 0.0f, radius + uy * outerRadius ?? 0.0f);
            path.lineTo(arrowheadPointX ?? 0.0f, arrowheadPointY ?? 0.0f);
            path.close();
            Paint paint = new Paint();

            paint.color       = this.valueColor;
            paint.strokeWidth = this.strokeWidth ?? 0.0f;
            paint.style       = PaintingStyle.fill;
            canvas.drawPath(path, paint);
        }
示例#4
0
 void _paintBackgroundColor(Canvas canvas, Rect rect, TextDirection textDirection)
 {
     if (_decoration.color != null || _decoration.gradient != null)
     {
         _paintBox(canvas, rect, _getBackgroundPaint(rect, textDirection), textDirection);
     }
 }
示例#5
0
        public void paint(Canvas canvas, Size size)
        {
            if (this._lastAxisDirection == null ||
                this._lastMetrics == null ||
                this.fadeoutOpacityAnimation.value == 0.0)
            {
                return;
            }

            switch (this._lastAxisDirection)
            {
            case AxisDirection.down:
                this._paintThumb(this._lastMetrics.extentBefore(), this._lastMetrics.extentInside(),
                                 this._lastMetrics.extentAfter(), size.height, canvas, size, this._paintVerticalThumb);
                break;

            case AxisDirection.up:
                this._paintThumb(this._lastMetrics.extentAfter(), this._lastMetrics.extentInside(),
                                 this._lastMetrics.extentBefore(), size.height, canvas, size, this._paintVerticalThumb);
                break;

            case AxisDirection.right:
                this._paintThumb(this._lastMetrics.extentBefore(), this._lastMetrics.extentInside(),
                                 this._lastMetrics.extentAfter(), size.width, canvas, size, this._paintHorizontalThumb);
                break;

            case AxisDirection.left:
                this._paintThumb(this._lastMetrics.extentAfter(), this._lastMetrics.extentInside(),
                                 this._lastMetrics.extentBefore(), size.width, canvas, size, this._paintHorizontalThumb);
                break;
            }
        }
示例#6
0
        protected bool _presentSurface(Canvas canvas)
        {
            if (canvas == null)
            {
                return(false);
            }

            this._surface.getCanvas().flush();
            this._surface.getCanvas().reset();

            var screenRect = new Rect(0, 0,
                                      this._surface.size.width / this._surface.devicePixelRatio,
                                      this._surface.size.height / this._surface.devicePixelRatio);

            if (this._drawToTargetFunc == null)
            {
                Graphics.DrawTexture(screenRect, this._surface.getRenderTexture(),
                                     _getGUITextureMat());
            }
            else
            {
                this._drawToTargetFunc(screenRect, this._surface.getRenderTexture(),
                                       _getUIDefaultMat());
            }

            return(true);
        }
        void _paintBackgroundImage(Canvas canvas, Rect rect, ImageConfiguration configuration)
        {
            if (this._decoration.image == null)
            {
                return;
            }

            this._imagePainter = this._imagePainter ?? this._decoration.image.createPainter(this.onChanged);

            Path clipPath = null;

            switch (this._decoration.shape)
            {
            case BoxShape.circle:
                clipPath = new Path();
                clipPath.addOval(rect);
                break;

            case BoxShape.rectangle:
                if (this._decoration.borderRadius != null)
                {
                    clipPath = new Path();
                    clipPath.addRRect(this._decoration.borderRadius.toRRect(rect));
                }

                break;
            }

            this._imagePainter.paint(canvas, rect, clipPath, configuration);
        }
示例#8
0
        void _paintTickMarks(
            Canvas canvas,
            Rect trackLeft,
            Rect trackRight,
            Paint leftPaint,
            Paint rightPaint)
        {
            if (this.isDiscrete)
            {
                const float tickRadius = _trackHeight / 2.0f;
                float       trackWidth = trackRight.right - trackLeft.left;
                float       dx         = (trackWidth - _trackHeight) / this.divisions.Value;

                if (dx >= 3.0 * _trackHeight)
                {
                    for (int i = 0; i <= this.divisions.Value; i += 1)
                    {
                        float  left   = trackLeft.left + i * dx;
                        Offset center = new Offset(left + tickRadius, trackLeft.top + tickRadius);
                        if (trackLeft.contains(center))
                        {
                            canvas.drawCircle(center, tickRadius, leftPaint);
                        }
                        else if (trackRight.contains(center))
                        {
                            canvas.drawCircle(center, tickRadius, rightPaint);
                        }
                    }
                }
            }
        }
示例#9
0
        public override void paint(PaintingContext context, Offset offset)
        {
            Canvas canvas = context.canvas;

            this._drawButtonBackgroundsAndDividersStacked(canvas, offset);
            this._drawButtons(context, offset);
        }
        public void draw(Canvas canvas)
        {
            var boundRect = canvas.getTotalMatrix().mapRect(this.logicalRect);
            var bounds    = boundRect.withDevicePixelRatio(this.devicePixelRatio);

            D.assert(() => {
                var boundsInPixel = boundRect.roundOutScale(this.devicePixelRatio);
                var textureWidth  = Mathf.CeilToInt(boundsInPixel.width);
                var textureHeight = Mathf.CeilToInt(boundsInPixel.height);

                //it is possible that there is a minor difference between the bound size and the image size (1 pixel at
                //most) due to the roundOut operation when calculating the bounds if the elements in the canvas transform
                //is not all integer
                D.assert(Mathf.Abs(this.image.width - textureWidth) <= 1);
                D.assert(Mathf.Abs(this.image.height - textureHeight) <= 1);
                return(true);
            });

            canvas.save();
            try {
                canvas.resetMatrix();
                canvas.drawImage(this.image, bounds.topLeft, new Paint());
            }
            finally {
                canvas.restore();
            }
        }
示例#11
0
        public static void drawShadow(Canvas canvas, Path path, Color color, float elevation, bool transparentOccluder,
                                      float dpr)
        {
            Rect  bounds   = path.getBounds();
            float shadow_x = (bounds.left + bounds.right) / 2f;
            float shadow_y = bounds.top - 600.0f;

            uiColor uicolor = uiColor.fromColor(color);

            uiColor inAmbient    = uicolor.withAlpha((int)(kAmbientAlpha * uicolor.alpha));
            uiColor inSpot       = uicolor.withAlpha((int)(kSpotAlpha * uicolor.alpha));
            uiColor?ambientColor = null;
            uiColor?spotColor    = null;

            ShadowUtils.computeTonalColors(inAmbient, inSpot, ref ambientColor, ref spotColor);
            ShadowUtils.drawShadow(
                canvas,
                path,
                new Vector3(0, 0, dpr * elevation),
                new Vector3(shadow_x, shadow_y, dpr * kLightHeight),
                dpr * kLightRadius,
                ambientColor.Value,
                spotColor.Value,
                0
                );
        }
        Path _gapBorderPath(Canvas canvas, RRect center, float start, float extent) {
            Rect tlCorner = Rect.fromLTWH(
                center.left,
                center.top,
                center.tlRadiusX * 2.0f,
                center.tlRadiusY * 2.0f
            );
            Rect trCorner = Rect.fromLTWH(
                center.right - center.trRadiusX * 2.0f,
                center.top,
                center.trRadiusX * 2.0f,
                center.trRadiusY * 2.0f
            );
            Rect brCorner = Rect.fromLTWH(
                center.right - center.brRadiusX * 2.0f,
                center.bottom - center.brRadiusY * 2.0f,
                center.brRadiusX * 2.0f,
                center.brRadiusY * 2.0f
            );
            Rect blCorner = Rect.fromLTWH(
                center.left,
                center.bottom - center.brRadiusY * 2.0f,
                center.blRadiusX * 2.0f,
                center.blRadiusY * 2.0f
            );

            const float cornerArcSweep = Mathf.PI / 2.0f;
            float tlCornerArcSweep = start < center.tlRadiusX
                ? Mathf.Asin((start / center.tlRadiusX).clamp(-1.0f, 1.0f))
                : Mathf.PI / 2.0f;

            Path path = new Path();
            path.addArc(tlCorner, Mathf.PI, tlCornerArcSweep);
            path.moveTo(center.left + center.tlRadiusX, center.top);

            if (start > center.tlRadiusX) {
                path.lineTo(center.left + start, center.top);
            }

            const float trCornerArcStart = (3 * Mathf.PI) / 2.0f;
            const float trCornerArcSweep = cornerArcSweep;
            if (start + extent < center.width - center.trRadiusX) {
                path.relativeMoveTo(extent, 0.0f);
                path.lineTo(center.right - center.trRadiusX, center.top);
                path.addArc(trCorner, trCornerArcStart, trCornerArcSweep);
            }
            else if (start + extent < center.width) {
                float dx = center.width - (start + extent);
                float sweep = Mathf.Acos(dx / center.trRadiusX);
                path.addArc(trCorner, trCornerArcStart + sweep, trCornerArcSweep - sweep);
            }

            path.moveTo(center.right, center.top + center.trRadiusY);
            path.lineTo(center.right, center.bottom - center.brRadiusY);
            path.addArc(brCorner, 0.0f, cornerArcSweep);
            path.lineTo(center.left + center.blRadiusX, center.bottom);
            path.addArc(blCorner, Mathf.PI / 2.0f, cornerArcSweep);
            path.lineTo(center.left, center.top + center.trRadiusY);
            return path;
        }
示例#13
0
        // describeSemanticsConfiguration todo

        void _paintCaret(Canvas canvas, Offset effectiveOffset)
        {
            D.assert(this._textLayoutLastWidth == this.constraints.maxWidth);
            var caretOffset = this._textPainter.getOffsetForCaret(this._selection.extendPos, this._caretPrototype);
            var paint       = new Paint()
            {
                color = this._cursorColor
            };
            var caretRect = this._caretPrototype.shift(caretOffset + effectiveOffset);

            if (this.cursorRadius == null)
            {
                canvas.drawRect(caretRect, paint);
            }
            else
            {
                RRect caretRRect = RRect.fromRectAndRadius(caretRect, this.cursorRadius);
                canvas.drawRRect(caretRRect, paint);
            }
            if (!caretRect.Equals(this._lastCaretRect))
            {
                this._lastCaretRect = caretRect;
                if (this.onCaretChanged != null)
                {
                    this.onCaretChanged(caretRect);
                }
            }
        }
        public override void paint(Canvas canvas, Size size)
        {
            Paint paint = new Paint();

            paint.color       = this.valueColor;
            paint.strokeWidth = this.strokeWidth ?? 0.0f;
            paint.style       = PaintingStyle.stroke;

            if (this.backgroundColor != null)
            {
                Paint backgroundPaint = new Paint()
                {
                    color       = this.backgroundColor,
                    strokeWidth = this.strokeWidth ?? 0.0f,
                    style       = PaintingStyle.stroke
                };
                canvas.drawArc(Offset.zero & size, 0, _sweep, false, backgroundPaint);
            }

            if (this.value == null)
            {
                paint.strokeCap = StrokeCap.square;
            }

            canvas.drawArc(Offset.zero & size, this.arcStart ?? 0.0f, this.arcSweep ?? 0.0f, false, paint);
        }
示例#15
0
        public override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration)
        {
            LinearGradient gradient = _decoration.edgeGradient;

            if (gradient == null)
            {
                return;
            }
            TextDirection textDirection = configuration.textDirection;
            float         deltaX        = 0.0f;

            switch (textDirection)
            {
            case TextDirection.rtl:
                deltaX = configuration.size.width;
                break;

            case TextDirection.ltr:
                deltaX = -configuration.size.width;
                break;
            }
            Rect  rect  = (offset & configuration.size).translate(deltaX, 0.0f);
            Paint paint = new Paint()
            {
                shader = gradient.createShader(rect, textDirection: textDirection)
            };

            canvas.drawRect(rect, paint);
        }
示例#16
0
        public static void drawShadow(Canvas canvas, Path path, Color color, float elevation, bool transparentOccluder,
                                      float dpr)
        {
            float kAmbientAlpha = 0.039f;
            float kSpotAlpha    = ShadowUtils.kUseFastShadow ? 0.1f : 0.25f;
            float kLightHeight  = 600f;
            float kLightRadius  = 800f;

            Rect  bounds   = path.getBounds();
            float shadow_x = (bounds.left + bounds.right) / 2f;
            float shadow_y = bounds.top - 600.0f;

            _inAmbient    = color.withAlpha((int)(kAmbientAlpha * color.alpha));
            _inSpot       = color.withAlpha((int)(kSpotAlpha * color.alpha));
            _ambientColor = null;
            _spotColor    = null;
            ShadowUtils.computeTonalColors(_inAmbient, _inSpot, ref _ambientColor, ref _spotColor);

            _zPlane.Set(0, 0, dpr * elevation);
            _devLight.Set(shadow_x, shadow_y, dpr * kLightHeight);

            ShadowUtils.drawShadow(
                canvas,
                path,
                _zPlane,
                _devLight,
                dpr * kLightRadius,
                _ambientColor,
                _spotColor,
                0
                );
        }
示例#17
0
        void _drawButtonBackgroundsAndDividersStacked(Canvas canvas, Offset offset)
        {
            Offset dividerOffset      = new Offset(0.0f, this.dividerThickness);
            Path   backgroundFillPath = new Path();

            // fillType = PathFillType.evenOdd
            backgroundFillPath.addRect(Rect.fromLTWH(0.0f, 0.0f, this.size.width, this.size.height));

            Path      pressedBackgroundFillPath = new Path();
            Path      dividersPath       = new Path();
            Offset    accumulatingOffset = offset;
            RenderBox child     = this.firstChild;
            RenderBox prevChild = null;

            while (child != null)
            {
                D.assert(child.parentData is _ActionButtonParentData);
                _ActionButtonParentData currentButtonParentData = child.parentData as _ActionButtonParentData;
                bool isButtonPressed     = currentButtonParentData.isPressed;
                bool isPrevButtonPressed = false;
                if (prevChild != null)
                {
                    D.assert(prevChild.parentData is _ActionButtonParentData);
                    _ActionButtonParentData previousButtonParentData = prevChild.parentData as _ActionButtonParentData;
                    isPrevButtonPressed = previousButtonParentData.isPressed;
                }

                bool isDividerPresent = child != this.firstChild;
                bool isDividerPainted = isDividerPresent && !(isButtonPressed || isPrevButtonPressed);
                Rect dividerRect      = Rect.fromLTWH(
                    accumulatingOffset.dx,
                    accumulatingOffset.dy, this.size.width, this._dividerThickness
                    );
                Rect buttonBackgroundRect = Rect.fromLTWH(
                    accumulatingOffset.dx,
                    accumulatingOffset.dy + (isDividerPresent ? this.dividerThickness : 0.0f), this.size.width,
                    child.size.height
                    );
                if (isButtonPressed)
                {
                    backgroundFillPath.addRect(buttonBackgroundRect);
                    pressedBackgroundFillPath.addRect(buttonBackgroundRect);
                }

                if (isDividerPainted)
                {
                    backgroundFillPath.addRect(dividerRect);
                    dividersPath.addRect(dividerRect);
                }

                accumulatingOffset += (isDividerPresent ? dividerOffset : Offset.zero)
                                      + new Offset(0.0f, child.size.height);
                prevChild = child;
                child     = this.childAfter(child);
            }

            canvas.drawPath(backgroundFillPath, this._buttonBackgroundPaint);
            canvas.drawPath(pressedBackgroundFillPath, this._pressedButtonBackgroundPaint);
            canvas.drawPath(dividersPath, this._dividerPaint);
        }
示例#18
0
 public override void paint(Canvas canvas, Rect rect,
                            float gapStart,
                            float gapExtent     = 0.0f,
                            float gapPercentage = 0.0f
                            )
 {
 }
示例#19
0
        public void visualize(Canvas canvas, Rect rect)
        {
            Paint paint = new Paint {
                color = Colors.blue
            };
            Paint paint2 = new Paint {
                color = Colors.red
            };
            Paint paint3 = new Paint {
                color = Colors.green
            };
            Paint paint4 = new Paint {
                color = Colors.white70
            };

            float[] costFrames = this._laps;
            int     curFrame   = (this._currentSample - 1) % InstrumentationUtils.kMaxSamples;

            float barWidth  = Mathf.Max(1, rect.width / costFrames.Length);
            float perHeight = rect.height / 32.0f;

            canvas.drawRect(rect, paint4);
            canvas.drawRect(Rect.fromLTWH(rect.left, rect.top + perHeight * 16.0f, rect.width, 1), paint3);

            float cur_x   = rect.left;
            Path  barPath = new Path();

            for (var i = 0; i < costFrames.Length; i++)
            {
                if (costFrames[i] != 0)
                {
                    float curHeight = Mathf.Min(perHeight * costFrames[i] * 1000, rect.height);
                    Rect  barRect   = Rect.fromLTWH(cur_x, rect.top + rect.height - curHeight, barWidth, curHeight);
                    barPath.addRect(barRect);
                }

                cur_x += barWidth;
            }

            canvas.drawPath(barPath, paint);
            if (curFrame >= 0 && curFrame < costFrames.Length)
            {
                if (costFrames[curFrame] != 0)
                {
                    float curHeight = Mathf.Min(perHeight * costFrames[curFrame] * 1000, rect.height);
                    Rect  barRect   = Rect.fromLTWH(rect.left + barWidth * curFrame, rect.top + rect.height - curHeight,
                                                    barWidth, curHeight);
                    canvas.drawRect(barRect, paint2);
                }

                var pb = new ParagraphBuilder(new ParagraphStyle {
                });
                pb.addText("Current Frame Cost: " + costFrames[curFrame] * 1000 + "ms" +
                           " ; Max(in last 120 frames): " + this.maxDelta() * 1000 + "ms");
                var paragraph = pb.build();
                paragraph.layout(new ParagraphConstraints(width: 800));

                canvas.drawParagraph(paragraph, new Offset(rect.left, rect.top + rect.height - 12));
            }
        }
示例#20
0
        public override void paint(PaintingContext context, Offset offset)
        {
            D.assert(this._children.Count == this.rows * this.columns);
            if (this.rows * this.columns == 0)
            {
                if (this.border != null)
                {
                    Rect borderRect = Rect.fromLTWH(offset.dx, offset.dy, this.size.width, 0.0f);
                    this.border.paint(context.canvas, borderRect, rows: new List <float>(), columns: new List <float>());
                }

                return;
            }

            D.assert(this._rowTops.Count == this.rows + 1);
            if (this._rowDecorations != null)
            {
                Canvas canvas = context.canvas;
                for (int y = 0; y < this.rows; y++)
                {
                    if (this._rowDecorations.Count <= y)
                    {
                        break;
                    }

                    if (this._rowDecorations[y] != null)
                    {
                        this._rowDecorationPainters[y] = this._rowDecorationPainters[y] ??
                                                         this._rowDecorations[y].createBoxPainter(this.markNeedsPaint);
                        this._rowDecorationPainters[y].paint(
                            canvas,
                            new Offset(offset.dx, offset.dy + this._rowTops[y]),
                            this.configuration.copyWith(
                                size: new Size(this.size.width, this._rowTops[y + 1] - this._rowTops[y])
                                )
                            );
                    }
                }
            }

            for (int index = 0; index < this._children.Count; index++)
            {
                RenderBox child = this._children[index];
                if (child != null)
                {
                    BoxParentData childParentData = (BoxParentData)child.parentData;
                    context.paintChild(child, childParentData.offset + offset);
                }
            }

            D.assert(this._rows == this._rowTops.Count - 1);
            D.assert(this._columns == this._columnLefts.Count);
            if (this.border != null)
            {
                Rect         borderRect = Rect.fromLTWH(offset.dx, offset.dy, this.size.width, this._rowTops.Last());
                List <float> rows       = this._rowTops.GetRange(1, this._rowTops.Count - 2);
                List <float> columns    = this._columnLefts.GetRange(1, this._columnLefts.Count - 1);
                this.border.paint(context.canvas, borderRect, rows: rows, columns: columns);
            }
        }
 void _paintBackgroundColor(Canvas canvas, Rect rect)
 {
     if (this._decoration.color != null || this._decoration.gradient != null)
     {
         this._paintBox(canvas, rect, this._getBackgroundPaint(rect));
     }
 }
示例#22
0
        void _drawCheck(Canvas canvas, Offset origin, float t, Paint paint)
        {
            D.assert(t >= 0.0f && t <= 1.0f);
            Path   path  = new Path();
            Offset start = new Offset(CheckboxUtils._kEdgeSize * 0.15f, CheckboxUtils._kEdgeSize * 0.45f);
            Offset mid   = new Offset(CheckboxUtils._kEdgeSize * 0.4f, CheckboxUtils._kEdgeSize * 0.7f);
            Offset end   = new Offset(CheckboxUtils._kEdgeSize * 0.85f, CheckboxUtils._kEdgeSize * 0.25f);

            if (t < 0.5f)
            {
                float  strokeT = t * 2.0f;
                Offset drawMid = Offset.lerp(start, mid, strokeT);
                path.moveTo(origin.dx + start.dx, origin.dy + start.dy);
                path.lineTo(origin.dx + drawMid.dx, origin.dy + drawMid.dy);
            }
            else
            {
                float  strokeT = (t - 0.5f) * 2.0f;
                Offset drawEnd = Offset.lerp(mid, end, strokeT);
                path.moveTo(origin.dx + start.dx, origin.dy + start.dy);
                path.lineTo(origin.dx + mid.dx, origin.dy + mid.dy);
                path.lineTo(origin.dx + drawEnd.dx, origin.dy + drawEnd.dy);
            }

            canvas.drawPath(path, paint);
        }
示例#23
0
        public override void paint(PaintingContext context, Offset offset)
        {
            Canvas canvas               = context.canvas;
            float  currentValue         = _state.position.value;
            float  currentReactionValue = _state._reaction.value;

            float visualPosition = 0.0f;

            switch (textDirection)
            {
            case TextDirection.rtl:
                visualPosition = 1.0f - currentValue;
                break;

            case TextDirection.ltr:
                visualPosition = currentValue;
                break;
            }

            Paint paint = new Paint()
            {
                color = Color.lerp(trackColor, activeColor, currentValue)
            };
            Rect trackRect = Rect.fromLTWH(
                offset.dx + (size.width - CupertinoSwitchUtils._kTrackWidth) / 2.0f,
                offset.dy + (size.height - CupertinoSwitchUtils._kTrackHeight) / 2.0f,
                CupertinoSwitchUtils._kTrackWidth,
                CupertinoSwitchUtils._kTrackHeight
                );
            RRect trackRRect = RRect.fromRectAndRadius(trackRect, Radius.circular(CupertinoSwitchUtils._kTrackRadius));

            canvas.drawRRect(trackRRect, paint);

            float currentThumbExtension = CupertinoThumbPainter.extension * currentReactionValue;
            float thumbLeft             = MathUtils.lerpNullableFloat(
                trackRect.left + CupertinoSwitchUtils._kTrackInnerStart - CupertinoThumbPainter.radius,
                trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd - CupertinoThumbPainter.radius -
                currentThumbExtension,
                visualPosition
                );
            float thumbRight = MathUtils.lerpNullableFloat(
                trackRect.left + CupertinoSwitchUtils._kTrackInnerStart + CupertinoThumbPainter.radius +
                currentThumbExtension,
                trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd + CupertinoThumbPainter.radius,
                visualPosition
                );
            float thumbCenterY = offset.dy + size.height / 2.0f;
            Rect  thumbBounds  = Rect.fromLTRB(
                thumbLeft,
                thumbCenterY - CupertinoThumbPainter.radius,
                thumbRight,
                thumbCenterY + CupertinoThumbPainter.radius
                );

            context.pushClipRRect(needsCompositing, Offset.zero, thumbBounds, trackRRect,
                                  (PaintingContext innerContext, Offset offset1) => {
                CupertinoThumbPainter.switchThumb().paint(innerContext.canvas, thumbBounds);
            });
        }
示例#24
0
 public override void paint(Canvas canvas, Rect rect)
 {
     foreach (ShapeBorder border in this.borders)
     {
         border.paint(canvas, rect);
         rect = border.dimensions.deflateRect(rect);
     }
 }
示例#25
0
        void _drawBorder(Canvas canvas, RRect outer, float t, Paint paint)
        {
            D.assert(t >= 0.0f && t <= 0.5f);
            float size  = outer.width;
            RRect inner = outer.deflate(Mathf.Min(size / 2.0f, CheckboxUtils._kStrokeWidth + size * t));

            canvas.drawDRRect(outer, inner, paint);
        }
示例#26
0
 public override void paint(Canvas canvas, Size size)
 {
     base.paint(canvas, size);
     if (this.arrowheadScale > 0.0)
     {
         this.paintArrowhead(canvas, size);
     }
 }
示例#27
0
 public override void paint(Canvas canvas, Rect rect, TextDirection?textDirection = null)
 {
     foreach (ShapeBorder border in borders)
     {
         border.paint(canvas, rect, textDirection);
         rect = border.dimensions.resolve(textDirection).deflateRect(rect);
     }
 }
示例#28
0
 void _paintDividerBetweenContentAndActions(Canvas canvas, Offset offset)
 {
     canvas.drawRect(
         Rect.fromLTWH(
             offset.dx,
             offset.dy + this.contentSection.size.height, this.size.width, this._dividerThickness
             ), this._dividerPaint
         );
 }
示例#29
0
 void _paintShadows(Canvas canvas, Rect rect)
 {
     foreach (BoxShadow boxShadow in boxShadows)
     {
         Paint paint = boxShadow.toPaint();
         canvas.drawRRect(
             MaterialConstantsUtils.kMaterialEdges[MaterialType.card].toRRect(rect), paint);
     }
 }
示例#30
0
        public override void paint(
            PaintingContext context,
            Offset center,
            Animation <float> activationAnimation = null,
            Animation <float> enableAnimation     = null,
            bool isDiscrete             = false,
            bool isEnabled              = false,
            bool?isOnTop                = null,
            TextDirection?textDirection = null,
            SliderThemeData sliderTheme = null,
            Thumb?thumb = null
            )
        {
            Canvas     canvas     = context.canvas;
            ColorTween colorTween = new ColorTween(
                begin: sliderTheme.disabledThumbColor,
                end: sliderTheme.thumbColor
                );

            float size      = _thumbSize * sizeTween.evaluate(enableAnimation);
            Path  thumbPath = null;

            switch (textDirection)
            {
            case TextDirection.rtl:
                switch (thumb)
                {
                case Thumb.start:
                    thumbPath = SliderDemoUtils._rightTriangle(size, center);
                    break;

                case Thumb.end:
                    thumbPath = SliderDemoUtils._leftTriangle(size, center);
                    break;
                }

                break;

            case TextDirection.ltr:
                switch (thumb)
                {
                case Thumb.start:
                    thumbPath = SliderDemoUtils._leftTriangle(size, center);
                    break;

                case Thumb.end:
                    thumbPath = SliderDemoUtils._rightTriangle(size, center);
                    break;
                }

                break;
            }

            canvas.drawPath(thumbPath, new Paint {
                color = colorTween.evaluate(enableAnimation)
            });
        }