public static Point toWpfPoint(this PointDouble pointDouble) { return(new Point(pointDouble.x, pointDouble.y)); }
public bool LiesOnAxes(PointDouble p) { return(GenUtils.CloseEnough(p.X, x, 1) || GenUtils.CloseEnough(p.Y, y, 1) || GenUtils.CloseEnough(p.X, right, 1) || GenUtils.CloseEnough(p.Y, bottom, 1)); }
protected override SegmentedList <PointDouble> CreateShape(SegmentedList <PointDouble> tracePoints) { RectDouble num3; double num6; double num7; PointDouble a = tracePoints[0]; PointDouble b = tracePoints[tracePoints.Count - 1]; SelectionDrawMode mode = base.ToolSettings.Selection.DrawMode.Value; double num4 = base.ToolSettings.Selection.DrawWidth.Value; double num5 = base.ToolSettings.Selection.DrawHeight.Value; MeasurementUnit sourceUnits = base.ToolSettings.Selection.DrawUnits.Value; switch (mode) { case SelectionDrawMode.FixedRatio: case SelectionDrawMode.FixedSize: num6 = Math.Abs(num4); num7 = Math.Abs(num5); break; default: num6 = num4; num7 = num5; break; } switch (mode) { case SelectionDrawMode.Normal: if ((base.ModifierKeys & Keys.Shift) == Keys.None) { num3 = RectDoubleUtil.FromPixelPoints(a, b); break; } num3 = RectDoubleUtil.FromPixelPointsConstrained(a, b); break; case SelectionDrawMode.FixedRatio: try { double num13 = b.X - a.X; double num14 = b.Y - a.Y; double num15 = num13 / num6; double num16 = Math.Sign(num15); double num17 = num14 / num7; double num18 = Math.Sign(num17); double num19 = num6 / num7; if (num15 < num17) { double x = a.X; double y = a.Y; double right = a.X + num13; double bottom = a.Y + (num18 * Math.Abs((double)(num13 / num19))); num3 = RectDouble.FromEdges(x, y, right, bottom); } else { double left = a.X; double top = a.Y; double num26 = a.X + (num16 * Math.Abs((double)(num14 * num19))); double num27 = a.Y + num14; num3 = RectDouble.FromEdges(left, top, num26, num27); } } catch (ArithmeticException) { num3 = new RectDouble(a.X, a.Y, 0.0, 0.0); } break; case SelectionDrawMode.FixedSize: { double width = Document.ConvertMeasurement(num6, sourceUnits, base.Document.DpuUnit, base.Document.DpuX, MeasurementUnit.Pixel); double height = Document.ConvertMeasurement(num7, sourceUnits, base.Document.DpuUnit, base.Document.DpuY, MeasurementUnit.Pixel); num3 = new RectDouble(b.X, b.Y, width, height); break; } default: throw ExceptionUtil.InvalidEnumArgumentException <SelectionDrawMode>(mode, "drawMode"); } RectDouble num8 = RectDouble.Intersect(num3, base.Document.Bounds()); RectDouble num10 = num8.Int32Bound; if (num8.HasPositiveArea) { SegmentedList <PointDouble> list = new SegmentedList <PointDouble>(5, 7) { new PointDouble(num10.Left, num10.Top), new PointDouble(num10.Right, num10.Top), new PointDouble(num10.Right, num10.Bottom), new PointDouble(num10.Left, num10.Bottom) }; list.Add(list[0]); return(list); } return(new SegmentedList <PointDouble>(0, 7)); }
static void EmitVertex( StreamWriter s, PointDouble p) { s.WriteLine(_mtl_vertex, p.X, p.Y, p.Z); }
public void ProcessMouseWheel(Control sender, MouseEventArgs e) { double num11; double num12; double num13; RectDouble visibleCanvasViewportBounds = this.canvasView.GetVisibleCanvasViewportBounds(); PointInt32 point = base.PointToClient(sender.PointToScreen(e.Location)).ToPointInt32(); PointDouble viewportPt = RectDoubleUtil.Clamp(visibleCanvasViewportBounds, point); PointDouble extentPt = this.canvasView.ConvertViewportToExtent(viewportPt); PointDouble num5 = this.canvasView.ConvertExtentToCanvas(extentPt); double scaleRatio = this.canvasView.ScaleRatio; PointDouble viewportCanvasOffset = this.canvasView.ViewportCanvasOffset; double num8 = ((double)e.Delta) / scaleRatio; double x = viewportCanvasOffset.X; double y = viewportCanvasOffset.Y; ScaleBasis scaleBasis = this.canvasView.ScaleBasis; ScaleBasis ratio = ScaleBasis.Ratio; if (Control.ModifierKeys == Keys.Shift) { num11 = x - num8; num12 = y; ratio = scaleBasis; num13 = scaleRatio; } else if (Control.ModifierKeys == Keys.Control) { double num16; double num14 = ((double)e.Delta) / 120.0; double num15 = Math.Pow(1.12, Math.Abs(num14)); if (e.Delta > 0) { num16 = scaleRatio * num15; } else { num16 = scaleRatio / num15; } double num17 = this.canvasView.ClampScaleRatio(num16); double num18 = Math.Round(num17, MidpointRounding.AwayFromZero); if ((Math.Abs((double)(num18 - num17)) < (num18 * 0.1)) && (Math.Abs((double)(num18 - num17)) < Math.Abs((double)(num18 - scaleRatio)))) { num13 = num18; } else { num13 = num17; } ratio = ScaleBasis.Ratio; num11 = num5.X - (viewportPt.X / num13); num12 = num5.Y - (viewportPt.Y / num13); } else if (Control.ModifierKeys == Keys.None) { num11 = x; num12 = y - num8; ratio = scaleBasis; num13 = scaleRatio; } else { num11 = x; num12 = y; ratio = scaleBasis; num13 = scaleRatio; } this.canvasView.ViewportCanvasOffset = new PointDouble(num11, num12); this.canvasView.ScaleBasis = ratio; this.canvasView.ScaleRatio = num13; }
public static PointDouble ConvertExtentToCanvas(this CanvasView canvasView, PointDouble extentPt) => CanvasCoordinateConversions.ConvertExtentToCanvas(extentPt, canvasView.ScaleRatio);
protected static PointDouble GetMouseCenterPt(PointDouble mouseTopLeftPt, double hairWidth) => BrushToolBase <TDerived, TChanges, TUI> .GetMouseCoverageRect(mouseTopLeftPt, hairWidth).Center;
private static PointDouble GetMoveHandleCanvasOffset(PointDouble gradientStartPoint, PointDouble gradientEndPoint, double hairWidth, SizeDouble moveHandleActualSize) { VectorDouble num2; VectorDouble num = (VectorDouble)(gradientEndPoint - gradientStartPoint); if (num.LengthSquared <= double.Epsilon) { num2 = new VectorDouble(1.0, 1.0); } else { num2 = num; } VectorDouble num4 = (VectorDouble)(VectorDouble.Normalize(num2) * (hairWidth * 35.0)); double x = UIUtil.ScaleWidth(num4.X); VectorDouble num5 = new VectorDouble(x, UIUtil.ScaleHeight(num4.Y)); PointDouble pt = gradientEndPoint + num5; return(PointDouble.Offset(pt, -moveHandleActualSize.Width / 2.0, -moveHandleActualSize.Height / 2.0)); }
public BrushStrokeSample(PointDouble center, double stampScale) { this.center = center; this.stampScale = stampScale; }
/// <summary> /// 根据像素坐标和瓦片尺寸获取瓦片索引 /// </summary> /// <param name="p"></param> /// <param name="tileSize"></param> /// <returns></returns> public static PointInt64 PixelToTileXY(PointDouble p) { return(MapHelper.PixelToTileXY(p, TileSize)); }
private static PointDouble GetHandleCanvasOffset(PointDouble point, SizeDouble actualSize) => new PointDouble(point.X - (actualSize.Width / 2.0), point.Y - (actualSize.Height / 2.0));
/// <summary> /// 像素坐标转大地坐标 /// </summary> /// <param name="pPix">像素坐标</param> /// <param name="zoom">层级</param> /// <returns></returns> public static PointDouble PointPixToPointGeo(PointDouble pPix, int zoom) { PointDouble pg = new PointDouble(); return(pg); }
/// <summary> /// 大地坐标转经纬度坐标 /// </summary> /// <param name="p"></param> /// <returns></returns> public static PointLatLng PointGetToLatLng(PointDouble p) { PointLatLng pll = new PointLatLng(p.X * 180 / L, (Math.Atan(Math.Pow(Math.E, p.Y / Axis)) * (180 / Math.PI) - 45) * 2); return(pll); }
/// <summary> /// 经纬度坐标转大地坐标 /// </summary> /// <param name="latlng"></param> /// <returns></returns> public static PointDouble LatLngToPointGeo(PointLatLng latlng) { PointDouble pd = new PointDouble(L * latlng.LngX / 180, Axis * Math.Log(Math.Tan((45.0 + latlng.LatY / 2) * (Math.PI / 180)))); return(pd); }
public static PointDouble ConvertViewportToCanvas(this CanvasView canvasView, PointDouble viewportPt) => CanvasCoordinateConversions.ConvertViewportToCanvas(viewportPt, canvasView.ScaleRatio, canvasView.ViewportCanvasOffset);
public PaintBucketToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, PointDouble originPoint, FloodMode?floodModeOverride, PaintDotNet.WhichUserColor whichUserColor, GeometryList clippingMask) : base(drawingSettingsValues, originPoint, floodModeOverride) { this.whichUserColor = whichUserColor; if (clippingMask == null) { this.clippingMaskPO = null; this.clippingMaskPersistenceKey = Guid.Empty; } else { this.clippingMaskPO = new PersistedObject <GeometryList>(clippingMask, true); this.clippingMaskPersistenceKey = PersistedObjectLocker.Add <GeometryList>(this.clippingMaskPO); } this.Initialize(); }
public static PointDouble ConvertCanvasToExtent(this CanvasView canvasView, PointDouble canvasPt) => CanvasCoordinateConversions.ConvertCanvasToExtent(canvasPt, canvasView.ScaleRatio);
public PaintBucketToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, PointDouble originPoint, FloodMode?floodModeOverride, PaintDotNet.WhichUserColor whichUserColor, Guid clippingMaskPersistenceKey) : base(drawingSettingsValues, originPoint, floodModeOverride) { this.whichUserColor = whichUserColor; this.clippingMaskPersistenceKey = clippingMaskPersistenceKey; this.Initialize(); }
public static PointDouble ConvertExtentToViewport(this CanvasView canvasView, PointDouble extentPt) => CanvasCoordinateConversions.ConvertExtentToViewport(extentPt, canvasView.ScaleRatio, canvasView.ViewportCanvasOffset);
public Center(PointDouble loc) { this.loc = loc; }
protected static RectDouble GetMouseCoverageRect(PointDouble mouseTopLeftPt, double hairWidth) => new RectDouble(mouseTopLeftPt, new SizeDouble(hairWidth, hairWidth));
private void RedrawOnBackgroundThread() { if (base.CheckAccess()) { ExceptionUtil.ThrowInvalidOperationException(); } if (this.redrawThreadFactory == null) { this.redrawThreadFactory = new Direct2DFactory(Direct2DFactoryType.MultiThreaded, DebugLevel.None); } if ((this.redrawThreadGeometryCache == null) || (this.redrawThreadGeometryCache.SelectionSnapshot != this.redrawRenderParams.SelectionSnapshot)) { DisposableUtil.Free <SelectionGeometryCache>(ref this.redrawThreadGeometryCache); this.redrawThreadGeometryCache = new SelectionGeometryCache(this.redrawThreadFactory, this.redrawRenderParams.SelectionSnapshot); } double scaleRatio = this.redrawRenderParams.ScaleRatio; PointDouble location = this.redrawRenderParams.ViewportCanvasBounds.Location; SizeDouble viewportSize = this.redrawRenderParams.ViewportSize; SizeInt32 num5 = SizeDouble.Ceiling(viewportSize); RectDouble b = RectDouble.Inflate(CanvasCoordinateConversions.ConvertExtentToViewport(CanvasCoordinateConversions.ConvertCanvasToExtent(this.redrawRenderParams.SelectionSnapshot.GeometryList.Value.Bounds, scaleRatio), scaleRatio, location), (double)this.outlineStrokeWidthPx, (double)this.outlineStrokeWidthPx); RectDouble a = new RectDouble(PointDouble.Zero, viewportSize); RectDouble renderViewportBounds = RectDouble.Intersect(a, b); RectInt32 viewportRect = renderViewportBounds.Int32Bound; RectDouble extentRect = CanvasCoordinateConversions.ConvertViewportToExtent(viewportRect, scaleRatio, location); RectDouble renderCanvasBounds = CanvasCoordinateConversions.ConvertExtentToCanvas(extentRect, scaleRatio); if (!viewportRect.HasPositiveArea) { base.SyncContext.Post((SendOrPostCallback)(_ => this.EndRedraw(renderViewportBounds, RectFloat.Zero, null, null))); } else { IBitmap <ColorAlpha8> interiorMask; float scale; PointFloat offset; Result <IGeometry> lazyGeometry; IBitmap <ColorAlpha8>[] dashedOutlineMasks; RectFloat maskSourceRect; SelectionSnapshot selectionSnapshot = this.redrawRenderParams.SelectionSnapshot; SelectionGeometryCache redrawThreadGeometryCache = this.redrawThreadGeometryCache; bool flag = this.redrawRenderParams.SelectionRenderingQuality == SelectionRenderingQuality.Aliased; if (!flag) { lazyGeometry = redrawThreadGeometryCache.Geometry; } else { bool flag3 = selectionSnapshot.IsRectilinear.Value; bool flag4 = selectionSnapshot.IsPixelated.Value; if (flag3 & flag4) { lazyGeometry = redrawThreadGeometryCache.Geometry; } else { lazyGeometry = redrawThreadGeometryCache.PixelatedGeometry; } } bool flag2 = !flag && this.redrawRenderParams.IsOutlineAntialiased; AntialiasMode antialiasMode = ((flag || !flag2) || selectionSnapshot.IsRectilinear.Value) ? AntialiasMode.Aliased : AntialiasMode.PerPrimitive; if (this.CanContinueRedrawing(null, null)) { scale = (float)this.redrawRenderParams.ScaleRatio; float x = -((float)renderCanvasBounds.X); float y = -((float)renderCanvasBounds.Y); offset = new PointFloat(x, y); interiorMask = BitmapAllocator.Alpha8.Allocate(viewportRect.Size, AllocationOptions.ZeroFillNotRequired); try { RetryManager.RunMemorySensitiveOperation(delegate { using (IDrawingContext context = DrawingContext.FromBitmap(this.redrawThreadFactory, interiorMask)) { context.Clear(null); IBrush interiorBrush = context.GetCachedOrCreateResource <IBrush>(whiteBrush); this.RenderSelection(context, scale, offset, this.redrawRenderParams, lazyGeometry, interiorBrush, null, null, antialiasMode); } }); } catch (OutOfMemoryException) { } if (this.CanContinueRedrawing(interiorMask, null)) { int num15; dashedOutlineMasks = new IBitmap <ColorAlpha8> [SelectionCanvasLayer.DashLength]; for (int i = 0; i < dashedOutlineMasks.Length; i = num15) { if ((!this.redrawRenderParams.IsOutlineAnimated && (i != 0)) && (i != (SelectionCanvasLayer.DashLength / 2))) { dashedOutlineMasks[i] = null; } else { dashedOutlineMasks[i] = BitmapAllocator.Alpha8.Allocate(viewportRect.Size, AllocationOptions.ZeroFillNotRequired); try { RetryManager.RunMemorySensitiveOperation(delegate { using (IDrawingContext context = DrawingContext.FromBitmap(this.redrawThreadFactory, dashedOutlineMasks[i])) { context.Clear(null); StrokeStyle resourceSource = SelectionCanvasLayer.GetDashedStrokeStyle(i); IStrokeStyle outlineStrokeStyle = context.GetCachedOrCreateResource <IStrokeStyle>(resourceSource); IBrush cachedOrCreateResource = context.GetCachedOrCreateResource <IBrush>(whiteBrush); this.RenderSelection(context, scale, offset, this.redrawRenderParams, lazyGeometry, null, cachedOrCreateResource, outlineStrokeStyle, antialiasMode); } }); } catch (OutOfMemoryException) { } if (!this.CanContinueRedrawing(interiorMask, dashedOutlineMasks)) { return; } } num15 = i + 1; } maskSourceRect = new RectFloat(PointFloat.Zero, interiorMask.Size); base.SyncContext.Post(_ => this.EndRedraw(renderCanvasBounds, maskSourceRect, interiorMask, dashedOutlineMasks), null); } } } }
protected override void OnKeyDown(KeyEventArgs e) { if (e.Handled) { goto Label_0347; } PaintDotNet.Canvas.CanvasView canvasView = this.CanvasView; if (canvasView == null) { goto Label_0347; } bool flag = false; switch (e.KeyCode) { case Keys.PageUp: if (!e.Shift) { canvasView.ViewportCanvasOffset -= new VectorDouble(0.0, canvasView.ViewportCanvasBounds.Height); } else { canvasView.ViewportCanvasOffset -= new VectorDouble(canvasView.ViewportCanvasBounds.Width, 0.0); } flag = true; e.Handled = true; goto Label_032E; case Keys.Next: if (!e.Shift) { canvasView.ViewportCanvasOffset += new VectorDouble(0.0, canvasView.ViewportCanvasBounds.Height); break; } canvasView.ViewportCanvasOffset += new VectorDouble(canvasView.ViewportCanvasBounds.Width, 0.0); break; case Keys.End: if (!e.Control || !e.Alt) { if (e.Control) { canvasView.ViewportCanvasOffset = canvasView.ViewportCanvasOffsetMax; } else { RectDouble visibleCanvasBounds = canvasView.GetVisibleCanvasBounds(); SizeDouble size = canvasView.ViewportCanvasBounds.Size; PointDouble bottomRight = canvasView.GetCanvasBounds().BottomRight; if ((visibleCanvasBounds.Left <= (bottomRight.X - 1.0)) && (visibleCanvasBounds.Right >= bottomRight.X)) { if ((visibleCanvasBounds.Top > (bottomRight.Y - 1.0)) || (visibleCanvasBounds.Bottom < bottomRight.Y)) { canvasView.ViewportCanvasOffset = new PointDouble(canvasView.ViewportCanvasOffset.X, bottomRight.Y - size.Height); } } else { canvasView.ViewportCanvasOffset = new PointDouble(bottomRight.X - size.Width, canvasView.ViewportCanvasOffset.Y); } } } flag = true; e.Handled = true; goto Label_032E; case Keys.Home: if (!e.Control || !e.Alt) { if (e.Control) { canvasView.ViewportCanvasOffset = canvasView.ViewportCanvasOffsetMin; } else { RectDouble num2 = canvasView.GetVisibleCanvasBounds(); PointDouble topLeft = canvasView.GetCanvasBounds().TopLeft; if ((num2.Left <= topLeft.X) && (num2.Right >= (topLeft.X + 1.0))) { if ((num2.Top > topLeft.Y) || (num2.Bottom < (topLeft.Y + 1.0))) { canvasView.ViewportCanvasOffset -= new VectorDouble(0.0, num2.Top - topLeft.Y); } } else { canvasView.ViewportCanvasOffset -= new VectorDouble(num2.Left - topLeft.X, 0.0); } } } flag = true; e.Handled = true; goto Label_032E; default: goto Label_032E; } flag = true; e.Handled = true; Label_032E: if (flag) { canvasView.SetValue(PaintDotNet.Canvas.CanvasView.ViewportCanvasOffsetProperty, canvasView.GetValue(PaintDotNet.Canvas.CanvasView.ViewportCanvasOffsetProperty)); } Label_0347: base.OnKeyDown(e); }
void pictureBox1_MouseUp(object sender, MouseEventArgs e) { _dragging = false; if (!_imageRectangle.ContainsPoint(_imageX + _adjustedStartPoint.X * _imageMultiplier, _imageY + _adjustedStartPoint.Y * _imageMultiplier) || !_imageRectangle.ContainsPoint(_imageX + (e.X / _imageMultiplier) * _imageMultiplier + 1, _imageY + (e.Y / _imageMultiplier) * _imageMultiplier + 1)) { PaintAll(); return; } Func <Line, Point, bool> lineEndsInPoint = (line, point) => { return(line.P1.Equals(point) || line.P2.Equals(point)); }; Shape[] shapesWithStartPoint = _newShapes.Where(i => i.Lines.Where(j => lineEndsInPoint(j, _adjustedStartPoint)).ToArray().Length > 0).ToArray(); Shape[] shapesWithEndPoint = _newShapes.Where(i => i.Lines.Where(j => lineEndsInPoint(j, _adjustedEndPoint)).ToArray().Length > 0).ToArray(); if (shapesWithStartPoint.Length > 1 || shapesWithEndPoint.Length > 1) { PaintAll(); return; } PointDouble pdStartPoint = new PointDouble(_adjustedStartPoint.X, _adjustedStartPoint.Y); PointDouble pdEndPoint = new PointDouble(_adjustedEndPoint.X, _adjustedEndPoint.Y); Shape newShape = new Shape(pdStartPoint, pdEndPoint); if (shapesWithStartPoint.Length == 0 && shapesWithEndPoint.Length == 0) { _newShapes.Add(newShape); DoLinesPaint(); PaintAll(); return; } if (shapesWithStartPoint.Length > 0 && shapesWithEndPoint.Length > 0 && shapesWithStartPoint[0] == shapesWithEndPoint[0]) { if (newShape.JoinWith(shapesWithStartPoint[0])) { _newShapes.Remove(shapesWithStartPoint[0]); } _newShapes.Add(newShape); DoLinesPaint(); PaintAll(); return; } if (shapesWithStartPoint.Length > 0) { if (newShape.JoinWith(shapesWithStartPoint[0])) { _newShapes.Remove(shapesWithStartPoint[0]); } _newShapes.Add(newShape); } if (shapesWithEndPoint.Length > 0) { if (newShape.JoinWith(shapesWithEndPoint[0])) { _newShapes.Remove(shapesWithEndPoint[0]); } _newShapes.Add(newShape); } DoLinesPaint(); PaintAll(); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { double canvasHairWidth = canvasView.CanvasHairWidth; if (this.handleDiameter > 2.0) { double rotationAngle = this.handleTransform.GetRotationAngle(); PointDouble location = this.handleTransform.Transform(this.handleLocation) + ((PointDouble)(this.handleLocationScreenOffset * canvasHairWidth)); VectorDouble[] vecs = new VectorDouble[] { new VectorDouble(-1.0, -1.0), new VectorDouble(1.0, -1.0), new VectorDouble(1.0, 1.0), new VectorDouble(-1.0, 1.0), new VectorDouble(-1.0, 0.0), new VectorDouble(1.0, 0.0), new VectorDouble(0.0, -1.0), new VectorDouble(0.0, 1.0) }; vecs.RotateInPlace(rotationAngle); vecs.NormalizeInPlace(); double num5 = ((double)this.handleAlpha) / 255.0; this.whiteBrush.Opacity = num5; this.blackBrush.Opacity = num5; if (this.handleShape != MoveHandleShape.Circle) { PointDouble[] numArray2 = new PointDouble[] { location + (vecs[0] * (this.handleDiameter * canvasHairWidth)), location + (vecs[1] * (this.handleDiameter * canvasHairWidth)), location + (vecs[2] * (this.handleDiameter * canvasHairWidth)), location + (vecs[3] * (this.handleDiameter * canvasHairWidth)) }; PointDouble[] numArray3 = new PointDouble[] { location + (vecs[0] * ((this.handleDiameter - 1.0) * canvasHairWidth)), location + (vecs[1] * ((this.handleDiameter - 1.0) * canvasHairWidth)), location + (vecs[2] * ((this.handleDiameter - 1.0) * canvasHairWidth)), location + (vecs[3] * ((this.handleDiameter - 1.0) * canvasHairWidth)) }; PointDouble[] numArray4 = new PointDouble[] { location + (vecs[0] * ((this.handleDiameter - 2.0) * canvasHairWidth)), location + (vecs[1] * ((this.handleDiameter - 2.0) * canvasHairWidth)), location + (vecs[2] * ((this.handleDiameter - 2.0) * canvasHairWidth)), location + (vecs[3] * ((this.handleDiameter - 2.0) * canvasHairWidth)) }; dc.DrawLine(numArray2[0], numArray2[1], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray2[1], numArray2[2], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray2[2], numArray2[3], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray2[3], numArray2[0], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray3[0], numArray3[1], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray3[1], numArray3[2], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray3[2], numArray3[3], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray3[3], numArray3[0], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray4[0], numArray4[1], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray4[1], numArray4[2], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray4[2], numArray4[3], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray4[3], numArray4[0], this.whiteBrush, canvasHairWidth); } else if (this.handleShape == MoveHandleShape.Circle) { RectDouble rect = new RectDouble(location, SizeDouble.Zero); rect.Inflate((double)((this.handleDiameter - 1.0) * canvasHairWidth), (double)((this.handleDiameter - 1.0) * canvasHairWidth)); dc.DrawEllipse(EllipseDouble.FromRect(rect), this.whiteBrush, canvasHairWidth); rect.Inflate(-canvasHairWidth, -canvasHairWidth); dc.DrawEllipse(EllipseDouble.FromRect(rect), this.blackBrush, canvasHairWidth); rect.Inflate(-canvasHairWidth, -canvasHairWidth); dc.DrawEllipse(EllipseDouble.FromRect(rect), this.whiteBrush, canvasHairWidth); } if (this.handleShape == MoveHandleShape.Compass) { PointDouble num7 = location + ((PointDouble)(vecs[0] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble point = location + ((PointDouble)(vecs[1] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble num9 = location + ((PointDouble)(vecs[2] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble num10 = location + ((PointDouble)(vecs[3] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble num11 = new PointDouble(num7.X, (num7.Y + num10.Y) / 2.0); PointDouble num12 = new PointDouble((num7.X + point.X) / 2.0, num7.Y); PointDouble num13 = new PointDouble(point.X, (point.Y + num9.Y) / 2.0); PointDouble num14 = new PointDouble((num10.X + num9.X) / 2.0, num9.Y); PointDouble num15 = new PointDouble(num12.X, num11.Y); PathGeometry geometry = new PathGeometry(); PathFigure item = new PathFigure { IsClosed = true, IsFilled = true, StartPoint = num7 }; item.Segments.Add(new LineSegment(point)); item.Segments.Add(new LineSegment(num9)); item.Segments.Add(new LineSegment(num10)); geometry.Figures.Add(item); dc.FillGeometry(geometry, this.whiteBrush, null); PathGeometry geometry2 = new PathGeometry(); double num16 = canvasHairWidth; double num17 = 1.35 * canvasHairWidth; double num18 = (num17 * 3.0) / 2.0; double num19 = num16 / 2.0; double num20 = (num17 * Math.Sqrt(27.0)) / 2.0; PathFigure figure2 = new PathFigure { IsFilled = true, IsClosed = true, StartPoint = num11 }; figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y + num18))); figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X - num19, num15.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X - num19, num14.Y - num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X - num18, num14.Y - num20))); figure2.Segments.Add(new LineSegment(num14)); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X + num18, num14.Y - num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X + num19, num14.Y - num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X + num19, num15.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y + num18))); figure2.Segments.Add(new LineSegment(num13)); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y - num18))); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X + num19, num15.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X + num19, num12.Y + num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X + num18, num12.Y + num20))); figure2.Segments.Add(new LineSegment(num12)); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X - num18, num12.Y + num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X - num19, num12.Y + num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X - num19, num15.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y - num18))); geometry2.Figures.Add(figure2); dc.FillGeometry(geometry2, this.blackBrush, null); } } base.OnRender(dc, clipRect, canvasView); }
public PointInt(PointDouble p) { X = (int)Math.Round(p.X); Y = (int)Math.Round(p.Y); }
public bool InBounds(PointDouble p) { return(InBounds(p.X, p.Y)); }
private void PutPixel(int[, ] matrix, PointDouble point, int color) { PutPixel(matrix, new PointInt(point), color); }
public unsafe void DrawScansNearestNeighbor(int cpuNumber) { int logicalCpuCount = Processor.LogicalCpuCount; void * voidStar = this.src.Scan0.VoidStar; int stride = this.src.Stride; RectInt32 b = this.dst.Bounds <ColorBgra>(); for (int i = cpuNumber; i < this.dstScans.Length; i += logicalCpuCount) { RectInt32 num5 = RectInt32.Intersect(this.dstScans[i], b); if ((num5.Width != 0) && (num5.Height != 0)) { PointDouble pt = new PointDouble((double)num5.X, (double)num5.Y); pt.X += 0.5; pt.Y += 0.5; pt = this.inverse.Transform(pt); pt.X -= this.boundsX; pt.Y -= this.boundsY; pt.X -= 0.5; pt.Y -= 0.5; int num7 = (int)(pt.X * 16384.0); int num8 = (int)(pt.Y * 16384.0); for (int j = num5.Y; j < (num5.Y + num5.Height); j++) { int num10 = num7; int num11 = num8; num7 += this.fp_dsxddy; num8 += this.fp_dsyddy; if (j >= 0) { int x = num5.X; ColorBgra *pointAddress = this.dst.GetPointAddress(x, j); ColorBgra *bgraPtr2 = pointAddress + num5.Width; int num13 = num10 + (this.fp_dsxddx * (num5.Width - 1)); int num14 = num11 + (this.fp_dsyddx * (num5.Width - 1)); while (pointAddress < bgraPtr2) { int num15 = (num10 + 0x1fff) >> 14; int num16 = (num11 + 0x1fff) >> 14; int num17 = Int32Util.Clamp(num15, 0, this.src.Width - 1); int y = Int32Util.Clamp(num16, 0, this.src.Height - 1); pointAddress[0] = this.src.GetPointUnchecked(num17, y); pointAddress++; num10 += this.fp_dsxddx; num11 += this.fp_dsyddx; if ((num17 == num15) && (y == num16)) { break; } } ColorBgra *bgraPtr3 = pointAddress; pointAddress = bgraPtr2 - 1; while (pointAddress >= bgraPtr3) { int num19 = (num13 + 0x1fff) >> 14; int num20 = (num14 + 0x1fff) >> 14; int num21 = Int32Util.Clamp(num19, 0, this.src.Width - 1); int num22 = Int32Util.Clamp(num20, 0, this.src.Height - 1); pointAddress[0] = this.src.GetPointUnchecked(num21, num22); if ((num21 == num19) && (num22 == num20)) { break; } pointAddress--; num13 -= this.fp_dsxddx; num14 -= this.fp_dsyddx; } ColorBgra *bgraPtr4 = pointAddress; while (bgraPtr3 < bgraPtr4) { int num23 = (num10 + 0x1fff) >> 14; int num24 = (num11 + 0x1fff) >> 14; bgraPtr3->Bgra = (((IntPtr)(num23 * sizeof(ColorBgra))) + (voidStar + (num24 * stride))).Bgra; bgraPtr3++; num10 += this.fp_dsxddx; num11 += this.fp_dsyddx; } } } } } }
private static void SetMouseCapturePoint(PaintDotNet.UI.FrameworkElement target, PointDouble value) { target.SetValue(MouseCapturePointPropertyKey, value); }