本文整理汇总了C#中Cairo.NewPath方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.NewPath方法的具体用法?C# Cairo.NewPath怎么用?C# Cairo.NewPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo
的用法示例。
在下文中一共展示了Cairo.NewPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例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: Fill
public static void Fill(Cairo.Context context, Gtk.Widget widget, Cairo.Color color)
{
context.NewPath();
context.Color = color;
context.Rectangle(0, 0, widget.Allocation.Width, widget.Allocation.Height);
context.Fill();
}
示例4: DrawCircle
protected void DrawCircle (Cairo.Context cr, double x, double y, double size)
{
x += 0.5; y += 0.5;
cr.NewPath ();
cr.Arc (x + size/2, y + size / 2, (size-4)/2, 0, 2 * Math.PI);
cr.ClosePath ();
}
示例5: 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 ();
}
示例6: draw
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 ();
}
示例7: 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);
}
示例8: DrawForeground
public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
{
cr.Arc (metrics.X + metrics.Width / 2 + 2, metrics.Y + metrics.Height / 2, 7 * editor.Options.Zoom, 0, Math.PI * 2);
isFailed = false;
var test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier);
bool searchCases = false;
if (unitTest.IsIgnored) {
cr.SetSourceRGB (0.9, 0.9, 0);
} else {
if (test != null) {
var result = test.GetLastResult ();
if (result == null) {
cr.SetSourceRGB (0.5, 0.5, 0.5);
searchCases = true;
} else if (result.IsNotRun) {
cr.SetSourceRGBA (0.9, 0.9, 0, test.IsHistoricResult ? 0.5 : 1.0);
} else if (result.IsSuccess) {
cr.SetSourceRGBA (0, 1, 0, test.IsHistoricResult ? 0.2 : 1.0);
} else if (result.IsFailure) {
cr.SetSourceRGBA (1, 0, 0, test.IsHistoricResult ? 0.2 : 1.0);
failMessage = result.Message;
isFailed = true;
} else if (result.IsInconclusive) {
cr.SetSourceRGBA (0, 1, 1, test.IsHistoricResult ? 0.2 : 1.0);
} else {
cr.SetSourceRGB (0.5, 0.5, 0.5);
}
} else {
cr.SetSourceRGB (0.5, 0.5, 0.5);
searchCases = true;
}
if (searchCases) {
foreach (var caseId in unitTest.TestCases) {
test = NUnitService.Instance.SearchTestById (unitTest.UnitTestIdentifier + caseId);
if (test != null) {
var result = test.GetLastResult ();
if (result == null || result.IsNotRun || test.IsHistoricResult) {
} else if (result.IsNotRun) {
cr.SetSourceRGB (0.9, 0.9, 0);
} else if (result.IsSuccess) {
cr.SetSourceRGB (0, 1, 0);
} else if (result.IsFailure) {
cr.SetSourceRGB (1, 0, 0);
failMessage = result.Message;
isFailed = true;
break;
} else if (result.IsInconclusive) {
cr.SetSourceRGB (0, 1, 1);
}
}
}
}
}
cr.FillPreserve ();
if (unitTest.IsIgnored) {
cr.SetSourceRGB (0.4, 0.4, 0);
cr.Stroke ();
} else {
if (test != null) {
var result = test.GetLastResult ();
if (result == null) {
cr.SetSourceRGB (0.2, 0.2, 0.2);
cr.Stroke ();
} else if (result.IsNotRun && !test.IsHistoricResult) {
cr.SetSourceRGB (0.4, 0.4, 0);
cr.Stroke ();
} else if (result.IsSuccess && !test.IsHistoricResult) {
cr.SetSourceRGB (0, 0.5, 0);
cr.Stroke ();
} else if (result.IsFailure && !test.IsHistoricResult) {
cr.SetSourceRGB (0.5, 0, 0);
cr.Stroke ();
} else if (result.IsInconclusive && !test.IsHistoricResult) {
cr.SetSourceRGB (0, 0.7, 0.7);
cr.Stroke ();
}
}
}
cr.NewPath ();
}
示例9: Render
public void Render (Cairo.Context context, StatusArea.RenderArg arg)
{
context.CachedDraw (surface: ref backgroundSurface,
region: arg.Allocation,
draw: (c, o) => DrawBackground (c, new Gdk.Rectangle (0, 0, arg.Allocation.Width, arg.Allocation.Height)));
if (arg.BuildAnimationOpacity > 0.001f)
DrawBuildEffect (context, arg.Allocation, arg.BuildAnimationProgress, arg.BuildAnimationOpacity);
if (arg.ErrorAnimationProgress > 0.001 && arg.ErrorAnimationProgress < .999) {
DrawErrorAnimation (context, arg);
}
DrawBorder (context, arg.Allocation);
if (arg.HoverProgress > 0.001f)
{
context.Clip ();
int x1 = arg.Allocation.X + arg.MousePosition.X - 200;
int x2 = x1 + 400;
using (Cairo.LinearGradient gradient = new LinearGradient (x1, 0, x2, 0))
{
Cairo.Color targetColor = Styles.StatusBarFill1Color;
Cairo.Color transparentColor = targetColor;
targetColor.A = .7;
transparentColor.A = 0;
targetColor.A = .7 * arg.HoverProgress;
gradient.AddColorStop (0.0, transparentColor);
gradient.AddColorStop (0.5, targetColor);
gradient.AddColorStop (1.0, transparentColor);
context.Pattern = gradient;
context.Rectangle (x1, arg.Allocation.Y, x2 - x1, arg.Allocation.Height);
context.Fill ();
}
context.ResetClip ();
} else {
context.NewPath ();
}
int progress_bar_x = arg.ChildAllocation.X;
int progress_bar_width = arg.ChildAllocation.Width;
if (arg.CurrentPixbuf != null) {
int y = arg.Allocation.Y + (arg.Allocation.Height - arg.CurrentPixbuf.Height) / 2;
Gdk.CairoHelper.SetSourcePixbuf (context, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
context.Paint ();
progress_bar_x += arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
progress_bar_width -= arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
}
int center = arg.Allocation.Y + arg.Allocation.Height / 2;
Gdk.Rectangle progressArea = new Gdk.Rectangle (progress_bar_x, center - Styles.ProgressBarHeight / 2, progress_bar_width, Styles.ProgressBarHeight);
if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0) {
DrawProgressBar (context, arg.ProgressBarFraction, progressArea, arg);
ClipProgressBar (context, progressArea);
}
int text_x = progress_bar_x + Styles.ProgressBarInnerPadding;
int text_width = progress_bar_width - (Styles.ProgressBarInnerPadding * 2);
double textTweenValue = arg.TextAnimationProgress;
if (arg.LastText != null) {
double opacity = Math.Max (0.0f, 1.0f - textTweenValue);
DrawString (arg.LastText, arg.LastTextIsMarkup, context, text_x,
center - (int)(textTweenValue * arg.Allocation.Height * 0.3), text_width, opacity, arg.Pango, arg);
}
if (arg.CurrentText != null) {
DrawString (arg.CurrentText, arg.CurrentTextIsMarkup, context, text_x,
center + (int)((1.0f - textTweenValue) * arg.Allocation.Height * 0.3), text_width, Math.Min (textTweenValue, 1.0), arg.Pango, arg);
}
if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
context.ResetClip ();
}
示例10: paintTrail
protected void paintTrail(Cairo.Context context, int x, int y)
{
context.Save ();
context.SetSourceRGB (0, 1, 0);
context.Translate (x, y);
context.Rectangle (new Cairo.Rectangle (0, 0, fieldSize, fieldSize));
context.SetSourceRGBA (0, 1, 0, 0.3);
context.FillPreserve ();
context.NewPath ();
context.Restore ();
}
示例11: DrawSerie
void DrawSerie(Cairo.Context ctx, Serie serie)
{
ctx.NewPath ();
ctx.Rectangle (left, top, width + 1, height + 1);
ctx.Clip ();
ctx.NewPath ();
ctx.SetSourceColor (serie.Color);
ctx.LineWidth = serie.LineWidth;
bool first = true;
bool blockMode = serie.DisplayMode == DisplayMode.BlockLine;
double lastY = 0;
foreach (Data d in serie.GetData (startX, endX)) {
double x, y;
GetPoint (d.X, d.Y, out x, out y);
if (first) {
ctx.MoveTo (x, y);
lastY = y;
first = false;
} else {
if (blockMode) {
if (lastY != y)
ctx.LineTo (x, lastY);
ctx.LineTo (x, y);
} else
ctx.LineTo (x, y);
}
lastY = y;
}
ctx.Stroke ();
}
示例12: DrawExpander
void DrawExpander (Cairo.Context ctx, double ex, double ey, bool expanded, bool hilight)
{
ctx.NewPath ();
ctx.LineWidth = 1;
ctx.Rectangle (ex, ey, ExpanderSize, ExpanderSize);
if (hilight)
ctx.SetSourceColor (Style.Background (Gtk.StateType.Normal).ToCairoColor ());
else
ctx.SetSourceColor (Style.White.ToCairoColor ());
ctx.FillPreserve ();
ctx.SetSourceColor (Style.Foreground (Gtk.StateType.Normal).ToCairoColor ());
ctx.Stroke ();
ctx.NewPath ();
ctx.MoveTo (ex + 2, ey + (ExpanderSize/2));
ctx.RelLineTo (ExpanderSize - 4, 0);
if (!expanded) {
ctx.MoveTo (ex + (ExpanderSize/2), ey + 2);
ctx.RelLineTo (0, ExpanderSize - 4);
}
ctx.Stroke ();
}
示例13: paintWanderer
protected void paintWanderer(Cairo.Context context, Monster monster)
{
context.Save ();
context.Translate (monster.X + fieldSize / 2, monster.Y + fieldSize / 2);
for (int i = 0; i < 12; i++) {
context.LineTo ((fieldSize / 2) * Math.Cos (i * Math.PI / 6), (fieldSize / 2) * Math.Sin (i * Math.PI / 6));
context.LineTo ((fieldSize / 3) * Math.Cos (Math.PI / 12 + i * Math.PI / 6), (fieldSize / 3) * Math.Sin (Math.PI / 12 + i * Math.PI / 6));
}
context.ClosePath ();
context.FillPreserve ();
context.NewPath ();
context.Restore ();
}
示例14: paintSniffer
protected void paintSniffer(Cairo.Context context, Monster monster)
{
context.Save ();
context.Translate (monster.X, monster.Y);
rotateContext (context, monster.Direction);
context.Arc (fieldSize / 2, fieldSize / 2, fieldSize / 3, 0, 2 * Math.PI);
context.FillPreserve ();
context.MoveTo (0, 0);
context.LineTo (fieldSize, fieldSize);
context.Stroke ();
context.NewPath ();
context.MoveTo (fieldSize, 0);
context.LineTo (0, fieldSize);
context.Stroke ();
context.NewPath ();
context.MoveTo (0, fieldSize / 2);
context.LineTo (fieldSize, fieldSize / 2);
context.Stroke ();
context.NewPath ();
context.Restore ();
}
示例15: OnExposed
protected override bool OnExposed(Cairo.Context cr, Cairo.Rectangle area)
{
Rectangle rectT = new Rectangle(0.0, 0.0, Allocation.Width, EdgeSize);
Rectangle rectB = new Rectangle(0.0, Allocation.Height - EdgeSize, Allocation.Width, EdgeSize);
Rectangle rectL = new Rectangle(0.0, 0.0, EdgeSize, Allocation.Height);
Rectangle rectR = new Rectangle(Allocation.Width - EdgeSize, 0.0, EdgeSize, Allocation.Height);
Rectangle areaT = Widget.Intersect(area, rectT);
Rectangle areaB = Widget.Intersect(area, rectB);
Rectangle areaL = Widget.Intersect(area, rectL);
Rectangle areaR = Widget.Intersect(area, rectR);
if(areaT.Width != 0.0 && areaT.Height != 0.0)
{
LinearGradient grT = new LinearGradient(0.0, 0.0, 0.0, EdgeSize);
grT.AddColorStop(0.0, new Color(1.0, 1.0, 1.0, 1.0));
grT.AddColorStop(1.0, new Color(1.0, 1.0, 1.0, 0.0));
cr.Save();
cr.Pattern = grT;
//cr.Rectangle(areaT);
cr.NewPath();
cr.MoveTo(0.0, 0.0);
cr.LineTo(Allocation.Width, 0.0);
cr.LineTo(Allocation.Width - EdgeSize, EdgeSize);
cr.LineTo(EdgeSize, EdgeSize);
cr.ClosePath();
cr.Clip();
cr.Paint();
cr.Restore();
}
if(areaB.Width != 0.0 && areaB.Height != 0.0)
{
LinearGradient grB = new LinearGradient(0.0, Allocation.Height, 0.0, Allocation.Height - EdgeSize);
grB.AddColorStop(0.0, new Color(0.0, 0.0, 0.0, 1.0));
grB.AddColorStop(1.0, new Color(0.0, 0.0, 0.0, 0.0));
cr.Save();
cr.Pattern = grB;
//cr.Rectangle(areaB);
cr.MoveTo(0.0, Allocation.Height);
cr.LineTo(Allocation.Width, Allocation.Height);
cr.LineTo(Allocation.Width - EdgeSize, Allocation.Height - EdgeSize);
cr.LineTo(EdgeSize, Allocation.Height - EdgeSize);
cr.ClosePath();
cr.Clip();
cr.Paint();
cr.Restore();
}
if(areaL.Width != 0.0 && areaL.Height != 0.0)
{
LinearGradient grL = new LinearGradient(0.0, 0.0, EdgeSize, 0.0);
grL.AddColorStop(0.0, new Color(1.0, 1.0, 1.0, 1.0));
grL.AddColorStop(1.0, new Color(1.0, 1.0, 1.0, 0.0));
cr.Save();
cr.Pattern = grL;
//cr.Rectangle(areaL);
cr.MoveTo(0.0, 0.0);
cr.LineTo(0.0, Allocation.Height);
cr.LineTo(EdgeSize, Allocation.Height - EdgeSize);
cr.LineTo(EdgeSize, EdgeSize);
cr.ClosePath();
cr.Clip();
cr.Paint();
cr.Restore();
}
if(areaR.Width != 0.0 && areaR.Height != 0.0)
{
LinearGradient grR = new LinearGradient(Allocation.Width, 0.0, Allocation.Width - EdgeSize, 0.0);
grR.AddColorStop(0.0, new Color(0.0, 0.0, 0.0, 1.0));
grR.AddColorStop(1.0, new Color(0.0, 0.0, 0.0, 0.0));
cr.Save();
cr.Pattern = grR;
//cr.Rectangle(areaR);
cr.MoveTo(Allocation.Width, 0.0);
cr.LineTo(Allocation.Width, Allocation.Height);
cr.LineTo(Allocation.Width - EdgeSize, Allocation.Height - EdgeSize);
cr.LineTo(Allocation.Width - EdgeSize, EdgeSize);
cr.ClosePath();
cr.Clip();
cr.Paint();
cr.Restore();
}
return true;
}