コード例 #1
0
 public override void PushClip(RRect rect)
 {
     _clipStack.Push(_g.PushClip(Util.Convert(rect)));
     //_clipStack.Push(rect);
     //_g.PushClip(new RectangleGeometry(Utils.Convert(rect)));
 }
コード例 #2
0
 /// <summary>
 /// Get TextureBrush object that uses the specified image and bounding rectangle.
 /// </summary>
 /// <param name="image">The Image object with which this TextureBrush object fills interiors.</param>
 /// <param name="dstRect">A Rectangle structure that represents the bounding rectangle for this TextureBrush object.</param>
 /// <param name="translateTransformLocation">The dimension by which to translate the transformation</param>
 public abstract RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation);
コード例 #3
0
 /// <summary>
 /// Get linear gradient color brush from <paramref name="color1"/> to <paramref name="color2"/>.
 /// </summary>
 /// <param name="rect">the rectangle to get the brush for</param>
 /// <param name="color1">the start color of the gradient</param>
 /// <param name="color2">the end color of the gradient</param>
 /// <param name="angle">the angle to move the gradient from start color to end color in the rectangle</param>
 /// <returns>linear gradient color brush instance</returns>
 public RBrush GetLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
 {
     return(_adapter.GetLinearGradientBrush(rect, color1, color2, angle));
 }
コード例 #4
0
 public override void DrawImage(RImage image, RRect destRect)
 {
     ReleaseHdc();
     _g.DrawImage(((ImageAdapter)image).Image, Utils.Convert(destRect));
 }
コード例 #5
0
 /// <summary>
 /// Push the clipping region of this Graphics to interception of current clipping rectangle and the given rectangle.
 /// </summary>
 /// <param name="rect">Rectangle to clip to.</param>
 public abstract void PushClip(RRect rect);
コード例 #6
0
 /// <summary>
 /// Convert from core rectangle to WinForms rectangle.
 /// </summary>
 public static XRect Convert(RRect r)
 {
     return(new XRect(r.X, r.Y, r.Width, r.Height));
 }
コード例 #7
0
 public override void PushClipExclude(RRect rect)
 {
     ReleaseHdc();
     _clipStack.Push(_clipStack.Peek());
     _g.SetClip(Utils.Convert(rect), CombineMode.Exclude);
 }
コード例 #8
0
        public override void paint(PaintingContext context, Offset offset)
        {
            Canvas canvas = context.canvas;

            float currentValue         = this._position.value;
            float currentReactionValue = this._reaction.value;

            float visualPosition = 0f;

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

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

            Color trackColor      = this._value ? this.activeColor : CupertinoSwitchUtils._kTrackColor;
            float borderThickness =
                1.5f + (CupertinoSwitchUtils._kTrackRadius - 1.5f) * Mathf.Max(currentReactionValue, currentValue);

            Paint paint = new Paint();

            paint.color = trackColor;

            Rect trackRect = Rect.fromLTWH(
                offset.dx + (this.size.width - CupertinoSwitchUtils._kTrackWidth) / 2.0f,
                offset.dy + (this.size.height - CupertinoSwitchUtils._kTrackHeight) / 2.0f,
                CupertinoSwitchUtils._kTrackWidth,
                CupertinoSwitchUtils._kTrackHeight
                );
            RRect outerRRect = RRect.fromRectAndRadius(trackRect, Radius.circular(CupertinoSwitchUtils
                                                                                  ._kTrackRadius));
            RRect innerRRect = RRect.fromRectAndRadius(trackRect.deflate(borderThickness), Radius.circular
                                                           (CupertinoSwitchUtils._kTrackRadius));

            canvas.drawDRRect(outerRRect, innerRRect, paint);

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

            this._thumbPainter.paint(canvas, Rect.fromLTRB(
                                         thumbLeft,
                                         thumbCenterY - CupertinoThumbPainter.radius,
                                         thumbRight,
                                         thumbCenterY + CupertinoThumbPainter.radius
                                         ));
        }
コード例 #9
0
ファイル: input_border.cs プロジェクト: JC-ut0/CubeGame
        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);
        }
コード例 #10
0
        /// <summary>
        /// Draw image failed to load icon.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="htmlContainer"></param>
        /// <param name="r">the rectangle to draw icon in</param>
        public static void DrawImageErrorIcon(RGraphics g, HtmlContainerInt htmlContainer, RRect r)
        {
            g.DrawRectangle(g.GetPen(RColor.LightGray), r.Left + 2, r.Top + 2, 15, 15);
            var image = htmlContainer.Adapter.GetLoadingFailedImage();

            g.DrawImage(image, new RRect(r.Left + 3, r.Top + 3, image.Width, image.Height));
        }
コード例 #11
0
        /// <summary>
        /// Paints the fragment
        /// </summary>
        /// <param name="g">the device to draw to</param>
        protected override void PaintImp(RGraphics g)
        {
            // load image iff it is in visible rectangle
            if (_imageLoadHandler == null)
            {
                _imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
                _imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
            }

            var    rect   = CommonUtils.GetFirstValueOrDefault(Rectangles);
            RPoint offset = HtmlContainer.ScrollOffset;

            rect.Offset(offset);

            var clipped = RenderUtils.ClipGraphicsByOverflow(g, this);

            PaintBackground(g, rect, true, true);
            BordersDrawHandler.DrawBoxBorders(g, this, rect, true, true);

            RRect r = _imageWord.Rectangle;

            r.Offset(offset);
            r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
            r.Y      += ActualBorderTopWidth + ActualPaddingTop;
            r.X       = Math.Floor(r.X);
            r.Y       = Math.Floor(r.Y);

            if (_imageWord.Image != null)
            {
                if (r.Width > 0 && r.Height > 0)
                {
                    if (_imageWord.ImageRectangle == RRect.Empty)
                    {
                        g.DrawImage(_imageWord.Image, r);
                    }
                    else
                    {
                        g.DrawImage(_imageWord.Image, r, _imageWord.ImageRectangle);
                    }

                    if (_imageWord.Selected)
                    {
                        g.DrawRectangle(GetSelectionBackBrush(g, true), _imageWord.Left + offset.X, _imageWord.Top + offset.Y, _imageWord.Width + 2, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight);
                    }
                }
            }
            else if (_imageLoadingComplete)
            {
                if (_imageLoadingComplete && r.Width > 19 && r.Height > 19)
                {
                    RenderUtils.DrawImageErrorIcon(g, HtmlContainer, r);
                }
            }
            else
            {
                RenderUtils.DrawImageLoadingIcon(g, HtmlContainer, r);
                if (r.Width > 19 && r.Height > 19)
                {
                    g.DrawRectangle(g.GetPen(RColor.LightGray), r.X, r.Y, r.Width, r.Height);
                }
            }

            if (clipped)
            {
                g.PopClip();
            }
        }
コード例 #12
0
        public override void paint(PaintingContext context, Offset offset)
        {
            Canvas canvas = context.canvas;

            paintRadialReaction(canvas, offset, size.center(Offset.zero));

            Paint           strokePaint = _createStrokePaint();
            Offset          origin      = offset + (size / 2.0f - Size.square(CheckboxUtils._kEdgeSize) / 2.0f);
            AnimationStatus status      = position.status;
            float           tNormalized = status == AnimationStatus.forward || status == AnimationStatus.completed
                ? position.value
                : 1.0f - position.value;

            if (_oldValue == false || value == false)
            {
                float t     = value == false ? 1.0f - tNormalized : tNormalized;
                RRect outer = _outerRectAt(origin, t);
                Paint paint = new Paint();
                paint.color = _colorAt(t);

                if (t <= 0.5f)
                {
                    _drawBorder(canvas, outer, t, paint);
                }
                else
                {
                    canvas.drawRRect(outer, paint);

                    float tShrink = (t - 0.5f) * 2.0f;
                    if (_oldValue == null || value == null)
                    {
                        _drawDash(canvas, origin, tShrink, strokePaint);
                    }
                    else
                    {
                        _drawCheck(canvas, origin, tShrink, strokePaint);
                    }
                }
            }
            else
            {
                // Two cases: null to true, true to null
                RRect outer = _outerRectAt(origin, 1.0f);
                Paint paint = new Paint();
                paint.color = _colorAt(1.0f);
                canvas.drawRRect(outer, paint);

                if (tNormalized <= 0.5f)
                {
                    float tShrink = 1.0f - tNormalized * 2.0f;
                    if (_oldValue == true)
                    {
                        _drawCheck(canvas, origin, tShrink, strokePaint);
                    }
                    else
                    {
                        _drawDash(canvas, origin, tShrink, strokePaint);
                    }
                }
                else
                {
                    float tExpand = (tNormalized - 0.5f) * 2.0f;
                    if (value == true)
                    {
                        _drawCheck(canvas, origin, tExpand, strokePaint);
                    }
                    else
                    {
                        _drawDash(canvas, origin, tExpand, strokePaint);
                    }
                }
            }
        }
コード例 #13
0
 protected override RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
 {
     Console.WriteLine("CreateLinearGradientBrush(): NotImplemented");
     throw new NotImplementedException();
 }
コード例 #14
0
 public void clipRRectAndPaint(RRect rrect, Clip clipBehavior, Rect bounds, Action painter)
 {
     this._clipAndPaint(doAntiAias => this.canvas.clipRRect(rrect),
                        clipBehavior, bounds, painter);
 }
コード例 #15
0
        /// <summary>
        /// Draw the background image at the required location repeating it over the X and Y axis.<br/>
        /// Adjust location to left-top if starting location doesn't include all the range (adjusted to center or bottom/right).
        /// </summary>
        private static void DrawRepeat(RGraphics g, ImageLoadHandler imageLoadHandler, RRect rectangle, RRect srcRect, RRect destRect, RSize imgSize)
        {
            while (destRect.X > rectangle.X)
            {
                destRect.X -= imgSize.Width;
            }
            while (destRect.Y > rectangle.Y)
            {
                destRect.Y -= imgSize.Height;
            }

            using (var brush = g.GetTextureBrush(imageLoadHandler.Image, srcRect, destRect.Location))
            {
                g.DrawRectangle(brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
            }
        }
コード例 #16
0
 /// <summary>
 /// Convert from core rectangle to Eto rectangle.
 /// </summary>
 public static Rectangle ConvertRound(RRect r)
 {
     return(new Rectangle((int)Math.Round(r.X), (int)Math.Round(r.Y), (int)Math.Round(r.Width), (int)Math.Round(r.Height)));
 }
コード例 #17
0
        /// <summary>
        /// Draw the background image of the given box in the given rectangle.<br/>
        /// Handle background-repeat and background-position values.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="box">the box to draw its background image</param>
        /// <param name="imageLoadHandler">the handler that loads image to draw</param>
        /// <param name="rectangle">the rectangle to draw image in</param>
        public static void DrawBackgroundImage(RGraphics g, CssBox box, ImageLoadHandler imageLoadHandler, RRect rectangle)
        {
            // image size depends if specific rectangle given in image loader
            var imgSize = new RSize(imageLoadHandler.Rectangle == RRect.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
                                    imageLoadHandler.Rectangle == RRect.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);

            // get the location by BackgroundPosition value
            var location = GetLocation(box.BackgroundPosition, rectangle, imgSize);

            var srcRect = imageLoadHandler.Rectangle == RRect.Empty
                ? new RRect(0, 0, imgSize.Width, imgSize.Height)
                : new RRect(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);

            // initial image destination rectangle
            var destRect = new RRect(location, imgSize);

            // need to clip so repeated image will be cut on rectangle
            var lRectangle = rectangle;

            lRectangle.Intersect(g.GetClip());
            g.PushClip(lRectangle);

            switch (box.BackgroundRepeat)
            {
            case "no-repeat":
                g.DrawImage(imageLoadHandler.Image, destRect, srcRect);
                break;

            case "repeat-x":
                DrawRepeatX(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                break;

            case "repeat-y":
                DrawRepeatY(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                break;

            default:
                DrawRepeat(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                break;
            }

            g.PopClip();
        }
コード例 #18
0
 /// <summary>
 /// Convert from core rectangle to Eto rectangle.
 /// </summary>
 public static RectangleF Convert(RRect r)
 {
     return(new RectangleF((float)r.X, (float)r.Y, (float)r.Width, (float)r.Height));
 }
コード例 #19
0
 public override void PushClip(RRect rect)
 {
     ReleaseHdc();
     _clipStack.Push(rect);
     _g.SetClip(Utils.Convert(rect), CombineMode.Replace);
 }
コード例 #20
0
ファイル: AntialiasSVGSample.cs プロジェクト: JC-ut0/CubeGame
        public override void paint(Canvas canvas, Size size)
        {
            var paint = new Paint()
            {
                color = new Color(0xFFFF0000),
            };

            paint.color       = Colors.yellow;
            paint.style       = PaintingStyle.stroke;
            paint.strokeWidth = 3;

            var startPoint    = new Offset(0, size.height / 6);
            var controlPoint1 = new Offset(size.width / 4, 0);
            var controlPoint2 = new Offset(3 * size.width / 4, 0);
            var endPoint      = new Offset(size.width, size.height / 6);

            var path = new Path();

            path.moveTo(startPoint.dx, startPoint.dy);
            path.cubicTo(
                controlPoint1.dx, controlPoint1.dy,
                controlPoint2.dx, controlPoint2.dy,
                endPoint.dx, endPoint.dy
                );

            path.moveTo(10, 10);
            path.lineTo(90, 10);
            path.lineTo(10, 90);
            path.lineTo(90, 90);
            path.winding(PathWinding.clockwise);
            path.close();

            path.moveTo(110, 10);
            path.lineTo(190, 10);
            path.lineTo(110, 90);
            path.lineTo(190, 90);
            path.close();

            path.addRect(UIWidgetRect.fromLTWH(10, 25, 180, 50));

            path.addRect(UIWidgetRect.fromLTWH(200, 0, 100, 100));
            path.addRRect(RRect.fromRectAndRadius(UIWidgetRect.fromLTWH(225, 25, 50, 50), 10));
            path.winding(PathWinding.clockwise);
            path.addOval(UIWidgetRect.fromLTWH(200, 50, 100, 100));
            path.winding(PathWinding.clockwise);


            canvas.drawPath(path, paint);

            paint = new Paint {
                color  = new Color(0xFFFF0000),
                shader = Gradient.linear(
                    new Offset(0, 0),
                    new Offset(size.width, 200),
                    new List <Color>()
                {
                    Colors.red, Colors.black, Colors.green
                }, null, TileMode.clamp),
            };
            canvas.translate(0, 200);
            canvas.drawPath(path, paint);

            canvas.translate(0, 200);
            // paint.maskFilter = MaskFilter.blur(BlurStyle.normal, 5);
            paint.shader = new ImageShader(new Image(texture6, true), TileMode.mirror);
            canvas.drawPath(path, paint);

            canvas.translate(0, 200);
            paint = new Paint {
                color  = new Color(0xFF00FF00),
                shader = Gradient.sweep(
                    new Offset(size.width / 2, 100),
                    new List <Color>()
                {
                    Colors.red, Colors.black, Colors.green, Colors.red,
                }, null, TileMode.clamp, 0 * Mathf.PI / 180, 360 * Mathf.PI / 180),
            };
            canvas.drawPath(path, paint);


            paint.shader = Gradient.radial(
                new Offset(size.width / 2, 100), 200f,
                new List <Color>()
            {
                Colors.red, Colors.black, Colors.green
            }, null, TileMode.clamp);
            canvas.translate(0, 200);
            canvas.drawPath(path, paint);
        }
コード例 #21
0
 public override void DrawImage(RImage image, RRect destRect, RRect srcRect)
 {
     ReleaseHdc();
     _g.DrawImage(((ImageAdapter)image).Image, Utils.Convert(destRect), Utils.Convert(srcRect), GraphicsUnit.Pixel);
 }
コード例 #22
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
 public void DrawImage(RImage image, RRect rect1, RRect rect2, GraphicsUnit gu, bool useStack = true)
 {
     // throw new NotImplementedException();
 }
コード例 #23
0
ファイル: RAdapter.cs プロジェクト: cwensley/HTML-Renderer
 /// <summary>
 /// Get linear gradient color brush from <paramref name="color1"/> to <paramref name="color2"/>.
 /// </summary>
 /// <param name="rect">the rectangle to get the brush for</param>
 /// <param name="color1">the start color of the gradient</param>
 /// <param name="color2">the end color of the gradient</param>
 /// <param name="angle">the angle to move the gradient from start color to end color in the rectangle</param>
 /// <returns>linear gradient color brush instance</returns>
 protected abstract RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle);
コード例 #24
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
 public void DrawImage(RImage image, RRect rect, bool useStack = true)
 {
     // throw new NotImplementedException();
 }
コード例 #25
0
 /// <summary>
 /// Push the clipping region of this Graphics to exclude the given rectangle from the current clipping rectangle.
 /// </summary>
 /// <param name="rect">Rectangle to exclude clipping in.</param>
 public abstract void PushClipExclude(RRect rect);
コード例 #26
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
 public void SetClip(RRect rect, CombineMode cm)
 {
 }
コード例 #27
0
 /// <summary>
 /// Draws the specified Image at the specified location and with the specified size.
 /// </summary>
 /// <param name="image">Image to draw. </param>
 /// <param name="destRect">Rectangle structure that specifies the location and size of the drawn image. </param>
 public abstract void DrawImage(RImage image, RRect destRect);
コード例 #28
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
 public RSize MeasureCharacterRanges(string text, RFont font, RRect rect, StringFormat format)
 {
     // throw new NotImplementedException();
     return(RSize.Empty);
 }
コード例 #29
0
ファイル: GraphicsAdapter.cs プロジェクト: vebin/Perspex
 public override void DrawImage(RImage image, RRect destRect, RRect srcRect)
 {
     _g.DrawImage(((ImageAdapter)image).Image, 1, Util.Convert(srcRect), Util.Convert(destRect));
 }
コード例 #30
0
 public override void DrawImage(RImage image, RRect destRect)
 {
     _g.DrawImage(((ImageAdapter)image).Image, 1, new Rect(0, 0, image.Width, image.Height),
                  Util.Convert(destRect));
 }