public virtual void Scale() { Vector2 newPosition = _boundbox += Program.Instance.GetMouseCanvasPosition() - _scalePosition; _scalePosition = Program.Instance.GetMouseCanvasPosition(); BoundingBoxPoint current = CurrentBoundingBox; bool[] manipulateAnchors = current.ManipulateXyAnchor; if (manipulateAnchors[0]) { DownLeftAnchor = new Vector2(newPosition.x, DownLeftAnchor.y); } if (manipulateAnchors[1]) { DownLeftAnchor = new Vector2(DownLeftAnchor.x, newPosition.y); } if (manipulateAnchors[2]) { UpRightAnchor = new Vector2(newPosition.x, UpRightAnchor.y); } if (manipulateAnchors[3]) { UpRightAnchor = new Vector2(UpRightAnchor.x, newPosition.y); } SetPoints(); _boundbox = CurrentBoundingBox.Position; ShowBoundingRect(); }
bool CheckDistance(Vector2 another, BoundingBoxPoint boxPoint, int index) { if (Vector2.Distance(boxPoint.Position, another) <= 5f) { CurrentBoundingBox = boxPoint; Program.Instance.SetBoundingBoxPoint(index); return(true); } return(false); }
public virtual void Init() { _boundingBoxPoints[0] = new BoundingBoxPoint(new bool[] { true, true, false, false }); _boundingBoxPoints[1] = new BoundingBoxPoint(new bool[] { false, false, true, true }); _boundingBoxPoints[2] = new BoundingBoxPoint(new bool[] { true, false, false, true }); _boundingBoxPoints[3] = new BoundingBoxPoint(new bool[] { false, true, true, false }); _boundingBoxPoints[4] = new BoundingBoxPoint(new bool[] { true, false, false, false }); _boundingBoxPoints[5] = new BoundingBoxPoint(new bool[] { false, true, false, false }); _boundingBoxPoints[6] = new BoundingBoxPoint(new bool[] { false, false, true, false }); _boundingBoxPoints[7] = new BoundingBoxPoint(new bool[] { false, false, false, true }); _boundingBoxRenderer.BoundingBoxPoints = _boundingBoxPoints; SetPoints(); }