コード例 #1
0
        public static ShapeDecoration lerp(ShapeDecoration a, ShapeDecoration b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

            if (a != null && b != null)
            {
                if (t == 0.0)
                {
                    return(a);
                }

                if (t == 1.0)
                {
                    return(b);
                }
            }

            return(new ShapeDecoration(
                       color: Color.lerp(a?.color, b?.color, t),
                       gradient: Gradient.lerp(a?.gradient, b?.gradient, t),
                       image: t < 0.5 ? a.image : b.image,
                       shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t),
                       shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
                       ));
        }
コード例 #2
0
        void _precache(Rect rect)
        {
            D.assert(rect != null);
            if (rect == _lastRect)
            {
                return;
            }

            if (_interiorPaint == null && (_decoration.color != null || _decoration.gradient != null))
            {
                _interiorPaint = new Paint();
                if (_decoration.color != null)
                {
                    _interiorPaint.color = _decoration.color;
                }
            }

            if (_decoration.gradient != null)
            {
                // this._interiorPaint.shader = this._decoration.gradient.createShader(rect);
            }

            if (_decoration.shadows != null)
            {
                if (_shadowCount == null)
                {
                    _shadowCount  = _decoration.shadows.Count;
                    _shadowPaths  = new Path[_shadowCount.Value];
                    _shadowPaints = new Paint[_shadowCount.Value];
                    for (int index = 0; index < _shadowCount.Value; index += 1)
                    {
                        _shadowPaints[index] = _decoration.shadows[index].toPaint();
                    }
                }

                for (int index = 0; index < _shadowCount; index += 1)
                {
                    BoxShadow shadow = _decoration.shadows[index];
                    _shadowPaths[index] = _decoration.shape.getOuterPath(
                        rect.shift(shadow.offset).inflate(shadow.spreadRadius));
                }
            }

            if (_interiorPaint != null || _shadowCount != null)
            {
                _outerPath = _decoration.shape.getOuterPath(rect);
            }

            if (_decoration.image != null)
            {
                _innerPath = _decoration.shape.getInnerPath(rect);
            }

            _lastRect = rect;
        }
コード例 #3
0
 public BoxDecoration scale(float factor)
 {
     return(new BoxDecoration(
                color: Color.lerp(null, this.color, factor),
                image: this.image,
                border: Border.lerp(null, this.border, factor),
                borderRadius: BorderRadius.lerp(null, this.borderRadius, factor),
                boxShadow: BoxShadow.lerpList(null, this.boxShadow, factor),
                gradient: this.gradient?.scale(factor),
                backgroundBlendMode: this.backgroundBlendMode,
                shape: this.shape
                ));
 }
コード例 #4
0
        public static BoxDecoration lerp(BoxDecoration a, BoxDecoration b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

            if (a == null)
            {
                return(b.scale(t));
            }

            if (b == null)
            {
                return(a.scale(1.0f - t));
            }

            if (t == 0.0)
            {
                return(a);
            }

            if (t == 1.0)
            {
                return(b);
            }

            return(new BoxDecoration(
                       color: Color.lerp(a.color, b.color, t),
                       image: t < 0.5 ? a.image : b.image,
                       border: Border.lerp(a.border, b.border, t),
                       borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t),
                       boxShadow: BoxShadow.lerpList(a.boxShadow, b.boxShadow, t),
                       gradient: Gradient.lerp(a.gradient, b.gradient, t),
                       backgroundBlendMode: t < 0.5 ? a.backgroundBlendMode : b.backgroundBlendMode,
                       shape: t < 0.5 ? a.shape : b.shape
                       ));
        }