本文整理汇总了C#中Cairo.PointD类的典型用法代码示例。如果您正苦于以下问题:C# PointD类的具体用法?C# PointD怎么用?C# PointD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PointD类属于Cairo命名空间,在下文中一共展示了PointD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnMouseDown
protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
{
origin_offset = point;
is_dragging = true;
hist = new MovePixelsHistoryItem (Icon, Name);
hist.TakeSnapshot ();
if (!PintaCore.Layers.ShowSelectionLayer) {
// Copy the selection to the temp layer
PintaCore.Layers.CreateSelectionLayer ();
PintaCore.Layers.ShowSelectionLayer = true;
using (Cairo.Context g = new Cairo.Context (PintaCore.Layers.SelectionLayer.Surface)) {
g.AppendPath (PintaCore.Layers.SelectionPath);
g.FillRule = FillRule.EvenOdd;
g.SetSource (PintaCore.Layers.CurrentLayer.Surface);
g.Clip ();
g.Paint ();
}
Cairo.ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;
using (Cairo.Context g = new Cairo.Context (surf)) {
g.AppendPath (PintaCore.Layers.SelectionPath);
g.FillRule = FillRule.EvenOdd;
g.Operator = Cairo.Operator.Clear;
g.Fill ();
}
}
canvas.GdkWindow.Invalidate ();
}
示例2: getSharpestPointAndAssociatedMidpointAndDullestPoints
public Tuple<PointD, PointD, PointD, PointD> getSharpestPointAndAssociatedMidpointAndDullestPoints()
{
if (-1 == sharpestPointIdx) {
sharpestPointIdx = TriangleUtils.GetSharpestPoint (tri);
}
int sharp = sharpestPointIdx;
PointD p;
PointD d1;
PointD d2;
// meh
if (0 == sharp) {
p = tri.a;
d1 = tri.b;
d2 = tri.c;
} else if (1 == sharp) {
p = tri.b;
d1 = tri.a;
d2 = tri.c;
} else {
p = tri.c;
d1 = tri.a;
d2 = tri.b;
}
PointD midPoint = new PointD ((d1.X+d2.X)/2,(d1.Y+d2.Y)/2);
return new Tuple<PointD,PointD,PointD,PointD> (p,midPoint,d1,d2);
}
示例3: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Debug.WriteLine("OnPaint");
//draw something on the back surface
var p1 = new PointD(10, 10);
var p2 = new PointD(100, 10);
var p3 = new PointD(100, 100);
var p4 = new PointD(10, 100);
BackContext.SetSourceColor(new Cairo.Color(1,0,0));
BackContext.MoveTo(p1);
BackContext.LineTo(p2);
BackContext.LineTo(p3);
BackContext.LineTo(p4);
BackContext.LineTo(p1);
BackContext.ClosePath();
BackContext.Stroke();
BackContext.SetSourceColor(new Cairo.Color(0, 1, 0));
BackContext.MoveTo(new PointD(p3.X + 10, p3.Y + 10));
Cairo.Path path = DWriteCairo.RenderLayoutToCairoPath(BackContext, textLayout);
BackContext.AppendPath(path);
path.Dispose();
BackContext.Fill();
//copy back surface to font surface
SwapBuffer();
}
示例4: PreCalc
// In perspective mode, the warping functions are:
// x' = (a0 + a1 x + a2 y) / (c0 x + c1 y + 1)
// y' = (b0 + b1 x + b2 y) / (c0 x + c1 y + 1)
//
// The following calculates the factors a#, b# and c#.
// We do this by creating a set of eight equations with a#, b# and c# as unknowns.
// The equations are derived by:
// 1. substituting the srcPoints for (x, y);
// 2. substituting the corresponding destPoints for (x', y');
// 3. solving the resulting set of equations, with the factors as unknowns.
//
// The equations are like these:
// a0 x a1 y a2 0 0 0 -xx'c0 -yx'c1 = x'
// 0 0 0 b0 x b1 y b2 -xy'c0 -yy'c1 = y'
// The known factors of left hand side ar put in the 8x8 matrix mxLeft for
// all four point pairs, and the right hand side in the one column matrix mxRight.
// After solving, m_mxWarpFactors contains a0, a1, a2, b0, b1, b2, c0, c1.
private void PreCalc(PointD[] destPoints, PointD[] srcPoints)
{
var mxLeft = new GeneralMatrix(8, 8); //mxLeft.Null();
var mxRight = new GeneralMatrix(8, 1);
var row = 0;
for (int i = 0; i < 4; i++)
{
mxLeft.Array[row][0] = 1.0;
mxLeft.Array[row][1] = srcPoints[i].X;
mxLeft.Array[row][2] = srcPoints[i].Y;
mxLeft.Array[row][6] = - srcPoints[i].X * destPoints[i].X;
mxLeft.Array[row][7] = - srcPoints[i].Y * destPoints[i].X;
mxRight.Array[row][0] = destPoints[i].X;
row++;
mxLeft.Array[row][3] = 1.0f;
mxLeft.Array[row][4] = srcPoints[i].X;
mxLeft.Array[row][5] = srcPoints[i].Y;
mxLeft.Array[row][6] = - srcPoints[i].X * destPoints[i].Y;
mxLeft.Array[row][7] = - srcPoints[i].Y * destPoints[i].Y;
mxRight.Array[row][0] = destPoints[i].Y;
row++;
}
_mxWarpFactors = mxLeft.Solve(mxRight);
}
示例5: update
public void update()
{
LineSegment segmentToPlayer = new LineSegment (position,player.getPosition());
bool couldSeePlayerBefore = canSeePlayer;
canSeePlayer = true;
foreach (LineSegment wall in walls) {
if (LineSegment.TestIntersection (segmentToPlayer, wall)) {
canSeePlayer = false;
break;
}
}
if (canSeePlayer) {
target = player.getPosition ();
setStalkSpeed ();
}
if (!canSeePlayer && couldSeePlayerBefore) {
setRandomTarget ();
setWanderSpeed ();
}
PointD vectorDistance = new PointD (target.X - position.X, target.Y - position.Y);
double scalarDistance = Math.Sqrt (Math.Pow(vectorDistance.X,2) + Math.Pow(vectorDistance.Y,2));
if (scalarDistance < tolerance) {
;
} else {
double total = Math.Abs (vectorDistance.X) + Math.Abs (vectorDistance.Y);
position.X += (vectorDistance.X / total) * speed;
position.Y += vectorDistance.Y / total * speed;
}
}
示例6: MouseDrag
public override void MouseDrag (MouseEvent ev) {
DrawSelectionRect ((Gtk.Widget) ev.View, ev.GdkEvent.Window);
PointD anchor = new PointD (AnchorX, AnchorY);
PointD corner = new PointD (ev.X, ev.Y);
_selectionRect = new RectangleD (anchor, corner);
DrawSelectionRect ((Gtk.Widget) ev.View, ev.GdkEvent.Window);
}
示例7: UpdateRectangle
protected void UpdateRectangle (PointD point)
{
if (!is_drawing)
return;
Document doc = PintaCore.Workspace.ActiveDocument;
Rectangle r = PointsToRectangle (shape_origin, point);
Rectangle dirty;
doc.ToolLayer.Clear ();
doc.ToolLayer.Hidden = false;
using (Context g = new Context (doc.ToolLayer.Surface)) {
g.Antialias = Antialias.Subpixel;
dirty = g.FillStrokedRectangle (r, new Color (0, 0.4, 0.8, 0.1), new Color (0, 0, 0.9), 1);
dirty = dirty.Clamp ();
doc.Workspace.Invalidate (last_dirty.ToGdkRectangle ());
doc.Workspace.Invalidate (dirty.ToGdkRectangle ());
last_dirty = dirty;
}
}
示例8: InvalidateRect
public virtual RectangleD InvalidateRect(PointD b)
{
var r = new RectangleD (b.X, b.Y, 0.0, 0.0);
r.Inflate (15.0, 15.0);
return r;
}
示例9: Image_Loaded
private void Image_Loaded(object sender, RoutedEventArgs e)
{
Image image = (Image)sender;
using (ImageSurface surface = new ImageSurface(Format.Argb32, (int)image.Width, (int)image.Height))
{
using (Context context = new Context(surface))
{
PointD p = new PointD(10.0, 10.0);
PointD p2 = new PointD(100.0, 10.0);
PointD p3 = new PointD(100.0, 100.0);
PointD p4 = new PointD(10.0, 100.0);
context.MoveTo(p);
context.LineTo(p2);
context.LineTo(p3);
context.LineTo(p4);
context.LineTo(p);
context.ClosePath();
context.Fill();
context.MoveTo(140.0, 110.0);
context.SetFontSize(32.0);
context.SetSourceColor(new Color(0.0, 0.0, 0.8, 1.0));
context.ShowText("Hello Cairo!");
surface.Flush();
RgbaBitmapSource source = new RgbaBitmapSource(surface.Data, surface.Width);
image.Source = source;
}
}
}
示例10: NodeGroup
public NodeGroup()
{
nodes = ArrayList.Synchronized(new ArrayList());
name = string.Empty;
position = new PointD(0, 0);
dimension = new SizeD(0, 0);
}
示例11: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, PointD point)
{
if (active) {
PintaCore.Workspace.ScrollCanvas ((int)(last_point.X - args.Event.XRoot), (int)(last_point.Y - args.Event.YRoot));
last_point = new PointD (args.Event.XRoot, args.Event.YRoot);
}
}
示例12: OnMouseDown
protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
{
// Ignore extra button clicks while drawing
if (is_drawing)
return;
Document doc = PintaCore.Workspace.ActiveDocument;
hist = new SelectionHistoryItem(Icon, Name);
hist.TakeSnapshot();
reset_origin = args.Event.GetPoint();
active_control = HandleResize (point);
if (!active_control.HasValue)
{
combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);
double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
shape_origin = new PointD(x, y);
doc.PreviousSelection.Dispose ();
doc.PreviousSelection = doc.Selection.Clone();
doc.Selection.SelectionPolygons.Clear();
// The bottom right corner should be selected.
active_control = 3;
}
is_drawing = true;
}
示例13: DrawGraduations
protected override void DrawGraduations(Context gr, PointD pStart, PointD pEnd)
{
Rectangle r = ClientRectangle;
Foreground.SetAsSource (gr);
gr.LineWidth = 2;
gr.MoveTo(pStart);
gr.LineTo(pEnd);
gr.Stroke();
gr.LineWidth = 1;
double sst = unity * SmallIncrement;
double bst = unity * LargeIncrement;
PointD vBar = new PointD(0, sst);
for (double x = Minimum; x <= Maximum - Minimum; x += SmallIncrement)
{
double lineLength = r.Height / 3;
if (x % LargeIncrement != 0)
lineLength /= 3;
PointD p = new PointD(pStart.X + x * unity, pStart.Y);
gr.MoveTo(p);
gr.LineTo(new PointD(p.X, p.Y + lineLength));
}
gr.Stroke();
}
示例14: EdgePointOfCircle
//FIXME: Fix so point stays on edge of circle
public static PointD EdgePointOfCircle(PointD midpoint, double radius, PointD endpoint)
{
var x_vector = endpoint.X - midpoint.X;
var y_vector = endpoint.Y - midpoint.Y;
var sin = y_vector / radius;
var cos = x_vector / radius;
var x = 0.0;
var y = 0.0;
var e = 0.0001;
if (Math.Abs (sin) > e) {
y = radius * (-sin);
y = Range (-radius, radius, y);
} else
x = radius;
if (Math.Abs (cos) > e) {
x = radius * (-cos);
x = Range (-radius, radius, x);
} else
y = radius;
return new PointD (midpoint.X + x, midpoint.Y + y);
}
示例15: OnDrawingAreaExposed
void OnDrawingAreaExposed(object o, ExposeEventArgs args)
{
if (prevSize != Allocation.Size)
{
if (model != null)
treeMapModel = new TreeMapModel(model, Allocation.Width, Allocation.Height);
}
DrawingArea area = (DrawingArea)o;
Cairo.Context g = Gdk.CairoHelper.Create(area.GdkWindow);
if (treeMapModel != null)
{
foreach (var item in treeMapModel.Items)
{
double width = item.Rectangle.Width;
double height = item.Rectangle.Height;
double x1 = item.Rectangle.X;
double x2 = item.Rectangle.X + item.Rectangle.Width;
double y1 = item.Rectangle.Y;
double y2 = item.Rectangle.Y + item.Rectangle.Height;
PointD p1, p2, p3, p4;
p1 = new PointD(x1, y1);
p2 = new PointD(x2, y1);
p3 = new PointD(x2, y2);
p4 = new PointD(x1, y2);
g.MoveTo(p1);
g.LineTo(p2);
g.LineTo(p3);
g.LineTo(p4);
g.LineTo(p1);
g.ClosePath();
g.Save();
//using (Gradient pat = new LinearGradient(x1, y1, x2, y2))
using (Gradient pat = new RadialGradient(x1 + (x2 - x1) / 4.0, y1 + (y2 - y1) / 4.0, 3, x1 + (x2 - x1) / 4.0, y1 + (y2 - y1) / 4.0, Math.Sqrt(width*width + height*height)))
{
pat.AddColorStop(0, new Cairo.Color(1, 1, 1, 1));
pat.AddColorStop(1, new Cairo.Color(0, 0, 1, 1));
g.Pattern = pat;
// Fill the path with pattern
g.FillPreserve();
}
// We "undo" the pattern setting here
g.Restore();
g.Color = new Color(0, 0, 0, 0);
g.Stroke();
}
}
((IDisposable)g.Target).Dispose();
((IDisposable)g).Dispose();
}