本文整理汇总了C#中System.Drawing.Graphics.TranslateClip方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.TranslateClip方法的具体用法?C# Graphics.TranslateClip怎么用?C# Graphics.TranslateClip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.TranslateClip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateClipInt
private void TranslateClipInt(PaintEventArgs e)
{
// Create rectangle for clipping region.
Rectangle clipRect = new Rectangle(0, 0, 100, 100);
// Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect);
// Translate clipping region.
int dx = 50;
int dy = 50;
e.Graphics.TranslateClip(dx, dy);
// Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
示例2: TranslateClipFloat
private void TranslateClipFloat(PaintEventArgs e)
{
// Create rectangle for clipping region.
RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);
// Set clipping region of graphics to rectangle.
e.Graphics.SetClip(clipRect);
// Translate clipping region.
float dx = 50.0F;
float dy = 50.0F;
e.Graphics.TranslateClip(dx, dy);
// Fill rectangle to demonstrate translated clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
示例3: GraphicsPath
//引入命名空间
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
class KeyholeClipCentered : Form {
GraphicsPath path = new GraphicsPath();
Image image = Image.FromFile("Color.jpg");
public static void Main() {
Application.Run(new KeyholeClipCentered());
}
public KeyholeClipCentered() {
ResizeRedraw = true;
path.AddArc(80, 0, 80, 80, 45, -270);
path.AddLine(70, 180, 170, 180);
}
protected override void OnPaint(PaintEventArgs pea) {
DoPage(pea.Graphics, ForeColor, ClientSize.Width, ClientSize.Height);
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy) {
grfx.SetClip(path);
RectangleF rectf = path.GetBounds();
int xOffset = (int)((cx - rectf.Width) / 2 - rectf.X);
int yOffset = (int)((cy - rectf.Height) / 2 - rectf.Y);
grfx.TranslateClip(xOffset, yOffset);
grfx.DrawImage(image, xOffset, yOffset, image.Width, image.Height);
}
}