本文整理汇总了C#中Cairo.Context.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Save方法的具体用法?C# Context.Save怎么用?C# Context.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Context context)
{
SetupLayout(context);
RectangleD displayBox = DisplayBox;
displayBox.OffsetDot5();
double side = 10.0;
context.LineWidth = LineWidth;
context.Save ();
//Box
context.MoveTo (displayBox.X, displayBox.Y);
context.LineTo (displayBox.X, displayBox.Y + displayBox.Height);
context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + displayBox.Height);
context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + side);
context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y);
context.LineTo (displayBox.X, displayBox.Y);
context.Save ();
//Triangle
context.MoveTo (displayBox.X + displayBox.Width - side, displayBox.Y);
context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y + side);
context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + side);
context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y);
context.Restore ();
context.Color = FillColor;
context.FillPreserve ();
context.Color = LineColor;
context.Stroke ();
DrawText (context);
}
示例2: Draw
protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
{
cr.Color = new Color (0, 0, 0);
if (prev != null) {
double scale = Math.Min ((double)width/(double)prev.Width, (double)height/(double)prev.Height);
cr.Save ();
cr.Translate (-progress * width, 0);
cr.Rectangle (0, 0, width, .5 * (height - scale*prev.Height));
cr.Fill ();
cr.Rectangle (0, height - .5 * (height - scale*prev.Height), width, .5 * (height - scale*prev.Height));
cr.Fill ();
cr.Rectangle (0, 0, .5 * (width - scale*prev.Width), height);
cr.Fill ();
cr.Rectangle (width - .5 * (width - scale*prev.Width), 0, .5 * (width - scale*prev.Width), height);
cr.Fill ();
cr.Rectangle (0, 0, width, height);
cr.Scale (scale, scale);
CairoHelper.SetSourcePixbuf (cr, prev, .5 * ((double)width/scale - prev.Width), .5 * ((double)height/scale - prev.Height));
cr.Fill ();
cr.Restore ();
}
if (next != null) {
double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
cr.Save ();
cr.Translate (width * (1.0 - progress), 0);
cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
cr.Fill ();
cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
cr.Fill ();
cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
cr.Fill ();
cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
cr.Fill ();
cr.Rectangle (0, 0, width, height);
cr.Scale (scale, scale);
CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
cr.Fill ();
cr.Restore ();
}
}
示例3: Draw
protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
{
cr.SetSourceColor (new Color (0, 0, 0, progress));
if (next != null) {
double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
cr.Save ();
cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
cr.Fill ();
cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
cr.Fill ();
cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
cr.Fill ();
cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
cr.Fill ();
cr.Rectangle (0, 0, width, height);
cr.Scale (scale, scale);
CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
cr.PaintWithAlpha (progress);
cr.Restore ();
}
}
示例4: DrawObject
public void DrawObject(Context ctx, DrawingObject body)
{
if (body == null)
return;
ctx.Save ();
ctx.Color = new Cairo.Color (0, 0, 0);
ctx.LineWidth = 1;
foreach (Tuple<PointDouble, PointDouble> line in body.lines) {
ctx.MoveTo (line.Item1.toPointD());
ctx.LineTo (line.Item2.toPointD());
}
if (body.points.Count > 1)
ctx.Rectangle(body._centerOfMass.X - 5, body._centerOfMass.Y - 5, 10, 10);
ctx.Stroke ();
foreach (PointDouble point in body.points) {
ctx.Rectangle (point.X - 5, point.Y - 5, 10, 10);
ctx.Fill ();
}
foreach (Tuple<PointDouble, double, double> force in body._forces) {
DrawForce (ctx, force);
}
foreach (Tuple<PointDouble, double> moment in body._moments) {
DrawMoment (ctx, moment);
}
ctx.Restore ();
}
示例5: Draw
void Draw(Context cr, int width, int height)
{
cr.LineWidth = 1.0;
cr.Color = new Color(1.0, 1.0, 1.0);
cr.Rectangle(0, 0, width, height);
cr.Fill();
cr.Save();
cr.Scale(scale_factor, scale_factor);
try
{
if(diagram != null)
{
DiagramRenderer dr = new DiagramRenderer(cr, width, height, diagram);
cr.Color = new Color(0.0, 0.0, 0.0);
dr.Render();
dr.Draw();
}
}
catch
{
error_counter++;
}
cr.Restore();
}
示例6: Run
public override void Run()
{
ICollection<double> chapters = this.Theory.Chapters;
StripCanvasSize scs = this.Manager.GenerateStripCanvasSize (chapters.Count);
double dw = scs.CanvasSize.Width;
double dh = scs.CanvasSize.Height;
using (PdfSurface surface = new PdfSurface (this.Manager.OutputFile, scs.TotalWidth, scs.TotalHeight)) {
using (Context ctx = new Context (surface)) {
int index = 0x00;
IPoint3 p;
foreach (double chapter in chapters) {
p = scs.GetCanvasOffset (index);
ctx.Save ();
ctx.Translate (p.X, p.Y);
ctx.Rectangle (0.0d, 0.0d, dw, dh);
ctx.Stroke ();
this.Theory.Time = chapter;
CairoEngine engine = new CairoEngine (this.Theory);
engine.Context = ctx;
engine.Process ();
ctx.Restore ();
index++;
}
}
}
}
示例7: OnTransformIp
protected override FlowReturn OnTransformIp (Gst.Buffer buf) {
if (!buf.IsWritable)
return FlowReturn.Error;
Cairo.ImageSurface img = new Cairo.ImageSurface (buf.Data, Cairo.Format.Rgb24, width, height, width*4);
using (Cairo.Context context = new Cairo.Context (img)) {
double dx = (double) ( (buf.Timestamp / Clock.MSecond) % 2180) / 5;
context.Save ();
context.Scale (width / 640.0, height / 480.0);
context.MoveTo (300, 10 + dx);
context.LineTo (500 - dx, 400);
context.LineWidth = 4.0;
context.Color = new Color (0, 0, 1.0);
context.Stroke();
context.Restore ();
if (lastX != -1 && lastY != -1) {
context.Color = new Color (1.0, 0, 0);
context.Translate (lastX, lastY);
context.Scale (Math.Min (width / 640.0, height / 480.0), Math.Min (width / 640.0, height / 480.0));
context.Arc (0, 0, 10.0, 0.0, 2 * Math.PI);
context.Fill();
}
}
img.Destroy ();
return base.OnTransformIp (buf);
}
示例8: FillChecks
void FillChecks (Context cr, int x, int y, int width, int height)
{
int CHECK_SIZE = 32;
cr.Save ();
Surface check = cr.Target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
// draw the check
using (Context cr2 = new Context (check)) {
cr2.Operator = Operator.Source;
cr2.Color = new Color (0.4, 0.4, 0.4);
cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
cr2.Fill ();
cr2.Color = new Color (0.7, 0.7, 0.7);
cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE);
cr2.Fill ();
cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
cr2.Fill ();
}
// Fill the whole surface with the check
SurfacePattern check_pattern = new SurfacePattern (check);
check_pattern.Extend = Extend.Repeat;
cr.Source = check_pattern;
cr.Rectangle (0, 0, width, height);
cr.Fill ();
check_pattern.Destroy ();
check.Destroy ();
cr.Restore ();
}
示例9: OnRender
protected void OnRender(Context cr, int width, int height)
{
cr.Save();
cr.SetSourceRGBA(1, 0, 0, mTick*0.1);
cr.Rectangle(0, 0, width, height);
cr.Fill();
cr.Restore();
}
示例10: Draw
public virtual void Draw (Context context, IDrawingView view) {
RectangleD rect = ViewDisplayBox(view);
context.Save();
context.LineWidth = LineWidth;
context.Rectangle (GdkCairoHelper.CairoRectangle (rect));
context.Color = FillColor;
context.FillPreserve ();
context.Color = LineColor;
context.Stroke ();
context.Restore();
}
示例11: Render
public virtual void Render (Context cr, Gdk.Rectangle area, Color color, bool showEmptyStars, bool isHovering,
int hoverValue, double fillOpacity, double hoverFillOpacity, double strokeOpacity)
{
if (Value == MinRating && !isHovering && !showEmptyStars) {
return;
}
cr.Save ();
Cairo.Color fill_color = color;
fill_color.A = fillOpacity;
Cairo.Color stroke_color = fill_color;
stroke_color.A = strokeOpacity;
Cairo.Color hover_fill_color = fill_color;
hover_fill_color.A = hoverFillOpacity;
double x, y;
ComputePosition (area, out x, out y);
cr.LineWidth = 1.0;
cr.Translate (0.5, 0.5);
for (int i = MinRating + 1, s = isHovering || showEmptyStars ? MaxRating : Value; i <= s; i++, x += Size) {
bool fill = i <= Value && Value > MinRating;
bool hover_fill = i <= hoverValue && hoverValue > MinRating;
double scale = fill || hover_fill ? Size : Size - 2;
double ofs = fill || hover_fill ? 0 : 1;
for (int p = 0, n = star_plot.GetLength (0); p < n; p++) {
double px = x + ofs + star_plot[p, 0] * scale;
double py = y + ofs + star_plot[p, 1] * scale;
if (p == 0) {
cr.MoveTo (px, py);
} else {
cr.LineTo (px, py);
}
}
cr.ClosePath ();
if (fill || hover_fill) {
if (!isHovering || hoverValue >= Value) {
cr.Color = fill ? fill_color : hover_fill_color;
} else {
cr.Color = hover_fill ? fill_color : hover_fill_color;
}
cr.Fill ();
} else {
cr.Color = stroke_color;
cr.Stroke ();
}
}
cr.Restore ();
}
示例12: BasicDrawSelected
public void BasicDrawSelected(Context context, PointD anchor)
{
BasicDrawSelected(context);
context.Save();
context.Color = new Color(1.0, 0.2, 0.2);
context.SetDash(Dash.DotDash, 0.0);
context.MoveTo(anchor);
context.LineTo(HandlePosition());
context.Stroke();
context.Restore();
}
示例13: Clear
/// <summary>
/// Erase the handle that was drawn in a previous call to Render ().
/// </summary>
public void Clear (Context g)
{
g.Save ();
var rect = GetHandleRect ().Inflate (2, 2);
using (var path = g.CreateRectanglePath (rect))
g.AppendPath (path);
g.Operator = Operator.Clear;
g.Fill ();
g.Restore ();
}
示例14: Render
public static void Render (Context cr, Rectangle box,
double xalign, double yalign, Color innerColor, Color outerColor)
{
// virtual size of the figure we will draw below on the 1:1 scale
double original_width = 8;
double original_height = 12;
// figure out the scale dimensions of the bounding box and the glyph
double box_size = Math.Min (box.Width, box.Height);
double original_size = Math.Max (original_width, original_height);
// create a scale for the box (ratio between virtual glyph size and the box),
// then re-scale to account for the extra size that will be added via stroke.
// glyph_scale is the stroke width and the actual transformation size
double box_scale = box_size / original_size;
double glyph_scale = Math.Floor ((box_size - box_scale) / original_size);
// compute the alignment to the pixel grid for the stroke/scale
double pixel_align = Math.Floor (glyph_scale + 0.5) / 2.0;
// figure out the actual size in pixels of the glyph
double actual_width = glyph_scale * original_width + 2 * Math.Floor (pixel_align);
double actual_height = glyph_scale * original_height + 2 * Math.Floor (pixel_align);
// compute the offset accounting for box, grid alignment, and figure alignment
double tx = box.X + pixel_align + Math.Round ((box.Width - actual_width) * xalign);
double ty = box.Y + pixel_align + Math.Round ((box.Height - actual_height) * yalign);
// save the context, and transform the current/new context
cr.Save ();
cr.Translate (tx, ty);
cr.Scale (glyph_scale, glyph_scale);
// define how the strokes look
cr.LineWidth = 1;
cr.LineCap = LineCap.Round;
cr.LineJoin = LineJoin.Round;
// inner 'b' note
cr.Color = innerColor;
cr.MoveTo (0, 2);
cr.LineTo (2, 0);
cr.Arc (4, 8, 2, Math.PI, Math.PI * 3);
cr.Stroke ();
// outer 'cut' circle
cr.Color = outerColor;
cr.Arc (4, 8, 4, Math.PI * 1.5, Math.PI * 1.12);
cr.Stroke ();
cr.Restore ();
}
示例15: 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 ();
}