/// <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)); }
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; }
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(); }
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 (); }
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 (); }
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 (); }
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 (); }
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(); }
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 (); }
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(); }
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 (); }
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; }
/// <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)); } }
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 (); }
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(); }
static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; gr.MoveTo ( new PointD (0.5, 0.1) ); gr.LineTo ( new PointD (0.9, 0.9) ); gr.RelLineTo ( new Distance (-0.4, 0.0) ); gr.CurveTo ( new PointD (0.2, 0.9), new PointD ( 0.2, 0.5), new PointD (0.5, 0.5) ); gr.ClosePath (); gr.MoveTo ( new PointD (0.25, 0.1) ); gr.RelLineTo ( new Distance (0.2, 0.2) ); gr.RelLineTo ( new Distance ( -0.2, 0.2) ); gr.RelLineTo ( new Distance (-0.2, -0.2) ); gr.ClosePath (); gr.Color = new Color (0, 0, 1, 1); gr.FillPreserve (); gr.Color = new Color ( 0, 0, 0, 1); gr.Stroke (); }
static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius) { gr.Save (); if ((radius > height / 2) || (radius > width / 2)) radius = min (height / 2, width / 2); gr.Color = new Color (200, 10, 210, 1); 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 (); }
static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; 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 (); }
public static void RenderLine(Cairo.Context g, Cairo.Color c, double lw, double x0, double y0, double x1, double y1) { g.Save(); g.Color = c; g.LineWidth = 3; g.MoveTo(x0, y0); g.LineTo(x1, y1); g.Stroke(); g.Restore(); }
protected override void OnLayoutOutline (Cairo.Context context) { // polygons have 3 sides if (verticies.Count <= 2) return; var renderVerts = verticies.Select (v => new Cairo.PointD (v.X * Width, v.Y * Height)).ToList (); context.MoveTo (renderVerts.First ()); renderVerts.ForEach (v => context.LineTo (v)); }
/// <summary> /// The draw rounded rectangle. /// </summary> protected void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius) { gr.Save(); if ((radius > height / 2) || (radius > width / 2)) { radius = Math.Min(height / 2, width / 2); } gr.MoveTo(this._x + x, this._y + y + radius); gr.Arc(this._x + x + radius, this._y + y + radius, radius, Math.PI, -Math.PI / 2); gr.LineTo(this._x + x + width - radius, this._y + y); gr.Arc(this._x + x + width - radius, this._y + y + radius, radius, -Math.PI / 2, 0); gr.LineTo(this._x + x + width, this._y + y + height - radius); gr.Arc(this._x + x + width - radius, this._y + y + height - radius, radius, 0, Math.PI / 2); gr.LineTo(this._x + x + radius, this._y + y + height); gr.Arc(this._x + x + radius, this._y + y + height - radius, radius, Math.PI / 2, Math.PI); gr.ClosePath(); gr.Restore(); }
public static void DrawLine(Cairo.Context g, double x1, double y1, double x2, double y2, int width, Cairo.Color color) { g.Color = color; g.Operator = Operator.Over; g.LineWidth = width; g.MoveTo(x1, y1); g.LineTo(x2,y2); g.Stroke(); }
public static void CurvedRectangle(Cairo.Context c, RectangleD rect, double radius) { if (rect.Width < (radius * 2.0) ) { radius = rect.Width/2.0; } if (rect.Height < (radius * 2.0) ) { radius = rect.Height/2.0; } c.MoveTo (rect.X, rect.Y+radius); c.LineTo (rect.X, rect.Y2-radius); c.CurveTo (rect.X, rect.Y2-radius, rect.X, rect.Y2, rect.X+radius, rect.Y2); c.LineTo (rect.X2-radius, rect.Y2); c.CurveTo (rect.X2-radius, rect.Y2, rect.X2, rect.Y2, rect.X2, rect.Y2-radius); c.LineTo (rect.X2, rect.Y+radius); c.CurveTo (rect.X2, rect.Y+radius, rect.X2, rect.Y, rect.X2-radius, rect.Y); c.LineTo (rect.X+radius, rect.Y); c.CurveTo (rect.X+radius, rect.Y, rect.X, rect.Y, rect.X, rect.Y+radius); }
void DrawHand (double fThickness, double length, Cairo.Color color, double radians, Cairo.Context e) { e.MoveTo (new Cairo.PointD (center.X - (length / 9 * Math.Sin (radians)), center.Y + (length / 9 * Math.Cos (radians)))); e.LineTo (new Cairo.PointD (center.X + (length * Math.Sin (radians)), center.Y - (length * Math.Cos (radians)))); e.ClosePath (); e.LineCap = Cairo.LineCap.Round; e.LineJoin = Cairo.LineJoin.Round; e.Color = color; e.LineWidth = fThickness; e.Stroke (); }
protected void DrawVerticalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, out double w, double h) { cr.MoveTo(x,y); cr.LineTo(x+SectionSerifeWidth*2,y); cr.MoveTo(x+SectionSerifeWidth,y); cr.LineTo(x+SectionSerifeWidth,y+h); cr.MoveTo(x,y+h); cr.LineTo(x+SectionSerifeWidth*2,y+h); cr.Color = new Cairo.Color(0, 0, 0); cr.LineWidth = 1; layout.Alignment = Pango.Alignment.Left; layout.SetText (text); layout.Ellipsize = EllipsizeMode.Middle; layout.Justify = true; int lh,lw; layout.GetPixelSize(out lw, out lh); w=(double)lw+SectionSerifeWidth*2; cr.Color = new Cairo.Color(0, 0, 0); cr.MoveTo(x+SectionSerifeWidth*2,y+(h-lh)/2); Pango.CairoHelper.ShowLayout (cr, layout); }
void IIconBarMarker.DrawBackground (TextEditor ed, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height) { cr.Rectangle (x, y, width, height); cr.Color = LineColor.SecondColor; cr.Fill (); cr.MoveTo (x + width - 0.5, y); cr.LineTo (x + width - 0.5, y + height); cr.Color = LineColor.BorderColor; cr.Stroke (); if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this) { cr.Rectangle (x, y, width, height); cr.Color = new Cairo.Color (ed.ColorStyle.IndicatorMargin.Color.R, ed.ColorStyle.IndicatorMargin.Color.G, ed.ColorStyle.IndicatorMargin.Color.B, 0.5); cr.Fill (); } }
protected override void onDraw(Cairo.Context gr) { gr.Save (); int spacing = (Parent as TabView).Spacing; gr.MoveTo (0.5, TabTitle.Slot.Bottom-0.5); gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom-0.5); gr.CurveTo ( TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom-0.5, TabTitle.Slot.Left - spacing / 2, 0.5, TabTitle.Slot.Left, 0.5); gr.LineTo (TabTitle.Slot.Right, 0.5); gr.CurveTo ( TabTitle.Slot.Right + spacing / 2, 0.5, TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom-0.5, TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom-0.5); gr.LineTo (Slot.Width-0.5, TabTitle.Slot.Bottom-0.5); gr.LineTo (Slot.Width-0.5, Slot.Height-0.5); gr.LineTo (0.5, Slot.Height-0.5); gr.ClosePath (); gr.LineWidth = 2; Foreground.SetAsSource (gr); gr.StrokePreserve (); gr.Clip (); base.onDraw (gr); gr.Restore (); }
protected void DrawLeftBorder (Cairo.Context cr) { cr.MoveTo (0.5, 0); cr.LineTo (0.5, Allocation.Height); if (TextEditor.ColorStyle != null) { var col = (HslColor)TextEditor.ColorStyle.PlainText.Background; if (!Platform.IsWindows) { col.L *= 0.88; } cr.SetSourceColor (col); } cr.Stroke (); }
protected void DrawCaret (Cairo.Context cr) { if (TextEditor.ColorStyle == null || caretLine < 0) return; double y = GetYPosition (caretLine); cr.MoveTo (0, y - 4); cr.LineTo (7, y); cr.LineTo (0, y + 4); cr.ClosePath (); cr.SetSourceColor (TextEditor.ColorStyle.PlainText.Foreground); cr.Fill (); }
public override void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics layout, int startOffset, int endOffset) { if (DebuggingService.IsDebugging) return; int markerStart = Segment.Offset; int markerEnd = Segment.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; double drawFrom; double drawTo; double y = layout.LineYRenderStartPosition; double startXPos = layout.TextRenderStartPosition; double endXPos = layout.TextRenderEndPosition; if (markerStart < startOffset && endOffset < markerEnd) { drawTo = endXPos; var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; drawFrom = startXPos + (layout.Layout.Layout.IndexToPos (offset).X / Pango.Scale.PangoScale); } else { int start; if (startOffset < markerStart) { start = markerStart; } else { var line = editor.GetLineByOffset (startOffset); int offset = line.GetIndentation (editor.Document).Length; start = startOffset + offset; } int end = endOffset < markerEnd ? endOffset : markerEnd; int x_pos; x_pos = layout.Layout.Layout.IndexToPos (start - startOffset).X; drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale); x_pos = layout.Layout.Layout.IndexToPos (end - startOffset).X; drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } drawFrom = Math.Max (drawFrom, editor.TextViewMargin.XOffset); drawTo = Math.Max (drawTo, editor.TextViewMargin.XOffset); if (drawFrom >= drawTo) return; double height = editor.LineHeight / 5; cr.SetSourceColor (color); if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.WavedLine) { Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height); } else if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine) { cr.Save (); cr.LineWidth = 1; cr.MoveTo (drawFrom + 1, y + editor.LineHeight - 1 + 0.5); cr.RelLineTo (Math.Min (drawTo - drawFrom, 4 * 3), 0); cr.SetDash (new double[] { 2, 2 }, 0); cr.Stroke (); cr.Restore (); } else { cr.MoveTo (drawFrom, y + editor.LineHeight - 1); cr.LineTo (drawTo, y + editor.LineHeight - 1); cr.Stroke (); } }