本文整理汇总了C#中Cairo.Context.GetTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetTarget方法的具体用法?C# Context.GetTarget怎么用?C# Context.GetTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.GetTarget方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public void Render(DrawingArea area, SettingsModel settings)
{
var width = area.Allocation.Width;
var height = area.Allocation.Height;
var kaleidoscope = _factory.Get (settings.Type);
var rootNode = kaleidoscope.Generate (
settings.GeometyWidth,
settings.ImageUri,
width, height);
ImageSurface surface = new ImageSurface(Format.Argb32, width, height);
using (var context = new Context (surface)) {
context.Translate(width / 2, height / 2);
rootNode.Render (context);
}
rootNode.Geometry.Dispose ();
using (Context context = Gdk.CairoHelper.Create (area.GdkWindow)) {
context.Rectangle(0, 0, width, height);
context.SetSource(surface);
context.Fill();
context.GetTarget ().Dispose ();
}
surface.Dispose ();
}
示例2: CreateSurfaceForPixbuf
public static Surface CreateSurfaceForPixbuf (Context cr, Pixbuf pixbuf)
{
Surface surface;
using (var t = cr.GetTarget ()) {
surface = t.CreateSimilar (t.Content, pixbuf.Width, pixbuf.Height);
}
using (Context surface_cr = new Context (surface)) {
CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0, 0);
surface_cr.Paint ();
surface_cr.Dispose ();
}
return surface;
}
示例3: Form1_Shown
private void Form1_Shown(object sender, EventArgs e)
{
Debug.WriteLine("Form1_Shown");
surface = new Win32Surface(this.CreateGraphics().GetHdc());
context = new Context(surface);
textFormat = DWriteCairo.CreateTextFormat(
"Consolas",
FontWeight.Normal,
FontStyle.Normal,
FontStretch.Normal,
12);
textFormat.TextAlignment = TextAlignment.Center;
float left, top, width, height;
// get actual size of the text
var measureLayout = DWriteCairo.CreateTextLayout(s, textFormat, 4096, 4096);
measureLayout.GetRect(out left, out top, out width, out height);
measureLayout.Dispose();
// build text context against the size and format
textLayout = DWriteCairo.CreateTextLayout(s, textFormat, (int)Math.Ceiling(width), (int)Math.Ceiling(height));
Debug.WriteLine("showing layout");
Path path = DWriteCairo.RenderLayoutToCairoPath(context, textLayout);
context.AppendPath(path);
context.Fill();
textLayout.GetRect(out left, out top, out width, out height);
textRect = new System.Drawing.RectangleF(left, top, width, height);
context.Rectangle(left, top, width, height);
context.Stroke();
context.GetTarget().Flush();
}
示例4: FillChecks
void FillChecks (Context cr, int x, int y, int width, int height)
{
int CHECK_SIZE = 32;
cr.Save ();
Surface check;
using (var target = cr.GetTarget ()) {
check = target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
}
// draw the check
using (Context cr2 = new Context (check)) {
cr2.Operator = Operator.Source;
cr2.SetSourceRGB (0.4, 0.4, 0.4);
cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
cr2.Fill ();
cr2.SetSourceRGB (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.SetSource (check_pattern);
cr.Rectangle (0, 0, width, height);
cr.Fill ();
check_pattern.Dispose ();
check.Dispose ();
cr.Restore ();
}
示例5: OnMouseRelease
//Getting end of the would-be line, kept for possible re-use of lines
void OnMouseRelease(object source, ButtonReleaseEventArgs args)
{
End.X = args.Event.X;
End.Y = args.Event.Y;
isDrawing = false;
using (Context ctx = new Context(surface))
{
Painter(ctx, Start, End);
((IDisposable) ctx.GetTarget()).Dispose ();
((IDisposable)ctx).Dispose ();
}
dArea.QueueDraw();
}
示例6: OnMouseMotion
//Updates every time the mouse is moved while button is pressed
void OnMouseMotion(object source, MotionNotifyEventArgs args)
{
if (isDrawing)
{
End.X = args.Event.X;
End.Y = args.Event.Y;
using (Context ctx = new Context (surface)) {
//Reset of end's points so there are no accidental
if (isDot) {
Start.X = args.Event.X;
Start.Y = args.Event.Y;
}
Painter (ctx, Start, End);
((IDisposable) ctx.GetTarget()).Dispose ();
((IDisposable)ctx).Dispose ();
}
dArea.QueueDraw();
}
}
示例7: Draw
void Draw (Context cr, int width, int height)
{
double radius = 0.5 * Math.Min (width, height) - 10;
int xc = width / 2;
int yc = height / 2;
Surface overlay, punch, circles;
using (var target = cr.GetTarget ()) {
overlay = target.CreateSimilar (Content.ColorAlpha, width, height);
punch = target.CreateSimilar (Content.Alpha, width, height);
circles = target.CreateSimilar (Content.ColorAlpha, width, height);
}
FillChecks (cr, 0, 0, width, height);
cr.Save ();
// Draw a black circle on the overlay
using (Context cr_overlay = new Context (overlay)) {
cr_overlay.SetSourceRGB (0.0, 0.0, 0.0);
OvalPath (cr_overlay, xc, yc, radius, radius);
cr_overlay.Fill ();
// Draw 3 circles to the punch surface, then cut
// that out of the main circle in the overlay
using (Context cr_tmp = new Context (punch))
Draw3Circles (cr_tmp, xc, yc, radius, 1.0);
cr_overlay.Operator = Operator.DestOut;
cr_overlay.SetSourceSurface (punch, 0, 0);
cr_overlay.Paint ();
// Now draw the 3 circles in a subgroup again
// at half intensity, and use OperatorAdd to join up
// without seams.
using (Context cr_circles = new Context (circles)) {
cr_circles.Operator = Operator.Over;
Draw3Circles (cr_circles, xc, yc, radius, 0.5);
}
cr_overlay.Operator = Operator.Add;
cr_overlay.SetSourceSurface (circles, 0, 0);
cr_overlay.Paint ();
}
cr.SetSourceSurface (overlay, 0, 0);
cr.Paint ();
overlay.Dispose ();
punch.Dispose ();
circles.Dispose ();
}
示例8: draw
private void draw()
{
if (viewSurface != null)
{
viewSurface.Dispose();
}
viewSurface = new ImageSurface(Format.ARGB32, winWidth, winHeight);
//Context cr = Gdk.CairoHelper.Create(drawArea.GdkWindow);
Context cr = new Context(viewSurface);
clearDrawArea (cr);
Drawer.DrawPoints (points,cr);
foreach (VertexStructure vs in vertexStructs) {
Drawer.DrawVertexStructure (vs,cr);
}
foreach (IGameObject go in gos) {
if (go.needsDrawing ()) {
go.draw (cr);
}
}
((IDisposable) cr.GetTarget()).Dispose();
((IDisposable) cr).Dispose();
using (Context cr2 = Gdk.CairoHelper.Create(drawArea.GdkWindow))
{
cr2.SetSourceSurface(viewSurface, 0, 0);
cr2.Paint();
}
drawArea.QueueDraw ();
}