当前位置: 首页>>代码示例>>C#>>正文


C# RectangleF类代码示例

本文整理汇总了C#中RectangleF的典型用法代码示例。如果您正苦于以下问题:C# RectangleF类的具体用法?C# RectangleF怎么用?C# RectangleF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RectangleF类属于命名空间,在下文中一共展示了RectangleF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPieChart

    /// <summary>
    /// Method for creating pie chart symbols
    /// </summary>
    /// <remarks>
    /// <para>In this example we just create some random pie charts, 
    /// but it probably should be based on attributes read from the row.</para>
    ///	<para>Credits goes to gonzalo_ar for posting this in the forum</para></remarks>
    /// <param name="row"></param>
    /// <returns></returns>
    private static Bitmap GetPieChart(GeoAPI.Features.IFeature row)
    {
        // Replace polygon with a center point (this is where we place the symbol
        row.Geometry = row.Geometry.Centroid;

        // Just for the example I use random values 
        int size = rand.Next(20, 35);
        int angle1 = rand.Next(60, 180);
        int angle2 = rand.Next(angle1 + 60, 300);
        RectangleF rect = new RectangleF(0, 0, size, size);
        Bitmap b = new Bitmap(size, size);
        using (IGraphics g = Graphics.FromImage(b).G())
        {
            // Draw Pie 
            g.FillPie(Brushes.LightGreen, rect, 0, angle1);
            g.FillPie(Brushes.Pink, rect, angle1, angle2 - angle1);
            g.FillPie(Brushes.PeachPuff, rect, angle2, 360 - angle2);

            // Draw Borders 
            g.DrawPie(Pens.Green, rect, 0, angle1);
            g.DrawPie(Pens.Red, rect, angle1, angle2 - angle1);
            g.DrawPie(Pens.Orange, rect, angle2, 360 - angle2);
        }
        return b;
    }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:PieCharts.aspx.cs

示例2: Draw

        public override void Draw(SharpDXRenderer renderer)
        {
            base.Draw(renderer);

            if (this.ChildControls.Count == 0)
                return;

            TabHeaders = new RectangleF[ChildControls.Count];
            int idx = 0;
            Vector2 location = this.GetAbsoluteLocation();

            foreach (SharpDXControl panel in ChildControls)
            {
                Vector2 size = renderer.MeasureString(panel.Text, this.Font);
                if (idx == 0)
                    TabHeaders[idx] = new RectangleF(0, 0, (float)Math.Max(MinimumHeaderWidth, size.X + this.MarginLeft + this.MarginRight), size.Y);
                else
                    TabHeaders[idx] = new RectangleF(TabHeaders[idx - 1].X + TabHeaders[idx - 1].Width, TabHeaders[idx - 1].Y, (float)Math.Max(MinimumHeaderWidth, size.X + this.MarginLeft + this.MarginRight), size.Y);

                Vector2 tabLocation = location + new Vector2(TabHeaders[idx].X, TabHeaders[idx].Y);

                renderer.FillRectangle(this.BackColor, tabLocation, new Vector2(TabHeaders[idx].Width, TabHeaders[idx].Height));

                if (this.SelectedIndex == idx)
                    renderer.FillRectangle(this.ForeColor * 0.1f, tabLocation, new Vector2(TabHeaders[idx].Width, TabHeaders[idx].Height));

                renderer.DrawRectangle(this.ForeColor, tabLocation, new Vector2(TabHeaders[idx].Width, TabHeaders[idx].Height));
                renderer.DrawText(panel.Text, this.ForeColor, this.Font, tabLocation + Vector2.UnitX * this.MarginLeft);
                idx++;
            }
        }
开发者ID:Trontastic,项目名称:ExternalUtilsCSharp,代码行数:31,代码来源:SharpDXTabControl.cs

示例3: QuadTree

 public QuadTree(int level, RectangleF bounds)
 {
     this.Level = level;
     this.Objects = new List<BaseEntity>();
     this.Bounds = bounds;
     this.Nodes = new QuadTree[4];
 }
开发者ID:Harrum,项目名称:TestGamePlsIgnore,代码行数:7,代码来源:QuadTree.cs

示例4: DrawCore

        protected override void DrawCore(RenderContext context, RenderItemCollection renderItems, int fromIndex, int toIndex)
        {
            var graphicsDevice = context.GraphicsDevice;
            var destination = new RectangleF(0, 0, 1, 1);

            // find the last background to display with valid texture
            BackgroundComponent background = null;
            for (var i = toIndex; i >= fromIndex; --i)
            {
                background = (BackgroundComponent)renderItems[i].DrawContext;
                if (background.Texture != null)
                    break;
            }

            // Abort if not valid background component
            if (background == null || background.Texture == null)
                return;

            var texture = background.Texture;
            var target = CurrentRenderFrame;
            var imageBufferMinRatio = Math.Min(texture.ViewWidth / (float)target.Width, texture.ViewHeight / (float)target.Height);
            var sourceSize = new Vector2(target.Width * imageBufferMinRatio, target.Height * imageBufferMinRatio);
            var source = new RectangleF((texture.ViewWidth - sourceSize.X) / 2, (texture.ViewHeight - sourceSize.Y) / 2, sourceSize.X, sourceSize.Y);

            spriteBatch.Parameters.Add(BackgroundEffectKeys.Intensity, background.Intensity);
            spriteBatch.Begin(SpriteSortMode.FrontToBack, graphicsDevice.BlendStates.Opaque, graphicsDevice.SamplerStates.LinearClamp, graphicsDevice.DepthStencilStates.None, null, backgroundEffect);
            spriteBatch.Draw(texture, destination, source, Color.White, 0, Vector2.Zero);
            spriteBatch.End();
        }
开发者ID:releed,项目名称:paradox,代码行数:29,代码来源:BackgroundComponentRenderer.cs

示例5: RenderContext

 /// <summary>
 /// Creates a new instance of this class. This constructor gets typically called from the <see cref="Derive"/> method.
 /// </summary>
 /// <param name="transform">Combined current transformation to use in this context.</param>
 /// <param name="opacity">Combined opacity value.</param>
 /// <param name="untransformedBounds">Bounds of the element currently being rendered, in local space.</param>
 /// <param name="zOrder">Z coordinate of the currently rendered element.</param>
 public RenderContext(Matrix transform, double opacity, RectangleF untransformedBounds, float zOrder)
 {
   _zOrder = zOrder;
   _opacity = opacity;
   _transform = transform;
   SetUntransformedContentsBounds(untransformedBounds);
 }
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:14,代码来源:RenderContext.cs

示例6: HazardBox

        public HazardBox( CubeGame game,
                          World world,
                          RectangleF rec,
                          BodyType bodyType = BodyType.Static,
                          float density = 1,
                          Category categories = Constants.Categories.DEFAULT,
                          Category killCategories = Constants.Categories.ACTORS )
            : base(game, world, rec.Center.ToUnits(), 0, new HazardBoxMaker( rec.Width, rec.Height ))
        {
            mWidth = rec.Width;
            mHeight = rec.Height;

            Fixture box = FixtureFactory.AttachRectangle(
                    mWidth.ToUnits(),
                    mHeight.ToUnits(),
                    density,
                    Vector2.Zero,
                    Body,
                    new Flat() );

            Fixture killBox = box.CloneOnto( Body );
            killBox.IsSensor = true;
            killBox.UserData = new Hazard( "killbox" );

            Body.BodyType = bodyType;
            Body.CollisionCategories = categories;

            killBox.CollidesWith = killCategories;
            box.CollidesWith ^= killCategories;
        }
开发者ID:theLOLflashlight,项目名称:CyberCube,代码行数:30,代码来源:HazardBox.cs

示例7: GetIntersectionDepth

        /// <summary>
        /// Calculates the signed depth of intersection between two rectangles.
        /// </summary>
        /// <returns>
        /// The amount of overlap between two intersecting rectangles. These
        /// depth values can be negative depending on which wides the rectangles
        /// intersect. This allows callers to determine the correct direction
        /// to push objects in order to resolve collisions.
        /// If the rectangles are not intersecting, Vector2.Zero is returned.
        /// </returns>
        public static Vector2 GetIntersectionDepth(this RectangleF rectA, RectangleF rectB)
        {
            // Calculate half sizes.
            float halfWidthA = rectA.Width / 2.0f;
            float halfHeightA = rectA.Height / 2.0f;
            float halfWidthB = rectB.Width / 2.0f;
            float halfHeightB = rectB.Height / 2.0f;

            // Calculate centers.
            Vector2 centerA = new Vector2(rectA.Left + halfWidthA, rectA.Top + halfHeightA);
            Vector2 centerB = new Vector2(rectB.Left + halfWidthB, rectB.Top + halfHeightB);

            // Calculate current and minimum-non-intersecting distances between centers.
            float distanceX = centerA.X - centerB.X;
            float distanceY = centerA.Y - centerB.Y;
            float minDistanceX = halfWidthA + halfWidthB;
            float minDistanceY = halfHeightA + halfHeightB;

            // If we are not intersecting at all, return (0, 0).
            if (Math.Abs(distanceX) >= minDistanceX || Math.Abs(distanceY) >= minDistanceY)
                return Vector2.Zero;

            // Calculate and return intersection depths.
            float depthX = distanceX > 0 ? minDistanceX - distanceX : -minDistanceX - distanceX;
            float depthY = distanceY > 0 ? minDistanceY - distanceY : -minDistanceY - distanceY;
            return new Vector2(depthX, depthY);
        }
开发者ID:zmthy,项目名称:play-dead,代码行数:37,代码来源:RectangleExtensions.cs

示例8: recalculateBounds

		/// <summary>
		/// internal hack used by Particles so they can reuse a Circle for all collision checks
		/// </summary>
		/// <param name="radius">Radius.</param>
		/// <param name="position">Position.</param>
		internal void recalculateBounds( float radius, Vector2 position )
		{
			_originalRadius = radius;
			this.radius = radius;
			this.position = position;
			bounds = new RectangleF( position.X - radius, position.Y - radius, radius * 2f, radius * 2f );
		}
开发者ID:prime31,项目名称:Nez,代码行数:12,代码来源:Circle.cs

示例9: AddImage

    public void AddImage(Image image) {
        // scale image
        float widthMultiplier = maxDimension / (float)image.Width;
        float heightMultiplier = maxDimension / (float)image.Height;
        float minMultiplier = Math.Min(Math.Min(widthMultiplier, heightMultiplier), 1f);
        float newWidth = minMultiplier * (float)image.Width;
        float newHeight = minMultiplier * (float)image.Height;

        // choose a random translation & rotation
        float angle = GetRandomAngle();
        PointF newDimensions = RotateAndFindNewDimensions(new PointF(newWidth, newHeight), angle);
        PointF offset = GetRandomOffset(newDimensions);
        surfaceGraphics.TranslateTransform(offset.X, offset.Y);
        surfaceGraphics.RotateTransform(angle);

        // draw borders + image
        DrawRectangle(Brushes.White, newWidth, newHeight, thickLineWidth);
        DrawRectangle(Brushes.Black, newWidth, newHeight, thinLineWidth);
        surfaceGraphics.DrawImage(image, -newWidth / 2f, -newHeight / 2f, newWidth, newHeight);

        // calculate new image boundaries
        RectangleF newBounds = new RectangleF(
            offset.X - newDimensions.X / 2f,
            offset.Y - newDimensions.Y / 2f,
            newDimensions.X,
            newDimensions.Y);

        if (surfaceBounds.HasValue) {
            surfaceBounds = Union(surfaceBounds.Value, newBounds);
        } else {
            surfaceBounds = newBounds;
        }

        surfaceGraphics.ResetTransform();
    }
开发者ID:javidondeesta,项目名称:tech-talks,代码行数:35,代码来源:MultiThumbnailGenerator.cs

示例10: PipeSet

        public PipeSet(Entity referencePipeEntity, float scrollSpeed, float startScrollPos, float screenWidth)
        {
            this.scrollSpeed = scrollSpeed;
            this.startScrollPos = startScrollPos;
            halfScrollWidth = screenWidth / 2f;

            // Store Entity and create another one for two rendering:
            // top and bottom sprite of pipe.
            var spriteComp = referencePipeEntity.Get<SpriteComponent>();
             bottomPipe = referencePipeEntity.Clone();
            topPipe = referencePipeEntity.Clone();
            Entity.AddChild(bottomPipe);
            Entity.AddChild(topPipe);

            var sprite = spriteComp.CurrentSprite;
            pipeWidth = sprite.SizeInPixels.X;
            pipeHeight = sprite.SizeInPixels.Y;
            halfPipeWidth = pipeWidth/2f;

            // Setup pipeCollider
            pipeCollider = new RectangleF(0, 0, pipeWidth, pipeHeight);

            // Place the top/bottom pipes relatively to the root.
            topPipe.Transform.Position.Y = -(VerticalDistanceBetweenPipe + pipeHeight) * 0.5f;
            bottomPipe.Transform.Position.Y = (VerticalDistanceBetweenPipe + pipeHeight) * 0.5f;
            bottomPipe.Transform.Rotation = Quaternion.RotationZ(MathUtil.Pi);

            ResetPipe();
        }
开发者ID:cg123,项目名称:xenko,代码行数:29,代码来源:PipeSet.cs

示例11: UIView

        public UIView(AtlasGlobal atlas, RectangleF frame)
            : base(atlas)
        {
            Frame = frame;

            InitializeView();
        }
开发者ID:Racura,项目名称:AtlasEngine,代码行数:7,代码来源:UIView.cs

示例12: GetBrush

			public sd2.LinearGradientBrush GetBrush(RectangleF rect)
			{
				var start = StartPoint;
				var end = EndPoint;
				if (wrapMode == GradientWrapMode.Pad)
				{
					// winforms does not support pad, so extend to fill entire drawing region
					if (transform != null)
					{
						start = transform.TransformPoint(start);
						end = transform.TransformPoint(end);
					}
					PointF min, max;
					GradientHelper.GetLinearMinMax(start, end, rect, out min, out max, true);
					var len = max.LengthTo(min);
					// find start/end pos based on entire position
					var startpos = min.LengthTo(start) / len;
					var endpos = min.LengthTo(end) / len;
					if (brush == null || lastStartPos != startpos)
					{
						lastStartPos = startpos;
						start = min;
						end = max;
						var diff = end - start;
						// account for innacuracies in system.drawing when nearing horizontal or vertical
						if (Math.Abs(diff.X) < 0.0001)
							end.X = start.X;
						if (Math.Abs(diff.Y) < 0.0001)
							end.Y = start.Y;

						brush = new sd2.LinearGradientBrush(start.ToSD(), end.ToSD(), StartColor, EndColor);
						brush.WrapMode = sd2.WrapMode.Tile;
						brush.InterpolationColors = new sd2.ColorBlend
						{
							Colors = new[]
						{
							StartColor,
							StartColor,
							EndColor,
							EndColor
						},
							Positions = new[]
						{
							0f,
							startpos,
							endpos,
							1f,
						}
						};
					}
				}
				else if (brush == null)
				{
					brush = new sd2.LinearGradientBrush(StartPoint.ToSD(), EndPoint.ToSD(), StartColor, EndColor);
					brush.WrapMode = wrapMode.ToSD();
					if (transform != null)
						brush.MultiplyTransform(transform.ToSD());
				}
				return brush;
			}
开发者ID:mhusen,项目名称:Eto,代码行数:60,代码来源:LinearGradientBrushHandler.cs

示例13: DrawCore

        protected override void DrawCore(RenderContext context, RenderItemCollection renderItems, int fromIndex, int toIndex)
        {
            var graphicsDevice = context.GraphicsDevice;
            var destination = new RectangleF(0, 0, 1, 1);

            spriteBatch.Begin(SpriteSortMode.FrontToBack, graphicsDevice.BlendStates.Opaque, graphicsDevice.SamplerStates.LinearClamp, graphicsDevice.DepthStencilStates.None);

            for(var i = fromIndex; i <= toIndex; ++i)
            {
                var background = (BackgroundComponent)renderItems[i].DrawContext;
                var texture = background.Texture;
                if (texture == null)
                    continue;
                
                var target = CurrentRenderFrame;

                var imageBufferMinRatio = Math.Min(texture.ViewWidth / (float)target.Width, texture.ViewHeight / (float)target.Height);
                var sourceSize = new Vector2(target.Width * imageBufferMinRatio, target.Height * imageBufferMinRatio);
                var source = new RectangleF((texture.ViewWidth - sourceSize.X) / 2, (texture.ViewHeight - sourceSize.Y) / 2, sourceSize.X, sourceSize.Y);

                spriteBatch.Draw(texture, destination, source, Color.White, 0, Vector2.Zero);
            }

            spriteBatch.End();
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:25,代码来源:BackgroundComponentRenderer.cs

示例14: DrawRectangle

 public override void DrawRectangle(Rectangle area)
 {
     Rectangle pixelRect = device.Screen.ToPixelSpace(area);
     var sharpRect = new RectangleF(pixelRect.Left, pixelRect.Top, pixelRect.Right,
         pixelRect.Bottom);
     device.RenderTarget.FillRectangle(sharpRect, solidColorBrush);
 }
开发者ID:lilinghui,项目名称:DeltaEngine,代码行数:7,代码来源:SharpDXDrawing.cs

示例15: aabbBroadphase

        /// <summary>
        /// returns all objects in cells that the bounding box intersects
        /// </summary>
        /// <returns>The neighbors.</returns>
        /// <param name="bounds">Bounds.</param>
        /// <param name="layerMask">Layer mask.</param>
        public HashSet<Collider> aabbBroadphase( ref RectangleF bounds, Collider excludeCollider, int layerMask )
        {
            _tempHashset.Clear();

            var p1 = cellCoords( bounds.x, bounds.y );
            var p2 = cellCoords( bounds.right, bounds.bottom );

            for( var x = p1.X; x <= p2.X; x++ )
            {
                for( var y = p1.Y; y <= p2.Y; y++ )
                {
                    var cell = cellAtPosition( x, y );
                    if( cell == null )
                        continue;

                    // we have a cell. loop through and fetch all the Colliders
                    for( var i = 0; i < cell.Count; i++ )
                    {
                        var collider = cell[i];

                        // skip this collider if it is our excludeCollider or if it doesnt match our layerMask
                        if( collider == excludeCollider || !Flags.isFlagSet( layerMask, collider.physicsLayer ) )
                            continue;

                        if( bounds.intersects( collider.bounds ) )
                            _tempHashset.Add( collider );
                    }
                }
            }

            return _tempHashset;
        }
开发者ID:RastaCow,项目名称:Nez,代码行数:38,代码来源:SpatialHash.cs


注:本文中的RectangleF类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。