本文整理汇总了C#中Cairo.Context.Restore方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Restore方法的具体用法?C# Context.Restore怎么用?C# Context.Restore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.Restore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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 ();
}
示例3: 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);
}
示例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: 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);
}
示例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: Draw
protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
{
cr.Color = 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 ();
}
}
示例8: 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();
}
示例9: 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 ();
}
示例10: 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 ();
}
示例11: DrawBackground
protected override void DrawBackground (Context context, Gdk.Rectangle region)
{
LayoutRoundedRectangle (context, region);
context.Clip ();
context.SetSourceColor (CairoExtensions.ParseColor ("D3E6FF"));
context.Paint ();
context.Save ();
context.Translate (region.X + region.Width / 2.0, region.Y + region.Height);
using (var rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
var color = CairoExtensions.ParseColor ("E5F0FF");
rg.AddColorStop (0, color);
color.A = 0;
rg.AddColorStop (1, color);
context.Scale (region.Width / (double)region.Height, 1.0);
context.SetSource (rg);
context.Paint ();
}
context.Restore ();
LayoutRoundedRectangle (context, region, -3, -3, 2);
context.SetSourceRGBA (1, 1, 1, 0.4);
context.LineWidth = 1;
context.StrokePreserve ();
context.Clip ();
int boxSize = 11;
int x = region.Left + (region.Width % boxSize) / 2;
for (; x < region.Right; x += boxSize) {
context.MoveTo (x + 0.5, region.Top);
context.LineTo (x + 0.5, region.Bottom);
}
int y = region.Top + (region.Height % boxSize) / 2;
y += boxSize / 2;
for (; y < region.Bottom; y += boxSize) {
context.MoveTo (region.Left, y + 0.5);
context.LineTo (region.Right, y + 0.5);
}
context.SetSourceRGBA (1, 1, 1, 0.2);
context.Stroke ();
context.ResetClip ();
}
示例12: Draw
protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
{
cr.SetSourceColor (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 ();
}
}
示例13: 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 ();
}
示例14: 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 ();
}
示例15: 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 ();
}