コード例 #1
0
        private void DrawSatValPanel(Canvas canvas)
        {
            #if __ANDROID_11__
            if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.Honeycomb)
            {
                RootView.SetLayerType(LayerType.Software, null);
            }
            #endif

            var rect = _satValRect;

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

            if (_valShader == null)
            {
                _valShader = new LinearGradient(rect.Left, rect.Top, rect.Left, rect.Bottom,
                                                Color.Argb(255, 255, 255, 255), Color.Argb(255, 0, 0, 0), Shader.TileMode.Clamp);
            }

            var rgb = ColorUtils.ColorFromHSV(_hue / 360f, 1f, 1f);

            using (_satShader = new LinearGradient(rect.Left, rect.Top, rect.Right, rect.Top,
                                                   Color.Argb(255, 255, 255, 255), rgb, Shader.TileMode.Clamp))
            {
                var mShader = new ComposeShader(_valShader, _satShader, PorterDuff.Mode.Multiply);
                _satValPaint.SetShader(mShader);

                canvas.DrawRect(rect, _satValPaint);
            }
            var p = SatValToPoint(_sat, _val);

            _satValTrackerPaint.Color = Color.Argb(255, 0, 0, 0);
            canvas.DrawCircle(p.X, p.Y, _paletteCircleTrackerRadius - 1f * _density, _satValTrackerPaint);

            _satValTrackerPaint.Color = Color.Argb(255, 221, 221, 221);
            canvas.DrawCircle(p.X, p.Y, _paletteCircleTrackerRadius, _satValTrackerPaint);
        }