本文整理汇总了C#中NGraphics.Pen类的典型用法代码示例。如果您正苦于以下问题:C# Pen类的具体用法?C# Pen怎么用?C# Pen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pen类属于NGraphics命名空间,在下文中一共展示了Pen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLine
public static void DrawLine(this ICanvas canvas, Point start, Point end, Pen pen)
{
var p = new Path { Pen = pen };
p.MoveTo (start);
p.LineTo (end);
p.Draw (canvas);
}
示例2: Element
protected Element (Pen pen, Brush brush)
{
Id = "";
Pen = pen;
Brush = brush;
Transform = NGraphics.Transform.Identity;
}
示例3: Element
public Element(Pen pen, Brush brush)
{
Id = Guid.NewGuid ().ToString ();
Pen = pen;
Brush = brush;
Transform = NGraphics.Transform.Identity;
}
示例4: DrawEllipse
public void DrawEllipse (Rect frame, Pen pen = null, Brush brush = null)
{
var ch = GetChild (ChildType.Ellipse);
var s = (Shapes.Rectangle)ch.Shape;
s.Width = frame.Width;
s.Height = frame.Height;
FormatShape (s, pen, brush);
}
示例5: Text
public Text (Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
: base (pen, brush)
{
Frame = frame;
Font = font;
Alignment = alignment;
Spans = new List<TextSpan> ();
}
示例6: Text
public Text(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
: base(pen, brush)
{
String = text;
Frame = frame;
Font = font;
Alignment = alignment;
}
示例7: Draw
public override void Draw(ICanvas canvas, Rect rect)
{
if(DrawingFunction != null)
{
base.Draw(canvas, rect);
return;
}
var borderColro = NGraphics.Color.FromHSL(
BorderColor.Hue,
BorderColor.Saturation,
BorderColor.Luminosity,
BorderColor.A);
var pen = new Pen(borderColro, BorderWidth);
var fillColor = NGraphics.Color.FromHSL(
BackColor.Hue,
BackColor.Saturation,
BackColor.Luminosity,
BackColor.A);
var brush = new SolidBrush(fillColor);
var padding = BorderWidth <= 0 ? 0.0 : BorderWidth;
var newRect = rect.GetInflated(-padding);
var curveSize = newRect.Height / 2;
canvas.DrawPath(new PathOp []{
new MoveTo(newRect.Left+curveSize, newRect.Top),
new LineTo(newRect.Right-curveSize, newRect.Top),
new CurveTo(
new NGraphics.Point(newRect.Right-curveSize, newRect.Top),
newRect.TopRight,
new NGraphics.Point(newRect.Right, newRect.Top+curveSize)
),
new CurveTo(
new NGraphics.Point(newRect.Right, newRect.Bottom-curveSize),
newRect.BottomRight,
new NGraphics.Point(newRect.Right-curveSize, newRect.Bottom)
),
new LineTo(newRect.Left+curveSize, newRect.Bottom),
new CurveTo(
new NGraphics.Point(newRect.Left+curveSize, newRect.Bottom),
newRect.BottomLeft,
new NGraphics.Point(newRect.Left, newRect.Bottom-curveSize)
),
new CurveTo(
new NGraphics.Point(newRect.Left, newRect.Top+curveSize),
newRect.TopLeft,
new NGraphics.Point(newRect.Left+curveSize, newRect.Top)
),
new ClosePath()
}, pen, brush);
}
示例8: DrawRectangle
public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
{
}
示例9: DrawText
public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
{
if (brush == null)
return;
var paint = GetFontPaint (font, alignment);
var w = paint.MeasureText (text);
var fm = paint.GetFontMetrics ();
var h = fm.Ascent + fm.Descent;
var point = frame.Position;
var fr = new Rect (point, new Size (w, h));
AddBrushPaint (paint, brush, fr);
graphics.DrawText (text, (float)point.X, (float)point.Y, paint);
}
示例10: GetPenPaint
Paint GetPenPaint(Pen pen)
{
var paint = new Paint (PaintFlags.AntiAlias);
paint.SetStyle (Paint.Style.Stroke);
paint.SetARGB (pen.Color.A, pen.Color.R, pen.Color.G, pen.Color.B);
paint.StrokeWidth = (float)pen.Width;
return paint;
}
示例11: DrawPath
public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null)
{
if (pen == null && brush == null)
return;
using (var path = new global::Android.Graphics.Path ()) {
var bb = new BoundingBoxBuilder ();
foreach (var op in ops) {
var mt = op as MoveTo;
if (mt != null) {
var p = mt.Point;
path.MoveTo ((float)p.X, (float)p.Y);
bb.Add (p);
continue;
}
var lt = op as LineTo;
if (lt != null) {
var p = lt.Point;
path.LineTo ((float)p.X, (float)p.Y);
bb.Add (p);
continue;
}
var at = op as ArcTo;
if (at != null) {
var p = at.Point;
path.LineTo ((float)p.X, (float)p.Y);
bb.Add (p);
continue;
}
var ct = op as CurveTo;
if (ct != null) {
var p = ct.Point;
var c1 = ct.Control1;
var c2 = ct.Control2;
path.CubicTo ((float)c1.X, (float)c1.Y, (float)c2.X, (float)c2.Y, (float)p.X, (float)p.Y);
bb.Add (p);
bb.Add (c1);
bb.Add (c2);
continue;
}
var cp = op as ClosePath;
if (cp != null) {
path.Close ();
continue;
}
throw new NotSupportedException ("Path Op " + op);
}
var frame = bb.BoundingBox;
if (brush != null) {
var paint = GetBrushPaint (brush, frame);
graphics.DrawPath (path, paint);
}
if (pen != null) {
var paint = GetPenPaint (pen);
graphics.DrawPath (path, paint);
}
}
}
示例12: DrawRectangle
public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
{
if (brush != null) {
var paint = GetBrushPaint (brush, frame);
graphics.DrawRect ((float)(frame.X), (float)(frame.Y), (float)(frame.X + frame.Width), (float)(frame.Y + frame.Height), paint);
}
if (pen != null) {
var paint = GetPenPaint (pen);
graphics.DrawRect ((float)(frame.X), (float)(frame.Y), (float)(frame.X + frame.Width), (float)(frame.Y + frame.Height), paint);
}
}
示例13: DrawPath
public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null)
{
var bb = new BoundingBoxBuilder ();
var s = new D2D1.PathGeometry (factories.D2DFactory);
var figureDepth = 0;
using (var sink = s.Open ()) {
foreach (var op in ops) {
if (op is MoveTo) {
while (figureDepth > 0) {
sink.EndFigure (D2D1.FigureEnd.Open);
figureDepth--;
}
var mt = ((MoveTo)op);
sink.BeginFigure (Conversions.ToVector2 (mt.Point), D2D1.FigureBegin.Filled);
figureDepth++;
bb.Add (mt.Point);
}
else if (op is LineTo) {
var lt = ((LineTo)op);
sink.AddLine (Conversions.ToVector2 (lt.Point));
bb.Add (lt.Point);
}
else if (op is ArcTo) {
var ar = ((ArcTo)op);
// TODO: Direct2D Arcs
//sink.AddArc (new D2D1.ArcSegment {
// Size = Conversions.ToSize2F (ar.Radius),
// Point = Conversions.ToVector2 (ar.Point),
// SweepDirection = ar.SweepClockwise ? D2D1.SweepDirection.Clockwise : D2D1.SweepDirection.CounterClockwise,
//});
sink.AddLine (Conversions.ToVector2 (ar.Point));
bb.Add (ar.Point);
}
else if (op is CurveTo) {
var ct = ((CurveTo)op);
sink.AddBezier (new D2D1.BezierSegment {
Point1 = Conversions.ToVector2 (ct.Control1),
Point2 = Conversions.ToVector2 (ct.Control2),
Point3 = Conversions.ToVector2 (ct.Point),
});
bb.Add (ct.Point);
bb.Add (ct.Control1);
bb.Add (ct.Control2);
}
else if (op is ClosePath) {
sink.EndFigure (D2D1.FigureEnd.Closed);
figureDepth--;
}
else {
// TODO: More path operations
}
}
while (figureDepth > 0) {
sink.EndFigure (D2D1.FigureEnd.Open);
figureDepth--;
}
sink.Close ();
}
var p = GetBrush (pen);
var b = GetBrush (bb.BoundingBox, brush);
if (b != null) {
renderTarget.FillGeometry (s, b);
}
if (p != null) {
renderTarget.DrawGeometry (s, p, (float)pen.Width, GetStrokeStyle (pen));
}
}
示例14: DrawEllipse
public void DrawEllipse(Rect frame, Pen pen = null, Brush brush = null)
{
if (brush != null) {
var paint = GetBrushPaint (brush, frame);
graphics.DrawOval (Conversions.GetRectF (frame), paint);
}
if (pen != null) {
var paint = GetPenPaint (pen);
graphics.DrawOval (Conversions.GetRectF (frame), paint);
}
}
示例15: DrawText
public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
{
}