Draw() public method

public Draw ( Android.Graphics.Canvas canvas ) : void
canvas Android.Graphics.Canvas
return void
Exemplo n.º 1
0
        private void DrawAlphaPanel(Canvas canvas)
        {
            if (!_showAlphaPanel || _alphaRect == null || _alphaPattern == null)
            {
                return;
            }

            var rect = _alphaRect;

            if (BorderWidthPx > 0)
            {
                _borderPaint.Color = _borderColor;
                canvas.DrawRect(rect.Left - BorderWidthPx,
                                rect.Top - BorderWidthPx,
                                rect.Right + BorderWidthPx,
                                rect.Bottom + BorderWidthPx,
                                _borderPaint);
            }


            _alphaPattern.Draw(canvas);

            var color  = ColorUtils.ColorFromHSV(_hue / 360f, _sat, _val);
            var acolor = ColorUtils.ColorFromHSV(_hue / 360f, _sat, _val, 0);

            using (_alphaShader = new LinearGradient(rect.Left, rect.Top, rect.Right, rect.Top,
                                                     color, acolor, Shader.TileMode.Clamp))
            {
                _alphaPaint.SetShader(_alphaShader);

                canvas.DrawRect(rect, _alphaPaint);
            }

            if (!string.IsNullOrEmpty(_alphaSliderText))
            {
                canvas.DrawText(_alphaSliderText, rect.CenterX(), rect.CenterY() + 4 * _density, _alphaTextPaint);
            }

            float rectWidth = 4 * _density / 2;

            var p = AlphaToPoint(_alpha);

            var r = new RectF
            {
                Left   = p.X - rectWidth,
                Right  = p.X + rectWidth,
                Top    = rect.Top - _rectangleTrackerOffset,
                Bottom = rect.Bottom + _rectangleTrackerOffset
            };

            canvas.DrawRoundRect(r, 2, 2, _hueTrackerPaint);
        }
Exemplo n.º 2
0
        protected override void OnDraw(Canvas canvas)
        {
            var rect = _colorRect;

            if (BorderWidthPx > 0)
            {
                _borderPaint.Color = _borderColor;
                canvas.DrawRect(_drawingRect, _borderPaint);
            }

            if (_alphaPattern != null)
            {
                _alphaPattern.Draw(canvas);
            }

            _colorPaint.Color = _color;

            canvas.DrawRect(rect, _colorPaint);
        }