本文整理汇总了C#中Cairo.Context.FillPreserve方法的典型用法代码示例。如果您正苦于以下问题:C# Context.FillPreserve方法的具体用法?C# Context.FillPreserve怎么用?C# Context.FillPreserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.FillPreserve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Context context)
{
RectangleD rect = DisplayBox;
context.LineWidth = LineWidth;
context.Rectangle (GdkCairoHelper.CairoRectangle (rect));
context.Color = FillColor;
context.FillPreserve ();
context.Color = LineColor;
context.Stroke ();
}
示例2: BasicDraw
public override void BasicDraw (Context context) {
RectangleD displayBox = DisplayBox;
context.LineWidth = LineWidth;
context.Save ();
displayBox.OffsetDot5 ();
context.Rectangle (GdkCairoHelper.CairoRectangle(displayBox));
context.Restore ();
context.Color = FillColor;
context.FillPreserve ();
context.Color = LineColor;
context.Stroke ();
}
示例3: Draw
public override void Draw(Context context)
{
double middle = DisplayBox.Width / 2.0;
context.LineWidth = LineWidth;
context.Save ();
context.Translate (DisplayBox.X + middle, DisplayBox.Y + middle);
context.Arc (0.0, 0.0, middle, 0.0, 2.0 * Math.PI);
context.Restore ();
context.Color = new Cairo.Color (1.0, 1.0, 0.2, 0.2);
context.FillPreserve ();
context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
context.Stroke ();
}
示例4: Draw
public override void Draw (Context context, IDrawingView view) {
RectangleD rect = ViewDisplayBox(view);
double middle = rect.Width / 2.0;
context.LineWidth = LineWidth;
context.Save ();
context.Translate (rect.X + middle, rect.Y + middle);
context.Arc (0.0, 0.0, middle, 0.0, 2.0 * Math.PI);
context.Restore ();
context.Color = new Cairo.Color (0.2, 0.2, 1.0, 0.5);
context.FillPreserve ();
context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
context.Stroke ();
}
示例5: BasicDraw
public override void BasicDraw (Context context) {
double midwidth = DisplayBox.Width / 2.0;
double midheight = DisplayBox.Height / 2.0;
context.LineWidth = LineWidth;
context.Save ();
context.Translate (DisplayBox.X + midwidth, DisplayBox.Y + midheight);
context.Scale (midwidth - 1.0, midheight - 1.0);
context.Arc (0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI);
context.Restore ();
context.Color = FillColor;
context.FillPreserve ();
context.Color = LineColor;
context.Stroke ();
}
示例6: Draw
public override void Draw (Context context, IDrawingView view) {
RectangleD rect = ViewDisplayBox(view);
context.LineWidth = LineWidth;
context.MoveTo (rect.Center.X, rect.Top);
context.LineTo (rect.Right, rect.Center.Y);
context.LineTo (rect.Center.X, rect.Bottom);
context.LineTo (rect.Left, rect.Center.Y);
context.LineTo (rect.Center.X, rect.Top);
context.Color = new Cairo.Color (1.0, 0.0, 0.0, 0.8);
context.FillPreserve ();
context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
context.Stroke ();
}
示例7: Render
public override void Render(Node node, Context context)
{
ButtonNode button = node as ButtonNode;
context.RoundedRectangle (0.5, 0.5, button.Width - 1, button.Height - 1, button.Rounding);
if (button.Relief) {
using (var lg = new global::Cairo.LinearGradient (0, 0, 0, button.Height)) {
CreateGradient (lg, button.State, button.Opacity);
context.Pattern = lg;
context.FillPreserve ();
}
context.LineWidth = 1;
context.Color = new Color (0.8, 0.8, 0.8, button.Opacity).ToCairo ();
context.Stroke ();
}
}
示例8: curve_rectangle
public void curve_rectangle(Context cr, int width, int height)
{
// a custom shape, that could be wrapped in a function
double x0 = 0.1, //< parameters like cairo_rectangle
y0 = 0.1,
rect_width = 0.8,
rect_height = 0.8,
radius = 0.4; //< and an approximate curvature radius
double x1,y1;
Normalize(cr, width, height);
x1=x0+rect_width;
y1=y0+rect_height;
if (rect_width/2<radius) {
if (rect_height/2<radius) {
cr.MoveTo(x0, (y0 + y1)/2);
cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
} else {
cr.MoveTo(x0, y0 + radius);
cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
cr.LineTo(x1 , y1 - radius);
cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
}
} else {
if (rect_height/2<radius) {
cr.MoveTo(x0, (y0 + y1)/2);
cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
cr.LineTo(x1 - radius, y0);
cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
cr.LineTo(x0 + radius, y1);
cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
} else {
cr.MoveTo(x0, y0 + radius);
cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
cr.LineTo(x1 - radius, y0);
cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
cr.LineTo(x1 , y1 - radius);
cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
cr.LineTo(x0 + radius, y1);
cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
}
}
cr.ClosePath();
// and fill/stroke it
cr.Color = new Color (0.5, 0.5, 1);
cr.FillPreserve();
cr.Color = new Color (0.5, 0, 0, 0.5);
cr.Stroke();
}
示例9: fill_and_stroke2
public void fill_and_stroke2(Context cr, int width, int height)
{
Normalize (cr, width, height);
cr.MoveTo(0.5, 0.1);
cr.LineTo(0.9, 0.9);
cr.RelLineTo(-0.4, 0.0);
cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
cr.ClosePath();
cr.MoveTo(0.25, 0.1);
cr.RelLineTo(0.2, 0.2);
cr.RelLineTo(-0.2, 0.2);
cr.RelLineTo(-0.2, -0.2);
cr.ClosePath();
cr.Color = new Color (0, 0, 1);
cr.FillPreserve();
cr.Color = new Color (0, 0, 0);
cr.Stroke();
}
示例10: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
Document doc = PintaCore.Workspace.ActiveDocument;
if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask) {
outline_color = PintaCore.Palette.PrimaryColor;
fill_color = PintaCore.Palette.SecondaryColor;
} else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask) {
outline_color = PintaCore.Palette.SecondaryColor;
fill_color = PintaCore.Palette.PrimaryColor;
} else {
last_point = point_empty;
return;
}
int x = (int)point.X;
int y = (int)point.Y;
if (last_point.Equals (point_empty)) {
last_point = new Point (x, y);
return;
}
if (doc.Workspace.PointInCanvas (point))
surface_modified = true;
doc.ToolLayer.Clear ();
ImageSurface surf = doc.ToolLayer.Surface;
using (Context g = new Context (surf)) {
doc.Selection.Clip(g);
g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
} else {
g.MoveTo (x, y);
}
g.LineTo (x, y);
path = g.CopyPath ();
g.ClosePath ();
g.LineWidth = BrushWidth;
g.LineJoin = LineJoin.Round;
g.LineCap = LineCap.Round;
g.FillRule = FillRule.EvenOdd;
if (FillShape && StrokeShape) {
g.Color = fill_color;
g.FillPreserve ();
g.Color = outline_color;
g.Stroke ();
} else if (FillShape) {
g.Color = outline_color;
g.Fill ();
} else {
g.Color = outline_color;
g.Stroke ();
}
}
doc.Workspace.Invalidate ();
last_point = new Point (x, y);
}
示例11: OnMouseUp
protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
{
Document doc = PintaCore.Workspace.ActiveDocument;
doc.ToolLayer.Hidden = true;
if (surface_modified)
PintaCore.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, doc.CurrentUserLayerIndex));
else if (undo_surface != null)
(undo_surface as IDisposable).Dispose ();
surface_modified = false;
ImageSurface surf = doc.CurrentUserLayer.Surface;
using (Context g = new Context (surf)) {
g.AppendPath (doc.Selection.SelectionPath);
g.FillRule = FillRule.EvenOdd;
g.Clip ();
g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
path = null;
}
g.ClosePath ();
g.LineWidth = BrushWidth;
g.LineJoin = LineJoin.Round;
g.LineCap = LineCap.Round;
g.FillRule = FillRule.EvenOdd;
if (FillShape && StrokeShape) {
g.Color = fill_color;
g.FillPreserve ();
g.Color = outline_color;
g.Stroke ();
} else if (FillShape) {
g.Color = outline_color;
g.Fill ();
} else {
g.Color = outline_color;
g.Stroke ();
}
}
doc.Workspace.Invalidate ();
}
示例12: DrawBackground
public override void DrawBackground (Mono.TextEditor.MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
int markerStart = usage.Offset;
int markerEnd = usage.EndOffset;
if (markerEnd < startOffset || markerStart > endOffset)
return;
double @from;
double to;
var startXPos = metrics.TextRenderStartPosition;
var endXPos = metrics.TextRenderEndPosition;
var y = metrics.LineYRenderStartPosition;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
uint curIndex = 0, byteIndex = 0;
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = Math.Max (@from, editor.TextViewMargin.XOffset);
to = Math.Max (to, editor.TextViewMargin.XOffset);
if (@from < to) {
Mono.TextEditor.Highlighting.AmbientColor colorStyle;
if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write ||
(usage.UsageType & ReferenceUsageType.Declariton) == ReferenceUsageType.Declariton) {
colorStyle = editor.ColorStyle.ChangingUsagesRectangle;
} else {
colorStyle = editor.ColorStyle.UsagesRectangle;
}
using (var lg = new LinearGradient (@from + 1, y + 1, to , y + editor.LineHeight)) {
lg.AddColorStop (0, colorStyle.Color);
lg.AddColorStop (1, colorStyle.SecondColor);
cr.SetSource (lg);
cr.RoundedRectangle (@from + 0.5, y + 1.5, to - @from - 1, editor.LineHeight - 2, editor.LineHeight / 4);
cr.FillPreserve ();
}
cr.SetSourceColor (colorStyle.BorderColor);
cr.Stroke ();
}
}
示例13: DrawRibbon
/// <summary>Draws a ribbon.</summary>
public void DrawRibbon (Context cr, Gdk.Rectangle bodyAllocation, double roundSize, double lineWidth, Ribbon widget)
{
double lineWidth05 = lineWidth / 2;
double lineWidth15 = 3 * lineWidth05;
double x0, x1, y0, y1;
LinearGradient linGrad;
Ribbon.RibbonPage p = widget.CurrentPage;
if(p != null)
{
//Color c = ColorScheme.GetColor(colorScheme.Bright, 0.92);
Color c = colorScheme.Normal;
if(bodyAllocation.Height > 0)
{
/*** PAGE ***/
x0 = bodyAllocation.X; x1 = bodyAllocation.X + bodyAllocation.Width;
y0 = bodyAllocation.Y; y1 = bodyAllocation.Y + bodyAllocation.Height;
cr.Arc (x0 + roundSize, y1 - roundSize, roundSize - lineWidth05, Math.PI/2, Math.PI);
cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0);
cr.Arc (x1 - roundSize, y1 - roundSize, roundSize - lineWidth05, 0, Math.PI/2);
cr.LineTo (x0 + roundSize, y1 - lineWidth05);
/*** BACKGOUND ***/
cr.Color = c;
cr.FillPreserve ();
/*** DARK BORDER ***/
cr.LineWidth = lineWidth;
cr.Color = ColorScheme.GetColorAbsolute (colorScheme.Normal, 0.75);
cr.Stroke ();
/*** GLASS EFFECT ***/
double ymid = Math.Round(y0 + (y1 - y0) * 0.25);
cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth, Math.PI, 3*Math.PI/2);
cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth, 3*Math.PI/2, 0);
cr.LineTo (x1 - lineWidth, ymid);
cr.LineTo (x0 + lineWidth, ymid);
cr.LineTo (x0 + lineWidth, y0 + roundSize);
linGrad = new LinearGradient (0, y0, 0, ymid);
linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0));
linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.075));
cr.Pattern = linGrad;
cr.Fill ();
cr.Arc (x0 + roundSize, y1 - roundSize, roundSize - lineWidth, Math.PI/2, Math.PI);
cr.LineTo (x0 + lineWidth, ymid);
cr.LineTo (x1 - lineWidth, ymid);
cr.Arc (x1 - roundSize, y1 - roundSize, roundSize - lineWidth, 0, Math.PI/2);
cr.LineTo (x0 + roundSize, y1 - lineWidth);
linGrad = new LinearGradient (0, ymid, 0, y1);
linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.1));
linGrad.AddColorStop (0.5, new Color (0, 0, 0, 0.0));
cr.Pattern = linGrad;
cr.Fill ();
}
/*** TAB ***/
Gdk.Rectangle r = p.LabelAllocation;
x0 = r.X; x1 = r.X + r.Width;
y0 = r.Y; y1 = r.Y + r.Height + lineWidth;
/*** TAB :: BACKGROUND ***/
cr.MoveTo (x0 + lineWidth05, y1);
cr.LineTo (x0 + lineWidth05, y0 + roundSize);
cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0);
cr.LineTo (x1 - lineWidth05, y1);
linGrad = new LinearGradient (0, y0, 0, y1);
linGrad.AddColorStop (0.0, colorScheme.PrettyBright);
linGrad.AddColorStop (1.0, c);
cr.Pattern = linGrad;
cr.Fill ();
/*** TAB :: DARK BORDER ***/
cr.MoveTo (x0 + lineWidth05, y1);
cr.LineTo (x0 + lineWidth05, y0 + roundSize);
cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0);
cr.LineTo (x1 - lineWidth05, y1);
cr.LineWidth = lineWidth;
cr.Color = ColorScheme.GetColorRelative (colorScheme.Bright, -0.1);
cr.Stroke ();
y1 -= 1.0;
/*** TAB :: HIGHLIGHT ***/
cr.MoveTo (x0 + lineWidth15, y1);
//.........这里部分代码省略.........
示例14: DrawShape
void DrawShape(Context g, int width, int height)
{
int inner_x = radius + border + inner;
int cx = Center.X;
int cy = Center.Y;
g.Operator = Operator.Source;
g.SetSource (new SolidPattern (new Cairo.Color (0,0,0,0)));
g.Rectangle (0, 0, width, height);
g.Paint ();
g.NewPath ();
g.Translate (cx, cy);
g.Rotate (angle);
g.SetSource (new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6)));
g.Operator = Operator.Over;
g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner));
g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI);
g.Arc (0, 0, radius + border, 0, 2 * Math.PI);
g.Fill ();
g.SetSource (new SolidPattern (new Cairo.Color (0, 0, 0, 1.0)));
g.Operator = Operator.DestOut;
g.Arc (inner_x, 0, inner, 0, 2 * Math.PI);
#if true
g.Fill ();
#else
g.FillPreserve ();
g.Operator = Operator.Over;
RadialGradient rg = new RadialGradient (inner_x - (inner * 0.3), inner * 0.3 , inner * 0.1, inner_x, 0, inner);
rg.AddColorStop (0, new Cairo.Color (0.0, 0.2, .8, 0.5));
rg.AddColorStop (0.7, new Cairo.Color (0.0, 0.2, .8, 0.1));
rg.AddColorStop (1.0, new Cairo.Color (0.0, 0.0, 0.0, 0.0));
g.Source = rg;
g.Fill ();
rg.Destroy ();
#endif
g.Operator = Operator.Over;
g.Matrix = new Matrix ();
g.Translate (cx, cy);
if (source != null)
CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);
g.Arc (0, 0, radius, 0, 2 * Math.PI);
g.Fill ();
if (overlay != null) {
CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
g.Arc (0, 0, radius, angle, angle + Math.PI);
g.ClosePath ();
g.FillPreserve ();
g.SetSource (new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0)));
g.Stroke ();
}
}
示例15: DrawRoundedRect
public void DrawRoundedRect(Context gc, double x, double y, double width,
double height, double radius, double strokeWidth,
Cairo.Color backgroundColor, Cairo.Color strokeColor)
{
gc.Save ();
this.CreateRoundedRectPath (gc, x, y, width, height, radius);
gc.LineWidth = strokeWidth;
gc.Color = backgroundColor;
gc.FillPreserve ();
gc.Color = strokeColor;
gc.Stroke ();
gc.Restore ();
}