示例#1
0
        //****************************************************************
        // Painting - Methods for painting a PImage.
        //****************************************************************

        /// <summary>
        /// Overridden.  See <see cref="PNode.Paint">PNode.Paint</see>.
        /// </summary>
        protected override void Paint(PPaintContext paintContext)
        {
            if (Image != null)
            {
                RectangleFx b = Bounds;
                XnaGraphics g = paintContext.Graphics;

                g.DrawImage(image, b.ToRectangleF());
            }
        }
示例#2
0
        /// <summary>
        /// Overridden.  Does fast rendering when possible.
        /// </summary>
        public override void FullPaint(PPaintContext paintContext)
        {
            if (imageAnimate)
            {
                RectangleFx fRef       = FullBounds;
                RectangleFx viewBounds = ViewBounds;
                float       scale      = FullBounds.Width / imageAnimateBounds.Width;
                float       xOffset    = (viewBounds.X - imageAnimateBounds.X) * scale;
                float       yOffset    = (viewBounds.Y - imageAnimateBounds.Y) * scale;
                float       scaleW     = viewBounds.Width * scale;
                float       scaleH     = viewBounds.Height * scale;

                RectangleFx destRect = new RectangleFx(0, 0, (int)Math.Ceiling(fRef.Width), (int)Math.Ceiling(fRef.Height));
                RectangleFx srcRect  = new RectangleFx((int)Math.Floor(xOffset), (int)Math.Floor(yOffset), (int)Math.Ceiling(xOffset + scaleW), (int)Math.Ceiling(yOffset + scaleH));
                paintContext.Graphics.DrawImage(paintBuffer, destRect.ToRectangleF(), srcRect.ToRectangleF(), System.Drawing.GraphicsUnit.Pixel);
            }
            else
            {
                base.FullPaint(paintContext);
            }
        }
示例#3
0
 /// <summary>
 /// Returns true if the interior of the given path intersects the given rectangle.
 /// </summary>
 /// <param name="path">The path to check for intersection.</param>
 /// <param name="rect">The rectangle to check for intersection.</param>
 /// <returns>
 /// True if the interior of the given path intersects the given rectangle; otherwise,
 /// false.
 /// </returns>
 public static bool PathIntersectsRect(XnaGraphicsPath path, RectangleFx rect)
 {
     TEMP_REGION.MakeInfinite();
     TEMP_REGION.Intersect(path);
     return(TEMP_REGION.IsVisible(rect.ToRectangleF()));
 }