本文整理汇总了C#中Eto.Drawing.RectangleF类的典型用法代码示例。如果您正苦于以下问题:C# RectangleF类的具体用法?C# RectangleF怎么用?C# RectangleF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RectangleF类属于Eto.Drawing命名空间,在下文中一共展示了RectangleF类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TextureBrushesSection
public TextureBrushesSection()
{
var layout = new DynamicLayout();
for (var i = 0; i < 10; ++i)
{
var w = image.Size.Width / 3; // same as height
var img = image;
if (i > 0)
img = img.Clone(new Rectangle((i - 1) % 3 * w, (i - 1) / 3 * w, w, w));
var brush = new TextureBrush(img);
var drawable = new Drawable { Size = image.Size * 2 };
drawable.Paint += (s, e) => {
var destRect = new RectangleF(new PointF(100, 100), image.Size);
var temp = brush.Transform; // save state
brush.Transform = Matrix.FromRotation(90);
e.Graphics.TranslateTransform(destRect.Location);
e.Graphics.FillRectangle(brush, new RectangleF(destRect.Size));
brush.Transform = temp;
};
layout.AddRow(drawable);
}
layout.Add(null);
Content = layout;
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:26,代码来源:TextureBrushesSection.cs
示例2: Restrict
public void Restrict(RectangleF rectangle)
{
if (Left < rectangle.Left) Left = rectangle.Left;
if (Top < rectangle.Top) Top = rectangle.Top;
if (Right > rectangle.Right) Right = rectangle.Right;
if (Bottom > rectangle.Bottom) Bottom = rectangle.Bottom;
}
开发者ID:hultqvist,项目名称:Eto,代码行数:7,代码来源:RectangleF.cs
示例3: ToImageCoordinate
public RectangleF ToImageCoordinate(RectangleF pictureBoxRect)
{
var upperLeft = ToPictureBoxCoordinate(pictureBoxRect.Location);
var bottomRight = ToPictureBoxCoordinate(new PointF(pictureBoxRect.Right, pictureBoxRect.Bottom));
return RectangleF.FromSides(upperLeft.X, upperLeft.Y, bottomRight.X, bottomRight.Y);
}
开发者ID:gitter-badger,项目名称:dot-imaging,代码行数:7,代码来源:PictureBox.cs
示例4: Box
public Box (Size canvasSize, bool useTexturesAndGradients)
{
var size = new SizeF(random.Next (50) + 50, random.Next (50) + 50);
var location = new PointF(random.Next (canvasSize.Width - (int)size.Width), random.Next (canvasSize.Height - (int)size.Height));
position = new RectangleF(location, size);
increment = new SizeF (random.Next (3) + 1, random.Next (3) + 1);
if (random.Next (2) == 1)
increment.Width = -increment.Width;
if (random.Next (2) == 1)
increment.Height = -increment.Height;
angle = random.Next (360);
rotation = (random.Next (20) - 10f) / 4f;
var rect = new RectangleF (size);
color = GetRandomColor (random);
switch (random.Next (useTexturesAndGradients ? 4 : 2)) {
case 0:
draw = (g) => g.DrawRectangle (color, rect);
erase = (g) => g.DrawRectangle (Colors.Black, rect);
break;
case 1:
draw = (g) => g.DrawEllipse (color, rect);
erase = (g) => g.DrawEllipse (Colors.Black, rect);
break;
case 2:
switch (random.Next (2)) {
case 0:
fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
break;
case 1:
fillBrush = new TextureBrush(texture) {
Transform = Matrix.FromScale (size / 80)
};
break;
}
draw = (g) => g.FillEllipse (fillBrush, rect);
erase = (g) => g.FillEllipse (Colors.Black, rect);
break;
case 3:
switch (random.Next (2)) {
case 0:
fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
break;
case 1:
fillBrush = new TextureBrush(texture) {
Transform = Matrix.FromScale (size / 80)
};
break;
}
draw = (g) => g.FillRectangle (fillBrush, rect);
erase = (g) => g.FillRectangle (Colors.Black, rect);
break;
}
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:55,代码来源:DirectDrawingSection.cs
示例5: Create
public object Create (RectangleF rectangle, Color startColor, Color endColor, float angle)
{
var matrix = swm.Matrix.Identity;
var startPoint = rectangle.Location.ToWpf ();
matrix.RotateAtPrepend (angle - 45, startPoint.X, startPoint.Y);
var endPoint = matrix.Transform (rectangle.EndLocation.ToWpf ());
return new swm.LinearGradientBrush (startColor.ToWpf (), endColor.ToWpf (), startPoint, endPoint) {
MappingMode = swm.BrushMappingMode.Absolute,
SpreadMethod = swm.GradientSpreadMethod.Repeat
};
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:11,代码来源:LinearGradientBrushHandler.cs
示例6: Draw
public static void Draw(Graphics graphics)
{
var generator = graphics.Generator;
var image = TestIcons.TestImage(generator);
// lines
var whitePen = Pens.White(generator);
graphics.DrawLine(whitePen, 1, 1, 99, 99);
graphics.DrawLine(whitePen, 50, 1, 50, 99);
graphics.DrawLine(whitePen, 1, 51, 99, 51);
graphics.DrawRectangle(Pens.White(generator), 101, 1, 100, 100);
graphics.DrawRectangle(Pens.White(generator), 101, 1, 10, 10);
graphics.DrawEllipse(Pens.Green(generator), 101, 1, 100, 100);
graphics.DrawPolygon(Pens.White(generator), new PointF(203, 1), new PointF(253, 51), new Point(203, 101), new PointF(203, 1), new PointF(253, 1), new PointF(253, 101), new PointF(203, 101));
var rect = new RectangleF(255, 1, 100, 100);
graphics.DrawArc(Pens.LightGreen(generator), rect, 180, 90);
graphics.DrawArc(Pens.SkyBlue(generator), rect, 0, 90);
rect.Inflate(-15, 0);
graphics.DrawArc(Pens.FloralWhite(generator), rect, -45, 90);
rect.Inflate(-5, -20);
graphics.DrawArc(Pens.SlateGray(generator), rect, -45, 270);
rect.Inflate(-10, -10);
graphics.DrawArc(Pens.SteelBlue(generator), rect, 180 + 45, 270);
graphics.DrawImage(image, 100, 1, 100, 100);
graphics.DrawText(Fonts.Sans(12 * graphics.PointsPerPixel, generator: generator), Colors.White, 0, 104, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
// filled
graphics.FillRectangle(Brushes.White(generator), 101, 120, 100, 100);
graphics.FillRectangle(Brushes.Gray(generator), 101, 120, 10, 10);
graphics.FillEllipse(Brushes.Green(generator), 101, 120, 100, 100);
graphics.FillPolygon(Brushes.White(generator), new PointF(202, 120), new PointF(252, 170), new Point(202, 220), new PointF(202, 120));
rect = new RectangleF(255, 120, 100, 100);
graphics.FillPie(Brushes.LightGreen(generator), rect, 180, 90);
graphics.FillPie(Brushes.SkyBlue(generator), rect, 0, 90);
rect.Inflate(-15, 0);
graphics.FillPie(Brushes.FloralWhite(generator), rect, -45, 90);
rect.Inflate(-5, -20);
graphics.FillPie(Brushes.SlateGray(generator), rect, -45, 270);
rect.Inflate(-10, -10);
graphics.FillPie(Brushes.SteelBlue(generator), rect, 180 + 45, 270);
graphics.DrawImage(image, 101, 120, 100, 100);
}
开发者ID:Exe0,项目名称:Eto,代码行数:52,代码来源:PixelOffsetSection.cs
示例7: Create
public object Create(RectangleF rectangle, Color startColor, Color endColor, float angle)
{
var matrix = new MatrixHandler();
var startPoint = rectangle.Location;
matrix.RotateAt(angle - 45, startPoint.X, startPoint.Y);
var endPoint = matrix.TransformPoint(rectangle.EndLocation);
return new LinearBrushData
{
StartColor = startColor,
EndColor = endColor,
StartPoint = rectangle.Location,
EndPoint = rectangle.EndLocation
};
}
开发者ID:alexandrebaker,项目名称:Eto,代码行数:14,代码来源:LinearGradientBrushHandler.cs
示例8: ClipTest
public void ClipTest()
{
Assert.AreEqual("Verifying clipbounds size", (Size)Graphics.ClipBounds.Size, Drawable.ClientSize);
// Clip to the upper-left quadrant
var clipTo = Drawable.ClientSize / 2;
Graphics.SetClip(new RectangleF(PointF.Empty, clipTo));
// Translate to the bottom-right quadrant
Graphics.TranslateTransform(new Point(clipTo));
// Check that the clip region was correctly translated
var clip = Graphics.ClipBounds;
var expectedClip = new RectangleF(-new Point(clipTo), clipTo);
Assert.AreEqual("Verifying clip after translation ", expectedClip, clip);
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:16,代码来源:UnitTestSection.cs
示例9: Draw
public void Draw(GraphicsHandler graphics, RectangleF rect)
{
var context = graphics.Control;
context.SaveState();
context.ConcatCTM(transform);
context.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, Image.Height));
//transform.ToEto().TransformRectangle(rect);
if (Opacity < 1f)
{
context.SetBlendMode(CGBlendMode.Normal);
context.SetAlpha(Opacity);
}
context.DrawTiledImage(new CGRect(0, 0, Image.Width, Image.Height), Image);
context.RestoreState();
}
开发者ID:mhusen,项目名称:Eto,代码行数:17,代码来源:TextureBrushHandler.cs
示例10: ClipRectangleShouldTranslate
public void ClipRectangleShouldTranslate()
{
TestUtils.Paint((drawable, e) =>
{
var graphics = e.Graphics;
// Clip to the upper-left quadrant
var clipTo = drawable.ClientSize / 2;
graphics.SetClip(new RectangleF(PointF.Empty, clipTo));
// Translate to the bottom-right quadrant
graphics.TranslateTransform(new Point(clipTo));
// Check that the clip region was correctly translated
var clip = graphics.ClipBounds;
var expectedClip = new RectangleF(-new Point(clipTo), clipTo);
Assert.AreEqual(Rectangle.Round(expectedClip), Rectangle.Round(clip), "Clip rectangle wasn't translated properly");
});
}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:18,代码来源:ClipTests.cs
示例11: PictureBox_MouseMove
private void PictureBox_MouseMove(object sender, MouseEventArgs e)
{
if (!isDrawing || control.Image == null) return;
var ptSecond = control.ToImageCoordinate(e.Location);
rect = new RectangleF
{
X = Math.Min(ptFirst.X, ptSecond.X),
Y = Math.Min(ptFirst.Y, ptSecond.Y),
Width = Math.Abs(ptFirst.X - ptSecond.X),
Height = Math.Abs(ptFirst.Y - ptSecond.Y)
};
rect.Width = Math.Max(MIN_RECT_SIZE, rect.Width);
rect.Height = Math.Max(MIN_RECT_SIZE, rect.Height);
control.Invalidate();
}
开发者ID:gitter-badger,项目名称:dot-imaging,代码行数:19,代码来源:DrawingRectangleAdorner.cs
示例12: LinearGradientBrush
/// <summary>
/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class with a given <paramref name="rectangle"/> and <paramref name="angle"/>
/// </summary>
/// <param name="rectangle">Rectangle to define the area of the gradient</param>
/// <param name="startColor">Start color for the gradient</param>
/// <param name="endColor">End color for the gradient</param>
/// <param name="angle">Angle of the gradient</param>
/// <param name="generator">Generator to create the brush, or null to use the current generator</param>
public LinearGradientBrush(RectangleF rectangle, Color startColor, Color endColor, float angle, Generator generator)
{
handler = generator.CreateShared<IHandler>();
ControlObject = handler.Create(rectangle, startColor, endColor, angle);
}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:13,代码来源:LinearGradientBrush.cs
示例13: GetTextOrigin
/// <summary>
///
/// </summary>
/// <param name="style"></param>
/// <param name="rect"></param>
/// <param name="size"></param>
/// <returns></returns>
private PointF GetTextOrigin(ShapeStyle style, ref RectangleF rect, ref SizeF size)
{
float ox, oy;
switch (style.TextStyle.TextHAlignment)
{
case TextHAlignment.Left:
ox = rect.X;
break;
case TextHAlignment.Right:
ox = rect.Right - size.Width;
break;
case TextHAlignment.Center:
default:
ox = (rect.Left + rect.Width / 2f) - (size.Width / 2f);
break;
}
switch (style.TextStyle.TextVAlignment)
{
case TextVAlignment.Top:
oy = rect.TopLeft.Y;
break;
case TextVAlignment.Bottom:
oy = rect.Bottom - size.Height;
break;
case TextVAlignment.Center:
default:
oy = (rect.Bottom - rect.Height / 2f) - (size.Height / 2f);
break;
}
return new PointF(ox, oy);
}
开发者ID:gitter-badger,项目名称:Test2d,代码行数:41,代码来源:EtoRenderer.cs
示例14: Draw
/// <summary>
///
/// </summary>
/// <param name="gfx"></param>
/// <param name="image"></param>
/// <param name="dx"></param>
/// <param name="dy"></param>
/// <param name="db"></param>
/// <param name="r"></param>
public void Draw(object gfx, XImage image, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
{
var _gfx = gfx as Graphics;
var rect = CreateRect(
image.TopLeft,
image.BottomRight,
dx, dy);
var srect = new RectangleF(
_scaleToPage(rect.X),
_scaleToPage(rect.Y),
_scaleToPage(rect.Width),
_scaleToPage(rect.Height));
if (image.IsFilled)
{
Brush brush = ToSolidBrush(image.Style.Fill);
_gfx.FillRectangle(
brush,
srect);
brush.Dispose();
}
if (image.IsStroked)
{
Pen pen = ToPen(image.Style, _scaleToPage);
_gfx.DrawRectangle(
pen,
srect);
pen.Dispose();
}
if (_enableImageCache
&& _biCache.ContainsKey(image.Path))
{
_gfx.DrawImage(_biCache[image.Path], srect);
}
else
{
if (_state.ImageCache == null || string.IsNullOrEmpty(image.Path))
return;
var bytes = _state.ImageCache.GetImage(image.Path);
if (bytes != null)
{
var bi = new Bitmap(bytes);
if (_enableImageCache)
_biCache[image.Path] = bi;
_gfx.DrawImage(bi, srect);
if (!_enableImageCache)
bi.Dispose();
}
}
}
开发者ID:gitter-badger,项目名称:Test2d,代码行数:67,代码来源:EtoRenderer.cs
示例15: Draw
public override void Draw(object control, GraphicsHandler graphics, RectangleF rect)
{
graphics.Control.SetFillColor((CGColor)control);
graphics.Control.FillRect(rect.ToNS());
}
开发者ID:mhusen,项目名称:Eto,代码行数:6,代码来源:SolidBrushHandler.cs
示例16: GetRoundRect
public static IGraphicsPath GetRoundRect (RectangleF rectangle, float nwRadius, float neRadius, float seRadius, float swRadius, Generator generator)
{
return GetRoundRect(rectangle, nwRadius, neRadius, seRadius, swRadius);
}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:4,代码来源:GraphicsPath.cs
示例17: DrawImage
public void DrawImage(Image image, RectangleF source, RectangleF destination)
{
throw new NotImplementedException();
}
开发者ID:mhusen,项目名称:Eto,代码行数:4,代码来源:TestGraphicsHandler.cs
示例18: PaintEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="Eto.Forms.PaintEventArgs"/> class.
/// </summary>
/// <param name="graphics">Graphics for the paint event</param>
/// <param name="clipRectangle">Rectangle of the region being painted</param>
public PaintEventArgs(Graphics graphics, RectangleF clipRectangle)
{
ClipRectangle = clipRectangle;
Graphics = graphics;
}
开发者ID:mhusen,项目名称:Eto,代码行数:10,代码来源:Drawable.cs
示例19: Draw
public static void Draw(Graphics graphics)
{
var image = TestIcons.TestImage;
// lines
var whitePen = new Pen(Colors.White, 1);
graphics.DrawLine(whitePen, 1, 1, 99, 99);
graphics.DrawLine(whitePen, 50, 1, 50, 99);
graphics.DrawLine(whitePen, 1, 51, 99, 51);
graphics.DrawRectangle(whitePen, 101, 1, 100, 100);
graphics.DrawRectangle(whitePen, 101, 1, 10, 10);
graphics.DrawEllipse(Pens.Green, 101, 1, 100, 100);
graphics.DrawPolygon(whitePen, new PointF(203, 1), new PointF(253, 51), new Point(203, 101), new PointF(203, 1), new PointF(253, 1), new PointF(253, 101), new PointF(203, 101));
var rect = new RectangleF(255, 1, 100, 100);
graphics.DrawArc(Pens.LightGreen, rect, 180, 90);
graphics.DrawArc(Pens.SkyBlue, rect, 0, 90);
rect.Inflate(-15, 0);
graphics.DrawArc(Pens.FloralWhite, rect, -45, 90);
rect.Inflate(-5, -20);
graphics.DrawArc(Pens.SlateGray, rect, -45, 270);
rect.Inflate(-10, -10);
graphics.DrawArc(Pens.SteelBlue, rect, 180 + 45, 270);
graphics.DrawImage(image, 100, 1, 100, 100);
graphics.DrawText(Fonts.Sans(12 * graphics.PointsPerPixel), Colors.White, 0, 104, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
// filled
graphics.FillRectangle(Brushes.White, 101, 120, 100, 100);
graphics.FillRectangle(Brushes.Gray, 101, 120, 10, 10);
graphics.FillEllipse(Brushes.Green, 101, 120, 100, 100);
graphics.FillPolygon(Brushes.White, new PointF(202, 120), new PointF(252, 170), new Point(202, 220), new PointF(202, 120));
rect = new RectangleF(255, 120, 100, 100);
graphics.FillPie(Brushes.LightGreen, rect, 180, 90);
graphics.FillPie(Brushes.SkyBlue, rect, 0, 90);
rect.Inflate(-15, 0);
graphics.FillPie(Brushes.FloralWhite, rect, -45, 90);
rect.Inflate(-5, -20);
graphics.FillPie(Brushes.SlateGray, rect, -45, 270);
rect.Inflate(-10, -10);
graphics.FillPie(Brushes.SteelBlue, rect, 180 + 45, 270);
graphics.DrawImage(image, 101, 120, 100, 100);
const int offset = 440;
var xoffset = offset;
var yoffset = 112;
for (int i = 1; i < 14; i++)
{
var pen = new Pen(Colors.White, i);
pen.LineCap = PenLineCap.Butt;
graphics.DrawLine(pen, xoffset, 1, xoffset, 110);
graphics.DrawLine(pen, offset, yoffset, offset + 100, yoffset);
xoffset += i + 2;
yoffset += i + 2;
}
}
开发者ID:mhusen,项目名称:Eto,代码行数:67,代码来源:PixelOffsetSection.cs
示例20: Draw
public void Draw(GraphicsHandler graphics, RectangleF rect)
{
var outerRadius = Radius.Width;
var yscale = Radius.Height / Radius.Width;
var center = Center;
var origin = GradientOrigin;
var scale = 1f;
if (wrap != GradientWrapMode.Pad)
{
// use eto's transformrectangle as it'll make the rect encompass the resulting transformed area
var boundRect = transform.Invert().ToEto().TransformRectangle(rect);
// find max number of iterations we need to fill the bounding rectangle
scale = GradientHelper.GetRadialScale(Center, Radius, GradientOrigin, boundRect);
}
if (Gradient == null || scale > lastScale)
{
var stops = GradientHelper.GetGradientStops(StartColor.ToCG(), EndColor.ToCG(), scale, wrap).ToList();
lastScale = scale;
Gradient = new CGGradient(CGColorSpace.CreateDeviceRGB(), stops.Select(r => r.Item2).ToArray(), stops.Select(r => (nfloat)r.Item1).ToArray());
}
else
{
scale = lastScale;
}
var scaledRect = new RectangleF(GradientOrigin - (GradientOrigin - Center + Radius) * scale, GradientOrigin + (Center + Radius - GradientOrigin) * scale);
center = scaledRect.Center;
outerRadius *= scale;
// adjust center based on ellipse scale from gradient origin
center.Y = origin.Y - (origin.Y - center.Y) / yscale;
// scale to draw elliptical gradient
var t = new CGAffineTransform(1, 0f, 0f, yscale, 0, origin.Y - origin.Y * yscale);
t.Multiply(transform);
graphics.Control.SaveState();
graphics.Control.ConcatCTM(t);
graphics.Control.DrawRadialGradient(Gradient, origin.ToNS(), 0, center.ToNS(), outerRadius, CGGradientDrawingOptions.DrawsAfterEndLocation | CGGradientDrawingOptions.DrawsBeforeStartLocation);
graphics.Control.RestoreState();
}
开发者ID:picoe,项目名称:Eto,代码行数:44,代码来源:RadialGradientBrushHandler.cs
注:本文中的Eto.Drawing.RectangleF类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论