本文整理汇总了C#中Cairo.RelLineTo方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.RelLineTo方法的具体用法?C# Cairo.RelLineTo怎么用?C# Cairo.RelLineTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo
的用法示例。
在下文中一共展示了Cairo.RelLineTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: draw
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 ();
}
示例2: DrawRoundRectangle
public static void DrawRoundRectangle (Cairo.Context cr, double x, double y, double r, double w, double h)
{
const double ARC_TO_BEZIER = 0.55228475;
double radius_x = r;
double radius_y = r / 4;
if (radius_x > w - radius_x)
radius_x = w / 2;
if (radius_y > h - radius_y)
radius_y = h / 2;
double c1 = ARC_TO_BEZIER * radius_x;
double c2 = ARC_TO_BEZIER * radius_y;
cr.NewPath ();
cr.MoveTo (x + radius_x, y);
cr.RelLineTo (w - 2 * radius_x, 0.0);
cr.RelCurveTo (c1, 0.0,
radius_x, c2,
radius_x, radius_y);
cr.RelLineTo (0, h - 2 * radius_y);
cr.RelCurveTo (0.0, c2, c1 - radius_x, radius_y, -radius_x, radius_y);
cr.RelLineTo (-w + 2 * radius_x, 0);
cr.RelCurveTo (-c1, 0, -radius_x, -c2, -radius_x, -radius_y);
cr.RelLineTo (0, -h + 2 * radius_y);
cr.RelCurveTo (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y);
cr.ClosePath ();
}
示例3: Draw
public void Draw (Cairo.Context cr, Cairo.Rectangle rectangle)
{
if (IsSeparator) {
cr.NewPath ();
double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5;
cr.MoveTo (x, rectangle.Y + 0.5 + 2);
cr.RelLineTo (0, rectangle.Height - 1 - 4);
cr.ClosePath ();
cr.Color = (HslColor)parent.Style.Dark (StateType.Normal);
cr.LineWidth = 1;
cr.Stroke ();
return;
}
if (Active || HoverPosition.X >= 0) {
if (Active) {
cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
gr.AddColorStop (0, Tabstrip.ActiveGradientStart);
gr.AddColorStop (1, Tabstrip.ActiveGradientEnd);
cr.Pattern = gr;
}
cr.Fill ();
cr.Rectangle (rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1);
cr.Color = new Cairo.Color (1, 1, 1, 0.05);
cr.LineWidth = 1;
cr.Stroke ();
} else if (HoverPosition.X >= 0) {
cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
using (var gr = new LinearGradient (rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) {
var c1 = Tabstrip.ActiveGradientStart;
var c2 = Tabstrip.ActiveGradientEnd;
c1.A = 0.2;
c2.A = 0.2;
gr.AddColorStop (0, c1);
gr.AddColorStop (1, c2);
cr.Pattern = gr;
}
cr.Fill ();
}
}
if (Active)
cr.Color = new Cairo.Color (1, 1, 1);
else
cr.Color = parent.Style.Text (StateType.Normal).ToCairoColor ();
cr.MoveTo (rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2);
Pango.CairoHelper.ShowLayout (cr, layout);
}
示例4: DrawErrorMarkers
void DrawErrorMarkers (TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, double x, double y)
{
uint curIndex = 0, byteIndex = 0;
foreach (var task in errors.Select (t => t.Task)) {
int index = (int)layout2.TranslateToUTF8Index ((uint)(task.Column - 1), ref curIndex, ref byteIndex);
var pos = layout2.Layout.IndexToPos (index);
g.Color = MarkerColor.Color;
g.MoveTo (
x + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
y + editor.LineHeight - 4
);
g.RelLineTo (3, 3);
g.RelLineTo (-6, 0);
g.ClosePath ();
g.Fill ();
}
}
示例5: DrawErrorMarkers
void DrawErrorMarkers (MonoTextEditor editor, Cairo.Context g, LineMetrics metrics, double y)
{
uint curIndex = 0, byteIndex = 0;
var o = metrics.LineSegment.Offset;
foreach (var task in errors.Select (t => t.Task)) {
var column = (uint)(Math.Min (Math.Max (0, task.Column - 1), metrics.Layout.LineChars.Length));
var line = editor.GetLine (task.Line);
// skip possible white space locations
while (column < line.Length && char.IsWhiteSpace (editor.GetCharAt (line.Offset + (int)column))) {
column++;
}
if (column >= line.Length)
continue;
int index = (int)metrics.Layout.TranslateToUTF8Index (column, ref curIndex, ref byteIndex);
var pos = metrics.Layout.Layout.IndexToPos (index);
var co = o + task.Column - 1;
g.SetSourceColor (GetMarkerColor (false, metrics.SelectionStart <= co && co < metrics.SelectionEnd));
g.MoveTo (
metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
y + editor.LineHeight - 3
);
g.RelLineTo (3, 3);
g.RelLineTo (-6, 0);
g.ClosePath ();
g.Fill ();
}
}
示例6: DrawMarkedPositions
void DrawMarkedPositions(Cairo.Context cr)
{
if (MarkedPositionsToDisplay) {
SetColor (cr, ref ColorMarkedPos);
if (markedPositions.Length == PosSize) {
// all positions are marked
Rectangle (cr, ref totalRect);
cr.Fill ();
} else {
foreach (int i in markedPositions) {
cr.MoveTo (WorldToPhysicalX (i), 0);
cr.RelLineTo (0, height);
}
// single call is much faster
cr.Stroke ();
}
}
}
示例7: DrawHoverBackground
protected virtual void DrawHoverBackground(Cairo.Context ctx)
{
if (BorderPadding <= 0) {
ctx.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBackgroundColor));
ctx.Fill ();
ctx.MoveTo (Allocation.X, Allocation.Y + 0.5);
ctx.RelLineTo (Allocation.Width, 0);
ctx.MoveTo (Allocation.X, Allocation.Y + Allocation.Height - 0.5);
ctx.RelLineTo (Allocation.Width, 0);
if (DrawRightBorder) {
ctx.MoveTo (Allocation.Right + 0.5, Allocation.Y + 0.5);
ctx.LineTo (Allocation.Right + 0.5, Allocation.Bottom - 0.5);
}
if (DrawLeftBorder) {
ctx.MoveTo (Allocation.Left + 0.5, Allocation.Y + 0.5);
ctx.LineTo (Allocation.Left + 0.5, Allocation.Bottom - 0.5);
}
ctx.LineWidth = 1;
ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBorderColor));
ctx.Stroke ();
}
else {
Gdk.Rectangle region = Allocation;
region.Inflate (-BorderPadding, -BorderPadding);
ctx.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3);
ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBackgroundColor));
ctx.FillPreserve ();
ctx.LineWidth = 1;
ctx.SetSourceColor (CairoExtensions.ParseColor (HoverBorderColor));
ctx.Stroke ();
}
}
示例8: DrawErrorMarkers
void DrawErrorMarkers (TextEditor editor, Cairo.Context g, LineMetrics metrics, double y)
{
uint curIndex = 0, byteIndex = 0;
var o = metrics.LineSegment.Offset;
foreach (var task in errors.Select (t => t.Task)) {
var column = (uint)(Math.Min (Math.Max (0, task.Column - 1), metrics.Layout.LineChars.Length));
int index = (int)metrics.Layout.TranslateToUTF8Index (column, ref curIndex, ref byteIndex);
var pos = metrics.Layout.Layout.IndexToPos (index);
var co = o + task.Column - 1;
g.SetSourceColor (GetMarkerColor (false, metrics.SelectionStart <= co && co < metrics.SelectionEnd));
g.MoveTo (
metrics.TextRenderStartPosition + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
y + editor.LineHeight - 3
);
g.RelLineTo (3, 3);
g.RelLineTo (-6, 0);
g.ClosePath ();
g.Fill ();
}
}
示例9: Draw
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 ();
}
}
示例10: DrawButtonTabs
void DrawButtonTabs (Cairo.Context cr, Cairo.Rectangle rectangle)
{
if (IsSeparator) {
cr.NewPath ();
double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5;
cr.MoveTo (x, rectangle.Y + 0.5 + 2);
cr.RelLineTo (0, rectangle.Height - 1 - 4);
cr.ClosePath ();
cr.Color = (HslColor)parent.Style.Dark (StateType.Normal);
cr.LineWidth = 1;
cr.Stroke ();
return;
}
int topPadding = 2;
if (Active || HoverPosition.X >= 0) {
cr.Rectangle (rectangle.X + 1, rectangle.Y + 1 + topPadding, rectangle.Width - 1, rectangle.Height - topPadding);
if (Active) {
cr.Color = (HslColor)parent.Style.Background (StateType.Prelight);
} else if (HoverPosition.X >= 0) {
double rx = rectangle.X + HoverPosition.X;
double ry = rectangle.Y + HoverPosition.Y;
Cairo.RadialGradient gradient = new Cairo.RadialGradient (rx, ry, rectangle.Height * 1.5,
rx, ry, 2);
var color = (HslColor)parent.Style.Dark (StateType.Normal);
color.L *= 1.1;
gradient.AddColorStop (0, color);
color.L *= 1.1;
gradient.AddColorStop (1, color);
cr.Pattern = gradient;
}
cr.Fill ();
if (Active) {
cr.Rectangle (rectangle.X + 0.5, rectangle.Y + 0.5 + topPadding, rectangle.Width - 1, rectangle.Height - topPadding);
cr.Color = (HslColor)parent.Style.Dark (StateType.Normal);
cr.LineWidth = 1;
cr.Stroke ();
}
}
cr.Save ();
cr.Translate (rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2 + topPadding);
cr.Color = (HslColor)parent.Style.Text (StateType.Normal);
cr.ShowLayout (layout);
cr.Restore ();
}
示例11: Draw
public void Draw (Cairo.Context cr, Cairo.Rectangle rectangle)
{
if (IsSeparator) {
cr.NewPath ();
double x = Math.Ceiling (rectangle.X + rectangle.Width / 2) + 0.5;
cr.MoveTo (x, rectangle.Y + 0.5 + 2);
cr.RelLineTo (0, rectangle.Height - 1 - 4);
cr.ClosePath ();
cr.SetSourceColor (Styles.SubTabBarSeparatorColor.ToCairoColor ());
cr.LineWidth = 1;
cr.Stroke ();
return;
}
if (Active || HoverPosition.X >= 0) {
if (Active) {
cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
cr.SetSourceColor (Styles.SubTabBarActiveBackgroundColor.ToCairoColor ());
cr.Fill ();
} else if (HoverPosition.X >= 0) {
cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
cr.SetSourceColor (Styles.SubTabBarHoverBackgroundColor.ToCairoColor ());
cr.Fill ();
}
}
if (Active) {
cr.SetSourceColor (Styles.SubTabBarActiveTextColor.ToCairoColor ());
layout.FontDescription = FontService.SansFont.CopyModified (Styles.FontScale11, Pango.Weight.Bold);
} else {
cr.SetSourceColor (Styles.SubTabBarTextColor.ToCairoColor ());
layout.FontDescription = FontService.SansFont.CopyModified (Styles.FontScale11);
}
layout.Width = (int)rectangle.Width;
cr.MoveTo (rectangle.X + (int)(rectangle.Width / 2), (rectangle.Height - h) / 2 - 1);
Pango.CairoHelper.ShowLayout (cr, layout);
}
示例12: Draw
public new void Draw (Cairo.Context cr)
{
Gdk.Rectangle rect;
if (GradientBackround) {
rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
HslColor gcol = useCustomColor ? customColor : Parent.Style.Background (Gtk.StateType.Normal);
cr.NewPath ();
cr.MoveTo (rect.X, rect.Y);
cr.RelLineTo (rect.Width, 0);
cr.RelLineTo (0, rect.Height);
cr.RelLineTo (-rect.Width, 0);
cr.RelLineTo (0, -rect.Height);
cr.ClosePath ();
using (Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + rect.Height - 1)) {
Cairo.Color color1 = gcol;
pat.AddColorStop (0, color1);
gcol.L -= 0.1;
if (gcol.L < 0)
gcol.L = 0;
pat.AddColorStop (1, gcol);
cr.Pattern = pat;
cr.FillPreserve ();
}
}
base.Draw (cr);
//FIXME: Get this drawing properly again!
// Gdk.Color colour = Parent.Style.Dark (Gtk.StateType.Normal);
// cr.SetSourceRGB (colour.Red, colour.Green, colour.Blue);
//
// rect = Allocation;
// for (int n=0; n<topMargin; n++)
// GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Left + rect.Width - 1, rect.Y + n);
//
// for (int n=0; n<bottomMargin; n++)
// GdkWindow.DrawLine (borderColor, rect.X, rect.Top + rect.Height - 1 - n, rect.Left + rect.Width - 1, rect.Top + rect.Height - 1 - n);
//
// for (int n=0; n<leftMargin; n++)
// GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Top + rect.Height - 1);
//
// for (int n=0; n<rightMargin; n++)
// GdkWindow.DrawLine (borderColor, rect.Left + rect.Width - 1 - n, rect.Y, rect.Left + rect.Width - 1 - n, rect.Top + rect.Height - 1);
}
示例13: OnDrawn
protected override void OnDrawn (Cairo.Context cr, Gdk.Rectangle rect)
{
if (BackgroundColor.HasValue) {
cr.Rectangle (rect.X, rect.Y, rect.Width, rect.Height);
cr.SetSourceColor (BackgroundColor.Value.ToCairoColor ());
cr.Fill ();
}
if (GradientBackround) {
Color gcol = Style.Background (Gtk.StateType.Normal).ToXwtValue ();
cr.NewPath ();
cr.MoveTo (rect.X, rect.Y);
cr.RelLineTo (rect.Width, 0);
cr.RelLineTo (0, rect.Height);
cr.RelLineTo (-rect.Width, 0);
cr.RelLineTo (0, -rect.Height);
cr.ClosePath ();
using (var pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Bottom)) {
Cairo.Color color1 = gcol.ToCairoColor ();
pat.AddColorStop (0, color1);
gcol.Light -= 0.1;
pat.AddColorStop (1, gcol.ToCairoColor ());
cr.SetSource (pat);
cr.FillPreserve ();
}
}
cr.SetSourceColor (color.HasValue ? color.Value.ToCairoColor () : Style.Dark (Gtk.StateType.Normal).ToXwtValue ().ToCairoColor ());
cr.Rectangle (rect.X, rect.Y, rect.Width, topMargin);
cr.Rectangle (rect.X, rect.Y + rect.Height - bottomMargin, rect.Width, bottomMargin);
cr.Rectangle (rect.X, rect.Y, leftMargin, rect.Height);
cr.Rectangle (rect.X + rect.Width - rightMargin, rect.Y, rightMargin, rect.Height);
cr.Fill ();
}
示例14: DrawOutputndicator
private void DrawOutputndicator(Cairo.Context context)
{
context.Save();
RelativeLocator locator = new RelativeLocator(-0.04, 1.2);
PointD point = locator.Locate(this);
context.MoveTo(point);
context.LineCap = LineCap.Round;
context.Color = s_ioIndicatorColor;
double l = 4; //arm lenght of indicator icon
double s = 0.4; //spacing between arms in the indicator icon
//draw <<
//up
context.RelLineTo (new Distance (-s, -l));
context.RelMoveTo (new Distance (s, l)); //back
//right
context.RelLineTo (new Distance (l, s));
context.RelMoveTo (new Distance (-l, -s)); //back
context.RelMoveTo (new Distance (3, -3));
//repeat above for second arrow
context.RelLineTo (new Distance (-s, -l));
context.RelMoveTo (new Distance (s, l)); //back
context.RelLineTo (new Distance (l, s));
context.RelMoveTo (new Distance (-l, -s)); //back
context.Stroke();
context.Restore();
}
示例15: DrawLineEndAtIter
static void DrawLineEndAtIter (Cairo.Context cntx, TextView view, TextIter iter)
{
Gdk.Rectangle rect = view.GetIterLocation (iter);
int x, y;
view.BufferToWindowCoords (TextWindowType.Text,
rect.X,
rect.Y + rect.Height / 2,
out x, out y);
cntx.Save ();
cntx.Color = GetDrawingColorForIter (view, iter);
double arrowSize = 3;
cntx.MoveTo (x + 10, y);
cntx.RelLineTo (new Cairo.Distance (0, -arrowSize));
cntx.RelMoveTo (new Cairo.Distance (0, arrowSize));
cntx.RelLineTo (new Cairo.Distance (-8, 0));
cntx.RelLineTo (new Cairo.Distance (arrowSize, arrowSize));
cntx.RelMoveTo (new Cairo.Distance (-arrowSize, -arrowSize));
cntx.RelLineTo (new Cairo.Distance (arrowSize, -arrowSize));
cntx.Stroke ();
cntx.Restore ();
}