本文整理汇总了C#中Cairo.LineTo方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.LineTo方法的具体用法?C# Cairo.LineTo怎么用?C# Cairo.LineTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo
的用法示例。
在下文中一共展示了Cairo.LineTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
/// <summary>
/// Draw the robot taking into account the center x and y position of the map which
/// will be different from the true center x and y positions on the drawing context.
/// This method will result in a red wheeled robot with black tyres being drawn at
/// the robots location on the map.
///
/// The scale value is currently unused but it could be useful if the map was scaled
/// in some way for example a mini-map may be 10 times smaller than the original
/// results in 1:10 scale robot.
/// </summary>
/// <param name="cairoContext">Cairo context to draw to (assuming a map).</param>
/// <param name="centerX">Center x position of map to draw onto.</param>
/// <param name="centerY">Center y position of map to draw onto.</param>
/// <param name="scale">Scale currently unused.</param>
public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale)
{
// Scale up to centimeters.
int width = (int)(robot.Width * 100);
int height = (int)(robot.Height * 100);
int x = (int)(robot.X * 100);
int y = (int)(robot.Y * 100);
// Set a red colour.
cairoContext.SetSourceRGB(255, 0, 0);
cairoContext.LineWidth = 1.0;
cairoContext.LineCap = LineCap.Butt;
cairoContext.Translate (centerX + x, centerY - y);
cairoContext.Rotate (relativeRotation); // Rotate the robot based on its orientation in radians.
// Draw the robot as a triangle.
cairoContext.MoveTo (0, -height / 2);
cairoContext.LineTo (-width / 2, height / 2);
cairoContext.LineTo (width / 2, height / 2);
cairoContext.LineTo (0, -height / 2);
cairoContext.Stroke ();
// Reset the drawing context.
cairoContext.Rotate (-relativeRotation);
cairoContext.Translate (-(centerX + x), -(centerY - y));
}
示例2: DrawHorizontalSectionIndicator
protected void DrawHorizontalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, double w, out double h)
{
cr.MoveTo(x,y);
cr.LineTo(x,y+SectionSerifeWidth*2);
cr.MoveTo(x,y+SectionSerifeWidth);
cr.LineTo(x+w,y+SectionSerifeWidth);
cr.MoveTo(x+w,y);
cr.LineTo(x+w,y+SectionSerifeWidth*2);
cr.Color = new Cairo.Color(0, 0, 0);
cr.LineWidth = 1;
cr.Stroke();
layout.Width = (int)(w*Pango.Scale.PangoScale);
layout.Alignment = Pango.Alignment.Center;
layout.SetText (text);
layout.Ellipsize = EllipsizeMode.Middle;
layout.Justify = true;
cr.Color = new Cairo.Color(0, 0, 0);
cr.MoveTo(x,y+SectionSerifeWidth*2);
Pango.CairoHelper.ShowLayout (cr, layout);
int lw,lh;
layout.GetPixelSize(out lw, out lh);
h=(double)lh+SectionSerifeWidth*2;
}
示例3: DrawRoundedRectangle
public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y,
double width, double height, double radius,
Cairo.Color color, Cairo.Color borderColor)
{
gr.Save();
if((radius > height / 2) || (radius > width / 2))
radius = Math.Min(height / 2, width / 2);
gr.MoveTo(x, y + radius);
gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
gr.LineTo(x + width - radius, y);
gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
gr.LineTo(x + width, y + height - radius);
gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
gr.LineTo(x + radius, y + height);
gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
gr.ClosePath();
gr.Restore();
gr.LineJoin = LineJoin.Round;
gr.Color = borderColor;
gr.StrokePreserve();
gr.Color = color;
gr.Fill();
}
示例4: RoundedRectangle
public static void RoundedRectangle(Cairo.Context c, RectangleD rect, double radius)
{
if (radius > (rect.Width /2) || radius > (rect.Height / 2)) {
radius = Math.Min ((rect.Width /2), (rect.Height / 2));
}
c.Save ();
/* Bottom Left */
c.MoveTo(rect.X, rect.Y + radius);
c.Arc (rect.X + radius, rect.Y + radius, radius, Math.PI, -Math.PI/2);
c.LineTo (rect.X2 - radius, rect.Y);
/* Bottom Right */
c.Arc (rect.X2 - radius, rect.Y + radius, radius, -Math.PI/2, 0);
c.LineTo (rect.X2, rect.Y2 - radius);
/* Top Right */
c.Arc (rect.X2 - radius, rect.Y2 - radius, radius, 0, Math.PI/2);
c.LineTo (rect.X + radius, rect.Y2);
/* Top Left */
c.Arc(rect.X + radius, rect.Y2 - radius, radius, Math.PI/2, Math.PI);
c.ClosePath ();
c.Restore ();
}
示例5: draw
static void draw (Cairo.Context gr, int width, int height)
{
double x=0.1, y=0.5;
double x1=0.4, y1=0.9, x2=0.6, y2=0.1, x3=0.9, y3=0.5;
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.MoveTo ( new PointD (x, y) );
gr.CurveTo ( new PointD (x1, y1),
new PointD (x2, y2),
new PointD (x3, y3)
);
gr.Stroke ();
gr.Color = new Color (1, 0.2, 0.2, 0.6);
gr.LineWidth = 0.03;
gr.MoveTo ( new PointD (x, y) );
gr.LineTo ( new PointD (x1, y1) );
gr.MoveTo ( new PointD (x2, y2) );
gr.LineTo ( new PointD (x3, y3) );
gr.Stroke ();
}
示例6: draw
static void draw (Cairo.Context gr, int width, int height)
{
int w, h;
ImageSurface image;
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI);
gr.Clip ();
gr.NewPath ();
image = new ImageSurface("data/e.png");
w = image.Width;
h = image.Height;
gr.Scale (1.0/w, 1.0/h);
image.Show (gr, 0, 0);
image.Destroy();
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Clip ();
gr.NewPath ();
gr.Rectangle (new PointD (0, 0), 1, 1);
gr.Fill ();
gr.Color = new Color (0, 1, 0, 1);
gr.MoveTo ( new PointD (0, 0) );
gr.LineTo ( new PointD (1, 1) );
gr.MoveTo ( new PointD (1, 0) );
gr.LineTo ( new PointD (0, 1) );
gr.Stroke ();
}
示例7: draw
static void draw (Cairo.Context gr, int width, int height)
{
double xc = 0.5;
double yc = 0.5;
double radius = 0.4;
double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */
double angle2 = 180.0 * (M_PI/180.0); /* in radians */
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.ArcNegative (xc, yc, radius, angle1, angle2);
gr.Stroke ();
/* draw helping lines */
gr.Color = new Color(1, 0.2, 0.2, 0.6);
gr.Arc (xc, yc, 0.05, 0, 2*M_PI);
gr.Fill ();
gr.LineWidth = 0.03;
gr.Arc (xc, yc, radius, angle1, angle1);
gr.LineTo (new PointD(xc, yc));
gr.Arc (xc, yc, radius, angle2, angle2);
gr.LineTo (new PointD(xc, yc));
gr.Stroke ();
}
示例8: DrawTriangle
public static void DrawTriangle(Cairo.Context g, double x, double y,
int width, int height, Cairo.Color color)
{
g.Color = color;
g.MoveTo(x, y);
g.LineTo(x + width/2, y-height);
g.LineTo(x - width/2, y-height);
g.ClosePath();
g.Fill();
g.Stroke();
}
示例9: DrawDiamond
protected void DrawDiamond (Cairo.Context cr, double x, double y, double size)
{
x += 0.5; y += 0.5;
size -= 2;
cr.NewPath ();
cr.MoveTo (x + size/2, y);
cr.LineTo (x + size, y + size/2);
cr.LineTo (x + size/2, y + size);
cr.LineTo (x, y + size/2);
cr.LineTo (x + size/2, y);
cr.ClosePath ();
}
示例10: RenderInvertedTriangle
public static void RenderInvertedTriangle(Cairo.Context g, Cairo.Color c, double x, double y, int side)
{
g.Save();
g.Color = c;
g.MoveTo(x, y);
g.LineTo(x - side / 2, y - side);
g.LineTo(x + side / 2, y - side);
g.LineTo(x, y);
g.Fill();
g.Restore();
}
示例11: draw
public void draw(Cairo.Context cr)
{
cr.LineWidth = 3;
cr.SetSourceRGB(0, 0.9, 0.0);
//cr.Translate (l1.P1.X, l1.P1.Y);
cr.MoveTo(position);
cr.LineTo (position.X + width, position.Y);
cr.LineTo (position.X + width, position.Y + height);
cr.LineTo (position.X, position.Y + height);
cr.LineTo (position.X, position.Y);
cr.Stroke ();
}
示例12: DrawFrameBorder
public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
{
if (IsPanelWidget) {
return;
} else if (!IsSourceViewWidget) {
base.DrawFrameBorder (cr, alloc);
return;
}
cr.SetSourceColor (TextMidColor);
cr.LineWidth = 1.0;
cr.Antialias = Cairo.Antialias.None;
cr.MoveTo (alloc.Right - 1, alloc.Top);
cr.LineTo (alloc.Right - 1, alloc.Bottom);
cr.Stroke ();
if (Widget.Allocation.Bottom < Widget.Toplevel.Allocation.Height) {
cr.MoveTo (alloc.Left, alloc.Bottom - 1);
cr.LineTo (alloc.Right, alloc.Bottom - 1);
cr.Stroke ();
}
cr.Antialias = Cairo.Antialias.Default;
}
示例13: Draw
/// <summary>
/// Draw the specified cairoContext, centerX, centerY and scale.
/// </summary>
/// <param name="cairoContext">Cairo context.</param>
/// <param name="centerX">Center x.</param>
/// <param name="centerY">Center y.</param>
/// <param name="scale">Scale.</param>
public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale)
{
cairoContext.SetSourceRGB (0, 0, 200);
cairoContext.LineWidth = 1.0;
cairoContext.LineCap = LineCap.Butt;
//cairoContext.MoveTo (OriginalX, -OriginalY);
//int x = centerX;
//Console.WriteLine ("point: " + (robot.PathPointList [robot.PathPointList.Count-1] [1]*100));
//if (30 <= (robot.PathPointList [robot.PathPointList.Count - 1] [1] * 100))
//{
//robot.Halt ();
//Console.WriteLine ("\n\n Has Gone 30cm \n\n");
//}
for (int i = 1; i < robot.PathPointList.Count; i++)
{
cairoContext.MoveTo (centerX + (robot.PathPointList [i - 1] [0] * 100), centerY - (robot.PathPointList [i - 1] [1] * 100));
cairoContext.LineTo (centerX + (robot.PathPointList [i] [0] * 100), centerY - (robot.PathPointList [i] [1] * 100));
// Console.WriteLine (path[0]*100+" , "+ path[1]*100);
cairoContext.Stroke ();
}
foreach (double[] path in robot.PathPointList)
{
//cairoContext.MoveTo (centerX - (path[0] * 100), centerY - (path[1] * 100));
}
}
示例14: Draw
internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, LineSegment lineSegment, int line, double x, double y, double lineHeight)
{
cr.MoveTo (x + 0.5, y);
cr.LineTo (x + 0.5, y + lineHeight);
cr.Color = color;
cr.Stroke ();
}
示例15: Draw
private void Draw(Cairo.Context cr, int width, int heigth)
{
foreach (var path in pathPosition.Keys)
{
var pPosition = pathPosition[path];
var begin = pPosition.Item1;
var end = pPosition.Item2;
cr.SetSourceRGB(1, 1, 1);
cr.MoveTo(begin.X, begin.Y);
cr.LineTo(end.X, end.Y);
cr.Stroke();
cr.SetSourceRGB(0, 0, 0);
}
foreach (var path in pathPosition.Keys)
{
var pPosition = pathPosition[path];
var begin = pPosition.Item1;
var end = pPosition.Item2;
if (path is BlockingPath)
{
var blockingPath = path as BlockingPath;
if (blockingPath.IsBlocked)
{
cr.SetSourceRGB(1, 0, 0);
}
else
{
cr.SetSourceRGB(0, 1, 0);
}
cr.Rectangle(new Cairo.Rectangle(end.X - 6, end.Y - 6, 12, 12));
cr.Fill();
cr.SetSourceRGB(0, 0, 0);
}
else if (path is SourcePath)
{
var sourcePath = path as SourcePath;
cr.MoveTo(begin.X, begin.Y);
cr.TextPath(sourcePath.Queue.ToString());
cr.Fill();
}
foreach (var vehicle in path.VehiclePosition.Keys)
{
var position = path.VehiclePosition[vehicle];
var r = position / path.Length;
var x = begin.X + (end.X - begin.X) * r;
var y = begin.Y + (end.Y - begin.Y) * r;
cr.Arc(x, y, 5, 0, 2 * Math.PI);
cr.Fill();
}
}
cr.Stroke();
}