public static bool GetBoundingRect(VertexStoreSnap vs, ref RectD rect) { double x1, y1, x2, y2; bool rValue = GetBoundingRectSingle(vs, out x1, out y1, out x2, out y2); rect.Left = x1; rect.Bottom = y1; rect.Right = x2; rect.Top = y2; return rValue; }
public SimpleRect(double left, double bottom, double right, double top) { bounds = new RectD(left, bottom, right, top); if (left > right) { bounds.Left = right; bounds.Right = left; } if (bottom > top) { bounds.Bottom = top; bounds.Top = bottom; } }
public TextWidget(string Text, double left, double bottom, double CapitalHeight) : base(0, 0, 0, 0) { m_text_color = (new RGBA_Doubles(0.0, 0.0, 0.0)); m_BorderSize = CapitalHeight * .2; m_Thickness = CapitalHeight / 8; m_CapsHeight = CapitalHeight; m_text = new GsvText(); m_text.Text = Text; m_text_poly = new StrokeConverter(m_text); m_idx = (0); double MinX, MinY, MaxX, MaxY; GetTextBounds(out MinX, out MinY, out MaxX, out MaxY); double FullWidth = MaxX - MinX + m_BorderSize * 2; double FullHeight = m_CapsHeight + m_text.AscenderHeight + m_text.DescenderHeight + m_BorderSize * 2; Bounds = new RectD(left, bottom, left + FullWidth, bottom + FullHeight); }
protected override RectD CalculateLocalBounds() { RectD localBounds = new RectD(double.PositiveInfinity, double.PositiveInfinity, double.NegativeInfinity, double.NegativeInfinity); this.RewindZero(); using (VxsTemp.Borrow(out var v1)) { this.MakeVxs(v1); int j = v1.Count; for (int i = 0; i < j; ++i) { double x, y; v1.GetVertexXY(i, out x, out y); localBounds.ExpandToInclude(x, y); } return(localBounds); } //throw new NotImplementedException(); }
public override Visual CreateVisual(IRenderContext context) { if (Bounds == null) { return(null); } var container = new VisualGroup(); var iconBounds = new RectD(PointD.Origin, Bounds.ToSizeD()); foreach (var icon in icons) { icon.SetBounds(iconBounds); container.Add(icon.CreateVisual(context)); } container.SetCanvasArrangeRect(Bounds.ToRectD()); container.SetRenderDataCache(Bounds.ToRectD()); return(container); }
private void FormBlit_Load(object sender, EventArgs e) { particleBmp = LoadBitmapAsReadonly("../../FlowerBurst.jpg"); circleBmp = LoadBitmapAsReadonly("../../circle.png"); timer1 = new Timer(); timer1.Interval = 30; timer1.Tick += (s1, e1) => this.Invoke(new MethodInvoker(() => UpdateRenderFrame())); particleSourceRect = new RectD(0, 0, 64, 64); //bmp = BitmapFactory.New(640, 480); //bmp.Clear(Colors.Black); destBmp = new Bitmap(400, 500); g = this.panel1.CreateGraphics(); emitter = new ParticleEmitter(); //CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); this.MouseMove += new MouseEventHandler(MainPage_MouseMove); }
protected override void OnInitGLProgram(object sender, EventArgs args) { lionShape = new SpriteShape(); lionShape.ParseLion(); RectD lionBounds = lionShape.Bounds; //------------- aggImage = new ActualImage((int)lionBounds.Width, (int)lionBounds.Height, PixelFarm.Agg.PixelFormat.ARGB32); imgGfx2d = new ImageGraphics2D(aggImage); aggPainter = new AggCanvasPainter(imgGfx2d); DrawLion(aggPainter, lionShape, lionShape.Path.Vxs); //convert affImage to texture glBmp = LoadTexture(aggImage); int max = Math.Max(this.Width, this.Height); canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max); //------------------------- painter = new GLCanvasPainter(canvas2d, max, max); }
internal void Initialize(IMapReadable map, UnwrappedTileId tileId, float scale, int zoom, Texture2D loadingTexture = null) { TileScale = scale; _relativeScale = 1 / Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x); _rect = Conversions.TileBounds(tileId); _unwrappedTileId = tileId; _canonicalTileId = tileId.Canonical; _loadingTexture = loadingTexture; float scaleFactor = 1.0f; if (_isInitialized == false) { _isInitialized = true; InitialZoom = zoom; } scaleFactor = Mathf.Pow(2, (map.InitialZoom - zoom)); gameObject.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor); gameObject.SetActive(true); }
private void OnIntersect(object sender, RoutedEventArgs args) { args.Handled = true; RectD bounds = OutputBounds; double x = bounds.Left + (double)LeftUpDown.Value; double y = bounds.Top + (double)TopUpDown.Value; double dx = (double)WidthUpDown.Value; double dy = (double)HeightUpDown.Value; Subdivision rectangle; if (sender == RectangleButton) { rectangle = Subdivision.FromLines(new LineD[] { new LineD(x, y, x + dx, y), new LineD(x + dx, y, x + dx, y + dy), new LineD(x + dx, y + dy, x, y + dy), new LineD(x, y + dy, x, y) }); } else if (sender == DiamondButton) { rectangle = Subdivision.FromLines(new LineD[] { new LineD(x + dx / 2, y, x + dx, y + dy / 2), new LineD(x + dx, y + dy / 2, x + dx / 2, y + dy), new LineD(x + dx / 2, y + dy, x, y + dy / 2), new LineD(x, y + dy / 2, x + dx / 2, y) }); } else { return; } rectangle.Validate(); _division = Subdivision.Intersection(_division, rectangle, out _faceKeys); _division.Validate(); SubdivisionTest.DrawSubdivision(OutputBox, FontSize, _division); }
protected override bool IsHit(IInputModeContext context, PointD location, INode node) { if (sns.Renderer.GetHitTestable(node, sns).IsHit(context, location)) { return(true); } var layout = node.Layout.ToRectD(); if (ShowTopMessage) { var cx = layout.GetCenter().X; var topBoxSize = BpmnConstants.MessageSize; var messageRect = new RectD(new PointD(cx - topBoxSize.Width / 2, layout.Y - MessageDistance - topBoxSize.Height), topBoxSize); if (messageRect.Contains(location, context.HitTestRadius)) { return(true); } if (Math.Abs(location.X - cx) < context.HitTestRadius && layout.Y - MessageDistance - context.HitTestRadius < location.Y && location.Y < layout.Y + context.HitTestRadius) { return(true); } } if (ShowBottomMessage) { var bottomBoxSize = BpmnConstants.MessageSize; var cx = layout.GetCenter().X; var messageRect = new RectD(new PointD(cx - bottomBoxSize.Width / 2, layout.GetMaxY() + MessageDistance), bottomBoxSize); if (messageRect.Contains(location, context.HitTestRadius)) { return(true); } if (Math.Abs(location.X - cx) < context.HitTestRadius && layout.GetMaxY() - context.HitTestRadius < location.Y && location.Y < layout.GetMaxY() + MessageDistance + context.HitTestRadius) { return(true); } } return(false); }
public static RectD Get_Border_Points(BPaintLine Par_obj, bool padding = true) { RectD result = new RectD(); List <PointD> data = new List <PointD>(); data.Add(Par_obj.Position.PtD); data.Add(Par_obj.end.PtD); result.x = data.Min(j => j.X); result.y = data.Min(j => j.Y); result.width = data.Max(j => j.X) - result.x; result.height = data.Max(j => j.Y) - result.y; if (padding) { Set_Padding(result); } return(result); }
public override Visual UpdateVisual(IRenderContext context, Visual oldVisual) { var container = oldVisual as VisualGroup; if (container == null || container.Children.Count != icons.Count) { return(CreateVisual(context)); } var cache = container.GetRenderDataCache <RectD>(); if (cache.Size != Bounds.ToSizeD()) { // size changed -> we have to update the icons var iconBounds = new RectD(PointD.Origin, Bounds.ToSizeD()); int index = 0; foreach (var pathIcon in icons) { pathIcon.SetBounds(iconBounds); var oldPathVisual = container.Children[index]; var newPathVisual = pathIcon.UpdateVisual(context, oldPathVisual); if (!oldPathVisual.Equals(newPathVisual)) { newPathVisual = newPathVisual ?? new VisualGroup(); container.Children.Remove(oldPathVisual); container.Children.Insert(index, newPathVisual); } index++; } } else if (cache.TopLeft == Bounds.GetTopLeft()) { // bounds didn't change at all return(container); } container.SetCanvasArrangeRect(Bounds.ToRectD()); container.SetRenderDataCache(Bounds.ToRectD()); return(container); }
public override void OnDraw() { AntiAliasedScanlineRasterizer ras = new Pictor.AntiAliasedScanlineRasterizer(); Scanline sl = new Pictor.Scanline(); RoundedRect rectBorder = new RoundedRect(m_Bounds, m_BorderRadius); GetRenderer().Render(rectBorder, new RGBA_Bytes(0, 0, 0)); RectD insideBounds = Bounds; insideBounds.Inflate(-BorderWidth); RoundedRect rectInside = new RoundedRect(insideBounds, Math.Max(m_BorderRadius - BorderWidth, 0)); RGBA_Bytes insideColor = new RGBA_Bytes(222, 222, 222); GetRenderer().Render(rectInside, insideColor); RoundedRect titleBar = new RoundedRect(new RectD(m_Bounds.Left + BorderWidth, m_Bounds.Top - BorderWidth - 20, m_Bounds.Right - BorderWidth, m_Bounds.Top - BorderWidth), m_BorderRadius); GetRenderer().Render(titleBar, new RGBA_Bytes(0, 66, 128)); base.OnDraw(); }
/** * @since 6.0.0 * @return the maximum zoom level where a bounding box fits into a screen, * or Double.MIN_VALUE if bounding box is a single point * https://github.com/osmdroid/osmdroid/blob/78d28e4b958ed0a12a6203d9a4d9c7af58422101/osmdroid-android/src/main/java/org/osmdroid/util/TileSystem.java */ public void ZoomToBoundingBox(RectD pBoundingBox, int pScreenWidth, int pScreenHeight) { if (screenRect.width == 0 && screenRect.height == 0) { waitingForValidScreen = true; waitingBoundingBox = pBoundingBox; } if (pBoundingBox.Width == 0 && pBoundingBox.Height == 0) { Zoom = 19; return; } if (pScreenWidth == 0) { pScreenWidth = (int)screenRect.width; } if (pScreenHeight == 0) { pScreenHeight = (int)screenRect.height; } double longitudeZoom = getLongitudeZoom(pBoundingBox.Min.x + pBoundingBox.Width, pBoundingBox.Min.x, pScreenWidth); double latitudeZoom = getLatitudeZoom(pBoundingBox.Min.y, pBoundingBox.Min.y + pBoundingBox.Height, pScreenHeight); if (longitudeZoom == double.MinValue) { Zoom = (int)latitudeZoom; } else if (latitudeZoom == double.MinValue) { Zoom = (int)longitudeZoom; } else { Zoom = (int)Math.Min(latitudeZoom, longitudeZoom); } }
protected override RectD CalculateLocalBounds() { RectD localBounds = new RectD(double.PositiveInfinity, double.PositiveInfinity, double.NegativeInfinity, double.NegativeInfinity); this.RewindZero(); VectorToolBox.GetFreeVxs(out VertexStore v1); this.MakeVxs(v1); int j = v1.Count; for (int i = 0; i < j; ++i) { double x, y; v1.GetVertexXY(i, out x, out y); localBounds.ExpandToInclude(x, y); } VectorToolBox.ReleaseVxs(ref v1); return(localBounds); throw new NotImplementedException(); }
public BlurWithPainter() { //m_rbuf2 = new ReferenceImage(); m_shape_bounds = new RectD(); m_shadow_ctrl = new PolygonEditWidget(4); this.FlattenCurveChecked = true; this.BlurMethod = BlurMethod.RecursiveBlur; this.BlurRadius = 15; //ActualFont svgFont = svgFontStore.LoadFont("svg-LiberationSansFont", 300); ////PathWriter p01 = new PathWriter(); ////p01.MoveTo(0, 0); ////p01.LineTo(50, 100); ////p01.LineTo(100, 0); //////- ////p01.MoveTo(220, 10); ////p01.LineTo(50, 75); ////p01.LineTo(25, 15); ////p01.CloseFigure(); ////p01.Stop(); ////m_pathVxs = p01.Vxs; //var winFontGlyph = svgFont.GetGlyph('a'); //m_pathVxs = winFontGlyph.originalVxs;// typeFaceForLargeA.GetGlyphForCharacter('a'); //Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 100)); //m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs); //var curveFlattener = new CurveFlattener(); //m_pathVxs2 = curveFlattener.MakeVxs(m_pathVxs); //m_path_2 = new VertexStoreSnap(m_pathVxs2); //BoundingRect.GetBoundingRect(m_path_2, ref m_shape_bounds); //m_shadow_ctrl.SetXN(0, m_shape_bounds.Left); //m_shadow_ctrl.SetYN(0, m_shape_bounds.Bottom); //m_shadow_ctrl.SetXN(1, m_shape_bounds.Right); //m_shadow_ctrl.SetYN(1, m_shape_bounds.Bottom); //m_shadow_ctrl.SetXN(2, m_shape_bounds.Right); //m_shadow_ctrl.SetYN(2, m_shape_bounds.Top); //m_shadow_ctrl.SetXN(3, m_shape_bounds.Left); //m_shadow_ctrl.SetYN(3, m_shape_bounds.Top); //m_shadow_ctrl.LineColor = PixelFarm.Drawing.Color.FromArgb(0.3f, 0f, 0.3f, 0.5f); }
public override void OnRender() { if (Target is NodeDataControl) { Target = Controller.Instance.SelectedChapterDataControl.getPlayer(); } var npc = Target as NPCDataControl; var orientation = Orientation.S; if (SceneEditor.ElementReference != null) { var elementReference = SceneEditor.ElementReference as ElementReferenceDataControl; orientation = elementReference.Orientation; } if (npc != null) { var resourceOrientation = ""; switch (orientation) { case Orientation.S: resourceOrientation = NPC.RESOURCE_TYPE_STAND_DOWN; break; case Orientation.N: resourceOrientation = NPC.RESOURCE_TYPE_STAND_UP; break; case Orientation.O: resourceOrientation = NPC.RESOURCE_TYPE_STAND_LEFT; break; case Orientation.E: resourceOrientation = NPC.RESOURCE_TYPE_STAND_RIGHT; break; } var preview = GetCharacterTexturePreview(npc, resourceOrientation); if (preview) { var rect = new RectD(new Vector2d(-0.5f * preview.width, -preview.height), new Vector2d(preview.width, preview.height)); var adaptedRect = ComponentBasedEditor.Generic.ToRelative(rect.ToPoints()).ToRectD().ToRect(); GUI.DrawTexture(adaptedRect, preview, ScaleMode.ScaleToFit); } } }
private static void Center(MapEditor mapEditor, MapElementDataControl mapElement) { var extElementReference = mapElement as ExtElementRefDataControl; var geoElementReference = mapElement as GeoElementRefDataControl; if (extElementReference != null) { var sprite = ScenesWindowElementReference.ReferenceComponent.GetSprite(extElementReference); if (!sprite) { mapEditor.Center = (Vector2d)extElementReference.TransformManager["Position"]; } else { var texture = sprite.texture; var rect = new RectD(new Vector2d(-0.5f * texture.width, -texture.height), new Vector2d(texture.width, texture.height)); var previousTransformManager = mapEditor.PositionManager; mapEditor.PositionManager = extElementReference.TransformManager.GUIMapPositionManager; var relativeRect = mapEditor.ToRelative(rect.ToPoints()).ToRectD(); mapEditor.PositionManager = previousTransformManager; var boundingBox = relativeRect.ToPoints() .Select(p => mapEditor.PixelToLatLon(mapEditor.RelativeToAbsolute(p))) .ToArray() .ToRectD(); mapEditor.ZoomToBoundingBox(boundingBox); mapEditor.Center = boundingBox.Center; } } else if (geoElementReference != null) { var geoElement = geoElementReference.ReferencedDataControl as GeoElementDataControl; var geometry = geoElement.GMLGeometries[geoElement.SelectedGeometry]; mapEditor.ZoomToBoundingBox(geometry.BoundingBox); mapEditor.Center = geometry.BoundingBox.Center; } }
public override bool Update() { if (Event.current.type != EventType.MouseDown) { return(false); } var workingMapElement = Target as MapElementDataControl; var extElementReference = workingMapElement as ExtElementRefDataControl; if (extElementReference == null) { return(false); } var sprite = ScenesWindowElementReference.ReferenceComponent.GetSprite(extElementReference); if (!sprite) { return(false); } var texture = sprite.texture; var rect = new RectD(new Vector2d(-0.5 * texture.width, -texture.height), new Vector2d(texture.width, texture.height)); var adaptedRect = ComponentBasedEditor.Generic.ToRelative(rect.ToPoints()).ToRectD(); var textureContains = false; if (adaptedRect.Contains(Event.current.mousePosition.ToVector2d())) { double x = (Event.current.mousePosition.x - rect.Min.x) / rect.Width; double y = (Event.current.mousePosition.y - rect.Min.y) / rect.Height; textureContains = true; //textureContains = sprite.texture.GetPixel((int)(x * sprite.texture.width), sprite.texture.height - (int)(y * sprite.texture.height)).a > 0; } return(textureContains || extElementReference.TransformManager.GUIMapPositionManager.IsGizmosSelected(MapEditor.Current, rect.ToPoints())); }
internal void Initialize(IMap map, UnwrappedTileId tileId) { _relativeScale = 1 / Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x); _rect = Conversions.TileBounds(tileId); _canonicalTileId = tileId.Canonical; // previous implementation. This is done this way, custom for each tile // since we cannot tell where to place each tile according to the // center of the map (rather than find the center tile id, then offset // each of the tiles taking the x- and y- difference in the id //var position = new Vector3((float)(Rect.Center.x - map.CenterMercator.x), 0, (float)(Rect.Center.y - map.CenterMercator.y)); // zoom, x, y UnwrappedTileId centerTileId = CustomMap.Instance.CenterTileId; int xOffset = tileId.X - centerTileId.X; int yOffset = tileId.Y - centerTileId.Y; Vector3 position = new Vector3(xOffset * CustomMap.Instance.UnityTileLocalSize, 0, -yOffset * CustomMap.Instance.UnityTileLocalSize); gameObject.name = tileId.ToString(); transform.localPosition = position; gameObject.SetActive(true); gameObject.AddComponent <Interpolator>(); }
private NodeCreationCallback GetNodeCreator(NodeCreationCallback nodeCreator) { return((context, graph, location, parent) => { INode paletteNode = styleListBox.SelectedItem as INode; if (paletteNode != null) { if (paletteNode.Tag == null || !paletteNode.Tag.ToString().EndsWith("Label Container")) { INode newNode = nodeCreator(context, graph, location, parent); graph.SetStyle(newNode, paletteNode.Style); graph.SetNodeLayout(newNode, RectD.FromCenter(location, paletteNode.Layout.ToSizeD())); graph.SetIsGroupNode(newNode, paletteNode.Style is PanelNodeStyle); foreach (var label in paletteNode.Labels) { graph.AddLabel(newNode, label.Text, label.LayoutParameter, label.Style); } return newNode; } } return null; }); }
public RoundedRect(double left, double bottom, double right, double top, double radius) { bounds = new RectD(left, bottom, right, top); leftBottomRadius.x = radius; leftBottomRadius.y = radius; rightBottomRadius.x = radius; rightBottomRadius.y = radius; rightTopRadius.x = radius; rightTopRadius.y = radius; leftTopRadius.x = radius; leftTopRadius.y = radius; if (left > right) { bounds.Left = right; bounds.Right = left; } if (bottom > top) { bounds.Bottom = top; bounds.Top = bottom; } }
protected void ProcessSelection() { if (bpSelectionRectangle is null) { cmd_Clear_Selection(); return; } RectD SelectionRect = bpSelectionRectangle.BoundingRectD(padding: false); foreach (BPaintObject obj in ObjectsList) { RectD currObjBoundingRect = obj.BoundingRectD(padding: false); if (currObjBoundingRect.IsInRect(SelectionRect)) { obj.Selected = true; } else { obj.Selected = false; } } }
protected override GeneralPath GetOutline(INode node) { double width = Math.Min(node.Layout.Width, node.Layout.Height / BpmnConstants.ConversationWidthHeightRatio); double height = width * BpmnConstants.ConversationWidthHeightRatio; RectD bounds = new RectD(node.Layout.GetCenter().X - width / 2, node.Layout.GetCenter().Y - height / 2, width, height); var path = new GeneralPath(); path.MoveTo(0, 0.5); path.LineTo(0.25, 0); path.LineTo(0.75, 0); path.LineTo(1, 0.5); path.LineTo(0.75, 1); path.LineTo(0.25, 1); path.Close(); var transform = new Matrix2D(); transform.Translate(bounds.GetTopLeft()); transform.Scale(bounds.Width, bounds.Height); path.Transform(transform); return(path); }
/// <summary> /// Clips the edge list for the Delaunay triangulation to the specified bounds.</summary> /// <param name="bounds"> /// A <see cref="RectD"/> that indicates the clipping bounds for all <see /// cref="DelaunayEdges"/>.</param> /// <returns> /// An <see cref="Array"/> containing all <see cref="DelaunayEdges"/> which intersect the /// specified <paramref name="bounds"/>, as defined below.</returns> /// <remarks><para> /// <b>ClipDelaunayEdges</b> returns all <see cref="DelaunayEdges"/> whose corresponding /// <see cref="VoronoiEdges"/> element fulfils two conditions: /// </para><list type="bullet"><item> /// <see cref="VoronoiEdge.Site1"/> and <see cref="VoronoiEdge.Site2"/> both fall within the /// specified <paramref name="bounds"/>. /// </item><item> /// The line segment indicated by <see cref="VoronoiEdge.Vertex1"/> and <see /// cref="VoronoiEdge.Vertex2"/> intersects the specified <paramref name="bounds"/>. /// </item></list><para> /// In other words, <b>ClipDelaunayEdges</b> selects those <see cref="DelaunayEdges"/> that /// fall entirely within <paramref name="bounds"/>, and which connect two <see /// cref="VoronoiRegions"/> that share a common border within <paramref name="bounds"/>. /// </para></remarks> public LineD[] ClipDelaunayEdges(RectD bounds) { List <LineD> delaunayEdges = new List <LineD>(VoronoiEdges.Length); foreach (VoronoiEdge edge in VoronoiEdges) { PointD s1 = GeneratorSites[edge.Site1]; PointD s2 = GeneratorSites[edge.Site2]; if (bounds.Contains(s1) && bounds.Contains(s2)) { PointD v1 = VoronoiVertices[edge.Vertex1]; PointD v2 = VoronoiVertices[edge.Vertex2]; if (bounds.IntersectsWith(new LineD(v1, v2))) { delaunayEdges.Add(new LineD(s1, s2)); } } } return(delaunayEdges.ToArray()); }
/// <summary> /// Stores the initial layout of the node in case the user cancels the resizing. /// </summary> /// <param name="inputModeContext"></param> public void InitializeDrag(IInputModeContext inputModeContext) { if (reshapeHandler != null) { // if there is a reshape handler: initialize to // ensure proper handling of a parent group node reshapeHandler.InitializeReshape(inputModeContext); } initialLayout.Reshape(GetNodeBasedOrientedRectangle()); dummyLocation = initialLayout.GetAnchorLocation(); dummySize = initialLayout.GetSize(); initialRect = node.Layout.ToRectD(); portHandles.Clear(); var portContext = new DelegatingContext(inputModeContext); foreach (var port in node.Ports) { var portHandle = new DummyPortLocationModelParameterHandle(port); portHandle.InitializeDrag(portContext); portHandles.Add(portHandle); } }
public RoundedRect(double left, double bottom, double right, double top, double radius) { bounds = new RectD(left, bottom, right, top); leftBottomRadius.x = radius; leftBottomRadius.y = radius; rightBottomRadius.x = radius; rightBottomRadius.y = radius; rightTopRadius.x = radius; rightTopRadius.y = radius; leftTopRadius.x = radius; leftTopRadius.y = radius; if (left > right) { bounds.Left = right; bounds.Right = left; } if (bottom > top) { bounds.Bottom = top; bounds.Top = bottom; } }
public override void OnDrawingGizmosSelected() { var workingMapElement = Target as MapElementDataControl; var extElementReference = workingMapElement as ExtElementRefDataControl; if (extElementReference == null) { return; } var sprite = ScenesWindowElementReference.ReferenceComponent.GetSprite(extElementReference); if (!sprite) { return; } var texture = sprite.texture; var rect = new RectD(new Vector2d(-0.5f * texture.width, -texture.height), new Vector2d(texture.width, texture.height)); extElementReference.TransformManager.GUIMapPositionManager.OnDrawingGizmosSelected(MapEditor.Current, rect.ToPoints()); }
public override IVisual UpdateVisual(IRenderContext context, IVisual oldVisual) { var container = oldVisual as CombinedGroup; if (container == null || container.Children.Count != icons.Count) { return(CreateVisual(context)); } if (container.Size != Bounds.ToSizeD()) { // size changed -> we have to update the icons var iconBounds = new RectD(PointD.Origin, Bounds.ToSizeD()); int index = 0; foreach (var pathIcon in icons) { pathIcon.SetBounds(iconBounds); var oldPathVisual = container.Children[index]; var newPathVisual = pathIcon.UpdateVisual(context, oldPathVisual); if (oldPathVisual != newPathVisual) { container.Children.Remove(oldPathVisual); container.Children.Insert(index, newPathVisual); } index++; } container.Size = Bounds.ToSizeD(); } else if (container.TopLeft == Bounds.GetTopLeft()) { // bounds didn't change at all return(container); } container.TopLeft = Bounds.GetTopLeft(); container.Transform = new Matrix(1, 0, 0, 1, (float)Bounds.X, (float)Bounds.Y); return(container); }
// the type of button which has been hit private HitInfo GetHitInfo(PointD location) { RectD layout = node.Layout.ToRectD(); var classInfo = node.Tag as ClassInfo; PointD buttonLocation = layout.TopRight + new PointD(-ImageSize - 5, 5); RectD buttonRect = new RectD(buttonLocation, new SizeD(ImageSize, ImageSize)); if (buttonRect.Contains(location)) { return(HitInfo.ToggleAllDetails); } double height = umlStyle.GetHeaderSize(classInfo).Height; if (IsButtonHit(location, height)) { return(HitInfo.ToggleFieldDetails); } if (classInfo != null) { height += umlStyle.GetSectionSize(classInfo.Fields, "Fields").Height; } if (IsButtonHit(location, height)) { return(HitInfo.TogglePropertyDetails); } if (classInfo != null) { height += umlStyle.GetSectionSize(classInfo.Properties, "Properties").Height; } if (IsButtonHit(location, height)) { return(HitInfo.ToggleMethodDetails); } return(HitInfo.None); }
public BlurWithPainter() { //m_rbuf2 = new ReferenceImage(); m_shape_bounds = new RectD(); m_shadow_ctrl = new PolygonEditWidget(4); this.FlattenCurveChecked = true; this.BlurMethod = BlurMethod.RecursiveBlur; this.BlurRadius = 15; Font svgFont = SvgFontStore.LoadFont("svg-LiberationSansFont", 300); m_pathVxs = svgFont.GetGlyph('a').originalVxs;// typeFaceForLargeA.GetGlyphForCharacter('a'); Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 100)); m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs); var curveFlattener = new CurveFlattener(); m_path_2 = new VertexStoreSnap(curveFlattener.MakeVxs(m_pathVxs)); BoundingRect.GetBoundingRect(m_path_2, ref m_shape_bounds); m_shadow_ctrl.SetXN(0, m_shape_bounds.Left); m_shadow_ctrl.SetYN(0, m_shape_bounds.Bottom); m_shadow_ctrl.SetXN(1, m_shape_bounds.Right); m_shadow_ctrl.SetYN(1, m_shape_bounds.Bottom); m_shadow_ctrl.SetXN(2, m_shape_bounds.Right); m_shadow_ctrl.SetYN(2, m_shape_bounds.Top); m_shadow_ctrl.SetXN(3, m_shape_bounds.Left); m_shadow_ctrl.SetYN(3, m_shape_bounds.Top); m_shadow_ctrl.LineColor = ColorRGBAf.MakeColorRGBA(0f, 0.3f, 0.5f, 0.3f); }
/// <overloads> /// Creates an <see cref="Array"/> of random <see cref="PointD"/> coordinates within the /// specified area.</overloads> /// <summary> /// Creates an <see cref="Array"/> of random <see cref="PointD"/> coordinates within the /// specified area.</summary> /// <param name="count"> /// The number of <see cref="PointD"/> coordinates to create.</param> /// <param name="bounds"> /// The coordinates of the area containing all <see cref="PointD"/> coordinates.</param> /// <returns> /// An <see cref="Array"/> containing <paramref name="count"/> randomly created <see /// cref="PointD"/> coordinates.</returns> /// <exception cref="ArgumentOutOfRangeException"><para> /// <paramref name="count"/> is less than zero. /// </para><para>-or-</para><para> /// <paramref name="bounds"/> contains a <see cref="RectD.Width"/> or <see /// cref="RectD.Height"/> that is equal to or less than zero.</para></exception> /// <remarks> /// The returned <see cref="Array"/> is unsorted and may contain duplicate <see /// cref="PointD"/> coordinates.</remarks> public static PointD[] RandomPoints(int count, RectD bounds) { if (count < 0) { ThrowHelper.ThrowArgumentOutOfRangeException( "count", count, Strings.ArgumentNegative); } if (bounds.Width <= 0 || bounds.Height <= 0) { ThrowHelper.ThrowArgumentOutOfRangeException( "bounds", bounds, Strings.ArgumentCoordinatesInvalid); } PointD[] points = new PointD[count]; for (int i = 0; i < points.Length; i++) { points[i] = new PointD( bounds.X + MersenneTwister.Default.NextDouble() * bounds.Width, bounds.Y + MersenneTwister.Default.NextDouble() * bounds.Height); } return(points); }
/// <summary> /// Creates a node of the specified type. /// </summary> /// <remarks> /// The method will specify the ports that the node should have based on its type. /// </remarks> private void CreateNode(IGraph graph, PointD location, LogicGateType type, string label = null, SizeD?size = null) { RectD newBounds = RectD.FromCenter(location, graph.NodeDefaults.Size); INode node; if (type >= LogicGateType.Timer) { node = graph.CreateNode(RectD.FromCenter(location, (SizeD)size), new ShapeNodeStyle { Pen = new Pen(Brushes.Black, 2) }); } else { node = graph.CreateNode(newBounds, new LogicGateNodeStyle { GateType = type }); } if (label != null) { graph.AddLabel(node, label, InteriorLabelModel.Center); } var portDescriptors = PortDescriptor.CreatePortDescriptors(type); // use relative port locations var model = new FreeNodePortLocationModel(); // add ports for all descriptors using the descriptor as the tag of the port foreach (var descriptor in portDescriptors) { // use the descriptor's location as offset var portLocationModelParameter = model.CreateParameter(PointD.Origin, new PointD(descriptor.X, descriptor.Y)); graph.AddPort(node, portLocationModelParameter, tag: descriptor); } }
// Rectangle to quadrilateral public Perspective(RectD r, double[] quad) : this(r.Left, r.Bottom, r.Right, r.Top, quad) { }
public RoundedRect(RectD bounds, double r) : this(bounds.Left, bounds.Bottom, bounds.Right, bounds.Top, r) { }
public static bool GetBoundingRect(VertexStore vxs, int[] gi, int num, out RectD boundingRect) { return GetBoundingRect(vxs, gi, num, out boundingRect.Left, out boundingRect.Bottom, out boundingRect.Right, out boundingRect.Top); }
public override void Invalidate(RectD rectToInvalidate) { m_specific.Invalidate(new Rectangle( (int)System.Math.Floor(rectToInvalidate.Left), (int)System.Math.Floor(Height - rectToInvalidate.Top), (int)System.Math.Ceiling(rectToInvalidate.Width), (int)System.Math.Ceiling(rectToInvalidate.Height))); m_specific.m_WindowContentNeedsRedraw = true; }
public SimpleVertexSourceWidget(double x1, double y1, double x2, double y2) { Bounds = new RectD(x1, y1, x2, y2); }
public virtual void Invalidate(RectD rectToInvalidate) { Parent.Invalidate(rectToInvalidate); }
public RoundedRect(RectD bounds, double r) : this(bounds.x1, bounds.y1, bounds.x2, bounds.y2, r) { }
protected override bool IsInBox(IInputModeContext context, RectD rectangle, INode node) { // return only box containment test of wrapped - we don't want the decorator to be marquee selectable return(wrapped.Renderer.GetMarqueeTestable(node, wrapped).IsInBox(context, rectangle)); }
/// <summary> /// /// </summary> /// <param name="rectToTransform"> /// A <see cref="rect_d"/> /// </param> public void Transform(ref RectD rectToTransform) { Transform (ref rectToTransform.x1, ref rectToTransform.y1); Transform (ref rectToTransform.x2, ref rectToTransform.y2); }