本文整理汇总了C#中Cairo.Context.FixedStrokeExtents方法的典型用法代码示例。如果您正苦于以下问题:C# Context.FixedStrokeExtents方法的具体用法?C# Context.FixedStrokeExtents怎么用?C# Context.FixedStrokeExtents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.FixedStrokeExtents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnMouseMove
protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
int x, int y, int lastX, int lastY)
{
// Cairo does not support a single-pixel-long single-pixel-wide line
if (x == lastX && y == lastY && g.LineWidth == 1 &&
PintaCore.Workspace.ActiveWorkspace.PointInCanvas (new PointD(x,y))) {
surface.Flush ();
ColorBgra source = surface.GetColorBgraUnchecked (x, y);
source = UserBlendOps.NormalBlendOp.ApplyStatic (source, strokeColor.ToColorBgra ());
surface.SetColorBgra (source, x, y);
surface.MarkDirty ();
return new Gdk.Rectangle (x - 1, y - 1, 3, 3);
}
g.MoveTo (lastX + 0.5, lastY + 0.5);
g.LineTo (x + 0.5, y + 0.5);
g.StrokePreserve ();
Gdk.Rectangle dirty = g.FixedStrokeExtents ().ToGdkRectangle ();
// For some reason (?!) we need to inflate the dirty
// rectangle for small brush widths in zoomed images
dirty.Inflate (1, 1);
return dirty;
}
示例2: OnMouseMove
protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
int x, int y, int lastX, int lastY)
{
int dx = x - lastX;
int dy = y - lastY;
double px = Math.Cos (theta) * dx - Math.Sin (theta) * dy;
double py = Math.Sin (theta) * dx + Math.Cos (theta) * dy;
g.MoveTo (lastX - px, lastY - py);
g.LineTo (lastX + px, lastY + py);
g.LineTo (x + px, y + py);
g.LineTo (x - px, y - py);
g.LineTo (lastX - px, lastY - py);
g.StrokePreserve ();
return g.FixedStrokeExtents ().ToGdkRectangle ();
}
示例3: OnMouseMove
protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
int x, int y, int lastX, int lastY)
{
int line_width = (int)g.LineWidth;
int size;
// we want a minimum size of 2 for the splatter (except for when the brush width is 1), since a splatter of size 1 is very small
if (line_width == 1)
{
size = 1;
}
else
{
size = Random.Next (2, line_width);
}
Rectangle r = new Rectangle (x - Random.Next (-15, 15), y - Random.Next (-15, 15), size, size);
double rx = r.Width / 2;
double ry = r.Height / 2;
double cx = r.X + rx;
double cy = r.Y + ry;
double c1 = 0.552285;
g.Save ();
g.MoveTo (cx + rx, cy);
g.CurveTo (cx + rx, cy - c1 * ry, cx + c1 * rx, cy - ry, cx, cy - ry);
g.CurveTo (cx - c1 * rx, cy - ry, cx - rx, cy - c1 * ry, cx - rx, cy);
g.CurveTo (cx - rx, cy + c1 * ry, cx - c1 * rx, cy + ry, cx, cy + ry);
g.CurveTo (cx + c1 * rx, cy + ry, cx + rx, cy + c1 * ry, cx + rx, cy);
g.ClosePath ();
Rectangle dirty = g.FixedStrokeExtents ();
g.Fill ();
g.Restore ();
return dirty.ToGdkRectangle ();
}
示例4: GetBounds
public static Gdk.Rectangle GetBounds(this Path path)
{
Rectangle rect;
using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
g.AppendPath (path);
// We don't want the bounding box to include a stroke width
// of 1, but setting it to 0 returns an empty rectangle. Set
// it to a sufficiently small width and rounding takes care of it
g.LineWidth = .01;
rect = g.FixedStrokeExtents ();
}
int x = (int)Math.Round (rect.X);
int y = (int)Math.Round (rect.Y);
int w = (int)Math.Round (rect.Width);
int h = (int)Math.Round (rect.Height);
return new Gdk.Rectangle (x, y, w, h);
}