本文整理汇总了C#中Pen类的典型用法代码示例。如果您正苦于以下问题:C# Pen类的具体用法?C# Pen怎么用?C# Pen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pen类属于命名空间,在下文中一共展示了Pen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Player
/// <summary>
/// Initializes a new Player class.
/// </summary>
/// <param name="texture">The Texture.</param>
/// <param name="texture2">The ErasedTexture.</param>
public Player(Texture2D texture, Texture2D texture2)
{
_erased = texture2;
Bounds = new Polygon(new Vector2(1, 6), new Vector2(5, 4), new Vector2(11, 0), new Vector2(22, 0), new Vector2(28, 6),
new Vector2(28, 11), new Vector2(31, 15), new Vector2(28, 21), new Vector2(19, 21), new Vector2(18, 23),
new Vector2(9, 23), new Vector2(0, 13), new Vector2(1, 7));
_pen = new Pen(Color.White, 1);
_spriteSheet = new AnimatedSpriteSheet(texture) {AutoUpdate = true};
_spriteSheet.Add(new Keyframe(new Rectangle(0, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(32, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(64, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(96, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(128, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(160, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(192, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(224, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(256, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(288, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(320, 0, 32, 24), 100));
_spriteSheet.Add(new Keyframe(new Rectangle(352, 0, 32, 24), 100));
Position = new Vector2(300, 230);
Velocity = new Vector2(0, 0);
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "image/bmp";
string st = "",s="";
Random rnd = new Random();
Int32 num=0,ch=0;
for (int i = 0; i < 5; i++)
{
ch=rnd.Next(2);
if (ch == 0)
num = rnd.Next(65, 91);
if (ch == 0)
num = rnd.Next(97, 122);
else
num = rnd.Next(48, 57);
s += (Convert.ToChar(num)).ToString();
st += (Convert.ToChar(num)).ToString() + " ";
}
Session.Add("captcha", s);
Bitmap bmp = new Bitmap(210, 80);
Graphics g = Graphics.FromImage(bmp);
Pen p = new Pen(Color.Aqua);
HatchBrush br = new HatchBrush(HatchStyle.DottedGrid, Color.Aqua, Color.LightGray);
SolidBrush b = new SolidBrush(Color.Goldenrod);
Font f = new Font("Chillar", 36);
g.FillRectangle(br, new Rectangle(0, 0, 210, 80));
g.DrawString(st, f, b, new Point(5, 5));
bmp.Save(Response.OutputStream, ImageFormat.Bmp);
g.DrawLine(p, 20, 10, 210, 80);
}
示例3: setPen
public Pen setPen(Cell cell, string side)
{
Pen myPen = new Pen(Brushes.Gray, 3);
if (side == "right" && cell.rightSideIsHighlighted == true)
{
myPen.Color = Color.Orange;
myPen.Width = 6;
}
if (side == "bottom" && cell.bottomSideIsHighlighted == true)
{
myPen.Color = Color.Orange;
myPen.Width = 6;
}
if (side == "right" && cell.hasRightWall == true)
{
myPen.Color = Color.Black;
myPen.Width = 6;
}
if (side == "bottom" && cell.hasBottomWall == true)
{
myPen.Color = Color.Black;
myPen.Width = 6;
}
return myPen;
}
示例4: Star
public Star(int x, int y, int width, int height)
{
Pen pen = new Pen (Color.Black);
int numPoints = 5;
Point[] pts = new Point[numPoints];
double rx = width / 2;
double ry = height / 2;
double cx = x + rx;
double cy = y + ry;
double theta = -Math.PI / 2;
double dtheta = 4 * Math.PI / numPoints;
int i;
for (i = 0; i < numPoints; i++)
{
pts [i] = new Point (Convert.ToInt32(cx + rx * Math.Cos (theta)),
Convert.ToInt32(cy + ry * Math.Sin (theta)));
theta += dtheta;
}
for (i = 0; i < numPoints; i++)
{
Geo l;
Geometrie.Add(l = new Line(pts[i].X,
pts[i].Y,
pts[(i+1) % numPoints].X,
pts[(i+1) % numPoints].Y));
}
}
示例5: CreateImage
private void CreateImage()
{
string code = GetRandomText();
Bitmap bitmap = new Bitmap(200, 50, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bitmap);
Pen pen = new Pen(Color.Yellow);
Rectangle rect = new Rectangle(0, 0, 200, 50);
SolidBrush b = new SolidBrush(Color.Black);
SolidBrush blue = new SolidBrush(Color.Blue);
int counter = 0;
g.DrawRectangle(pen, rect);
g.FillRectangle(b, rect);
for (int i = 0; i < code.Length; i++)
{
g.DrawString(code[i].ToString(), new Font("Verdena", 10 + rand.Next(14, 18)), blue, new PointF(10 + counter, 10));
counter += 20;
}
DrawRandomLines(g);
bitmap.Save(Response.OutputStream, ImageFormat.Gif);
g.Dispose();
bitmap.Dispose();
}
示例6: DrawLine
public static void DrawLine(this ICanvas canvas, Point start, Point end, Pen pen)
{
var p = new Path { Pen = pen };
p.MoveTo(start,false);
p.LineTo(end);
p.Draw(canvas);
}
示例7: RenderRectangle
protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
{
Color outlineColor = (pen != null) ? pen.Color : (Color)0x0;
ushort outlineThickness = (pen != null) ? pen.Thickness : (ushort)0;
int x1, y1;
int x2, y2;
switch (MappingMode)
{
case BrushMappingMode.RelativeToBoundingBox:
x1 = x + (int)((long)(width - 1) * StartX / RelativeBoundingBoxSize);
y1 = y + (int)((long)(height - 1) * StartY / RelativeBoundingBoxSize);
x2 = x + (int)((long)(width - 1) * EndX / RelativeBoundingBoxSize);
y2 = y + (int)((long)(height - 1) * EndY / RelativeBoundingBoxSize);
break;
default: //case BrushMappingMode.Absolute:
x1 = StartX;
y1 = StartY;
x2 = EndX;
y2 = EndY;
break;
}
bmp.DrawRectangle((MSMedia.Color)outlineColor, outlineThickness, x, y, width, height, 0, 0, (MSMedia.Color)StartColor, x1, y1, (MSMedia.Color)EndColor, x2, y2, Opacity);
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//新建一个Bitmap对象
using (Bitmap image = new Bitmap(300, 200))
{
//根据Bitmap对象创建一个相关的Graphics对象,用于绘制。
using (Graphics g = Graphics.FromImage(image))
{
//调用Graphics的FillRectangle方法来绘制一个矩形。
g.FillRectangle(Brushes.White, 1, 1, 295, 195);
//初始化一个字体
Font font = new Font("Verdana",20, FontStyle.Regular|FontStyle.Bold);
Pen pen = new Pen(Brushes.Black, 8);
Rectangle rec=new Rectangle(10, 60, 220, 100);
//设置SmoothingMode为支持抗锯齿功能
g.SmoothingMode = SmoothingMode.AntiAlias;
//为文字添加防锯齿效果
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.DrawEllipse(pen,rec);
g.FillEllipse(Brushes.Green, rec);
//调用DrawingString方法在画布上绘制文本。
g.DrawString("使用GDI+绘图", font, Brushes.Silver, 5, 2);
Image icon = Image.FromFile(Server.MapPath("~/Images/A001.bmp"));
g.DrawImage(icon, 210, 10, 80, 50);
//将图像以Gif格式保存到指定的输入二进制流中
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}
示例9: SetLineCap
public void SetLineCap (Pen widget, PenLineCap lineCap)
{
var pen = widget.ToSD ();
pen.StartCap = pen.EndCap = lineCap.ToSD ();
pen.DashCap = lineCap == PenLineCap.Round ? sd2.DashCap.Round : sd2.DashCap.Flat;
SetDashStyle (widget, widget.DashStyle);
}
示例10: pensAreEqual
private static Boolean pensAreEqual(Pen p1, Pen p2)
{
if (ReferenceEquals(p1, p2))
{
return true;
}
if (p1 == null || p2 == null)
{
return false;
}
if (p1.Alignment != p2.Alignment) return false;
if (!brushesAreEqual(p1.Brush, p2.Brush)) return false;
if (p1.Color != p2.Color) return false;
if (!elementsAreEqual(p1.CompoundArray, p2.CompoundArray)) return false;
if (p1.DashStyle == DashStyle.Custom && p1.CustomEndCap != p2.CustomEndCap) return false;
if (p1.DashStyle == DashStyle.Custom && p1.CustomStartCap != p2.CustomStartCap) return false;
if (p1.DashCap != p2.DashCap) return false;
if (p1.DashOffset != p2.DashOffset) return false;
if (p1.DashStyle == DashStyle.Custom && !elementsAreEqual(p1.DashPattern, p2.DashPattern)) return false;
if (p1.DashStyle != p2.DashStyle) return false;
if (p1.EndCap != p2.EndCap) return false;
if (p1.LineJoin != p2.LineJoin) return false;
if (p1.MiterLimit != p2.MiterLimit) return false;
if (p1.PenType != p2.PenType) return false;
if (p1.StartCap != p2.StartCap) return false;
if (!elementsAreEqual(p1.Transform.Elements, p2.Transform.Elements)) return false;
if (p1.Width != p2.Width) return false;
return true;
}
示例11: OnPaint
protected override void OnPaint(PaintEventArgs pevent)
{
var g = pevent.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.Clear(Parent.BackColor);
var checkMarkLine = new Rectangle(1, 1, 16, 16);
var checkmarkPath = DrawHelper.CreateRoundRect(1, 1, 17, 17, 1);
EnabledCheckedColor = HexColor;
SolidBrush BG = new SolidBrush(Enabled ? Checked ? EnabledCheckedColor : EnabledUnCheckedColor : DisabledColor);
Pen Pen = new Pen(BG.Color);
g.FillPath(BG, checkmarkPath);
g.DrawPath(Pen, checkmarkPath);
g.SmoothingMode = SmoothingMode.None;
g.FillRectangle(new SolidBrush(Color.White), PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum);
g.SmoothingMode = SmoothingMode.AntiAlias;
//CheckMark
g.DrawImageUnscaledAndClipped(CheckMarkBitmap(), checkMarkLine);
//CheckBox Text
g.DrawString(Text, font.Roboto_Medium10, new SolidBrush(Enabled ? EnabledStringColor : DisabledStringColor), 21, 0);
}
示例12: Element
public Element(Pen pen, BaseBrush brush)
{
Id = Guid.NewGuid().ToString();
Pen = pen;
Brush = brush;
Transform = Transform.Identity;
}
示例13: DrawCircle
/// <summary>
/// Draws a circle
/// </summary>
/// <param name="x">The x coordinate of the square containing this circle</param>
/// <param name="y">The y coordinate of the square containing this circle</param>
/// <param name="s">The size (or weight/height) of the circle</param>
/// <param name="color">The color of the circle border</param>
public override void DrawCircle(int x, int y, int s, Color color)
{
//Create a pen
Pen pen = new Pen(color);
Canvas.DrawEllipse(pen, x, y, s, s);
}
示例14: DrawLine
/// <summary>
/// Draws a rectangle
/// </summary>
/// <param name="p1">The starting point of the line</param>
/// <param name="p2">The end point of the line</param>
/// <param name="color">The color of the line</param>
public override void DrawLine(Point p1, Point p2, Color color)
{
//Create a pen
Pen pen = new Pen(color);
Canvas.DrawLine(pen, p1, p2);
}
示例15: CreateImage
private void CreateImage()
{
Session["captcha.guid"] = Guid.NewGuid().ToString ("N");
string code = GetRandomText();
Bitmap bitmap = new Bitmap(WIDTH,HEIGHT,System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bitmap);
Pen pen = new Pen(Color.DarkSlateGray);
Rectangle rect = new Rectangle(0,0,WIDTH,HEIGHT);
SolidBrush background = new SolidBrush(Color.AntiqueWhite);
SolidBrush textcolor = new SolidBrush(Color.DarkSlateGray);
int counter = 0;
g.DrawRectangle(pen, rect);
g.FillRectangle(background, rect);
for (int i = 0; i < code.Length; i++)
{
g.DrawString(code[i].ToString(),
new Font("Verdana", 10 + rand.Next(6, 14)),
textcolor,
new PointF(10 + counter, 10));
counter += 25;
}
DrawRandomLines(g);
bitmap.Save(Response.OutputStream,ImageFormat.Gif);
g.Dispose();
bitmap.Dispose();
}