static public HPoint FlattenPoint(HPoint _pin, bool roundUp) { HPoint newP = _pin.Clone(); if (newP.X == newP.Y) { return(newP); } if (_pin.X > _pin.Y) { if (roundUp) { newP.Y = newP.X; } else { newP.X = newP.Y; } } else { if (!roundUp) { newP.Y = newP.X; } else { newP.X = newP.Y; } } return(newP); }
public HPoint AddY(params int[] P) { HPoint PBase = Clone(); foreach (int RefPoint in P) { PBase.Y += RefPoint; } return(PBase); }
public HPoint NegY(params HPoint[] P) { HPoint PBase = Clone(); foreach (HPoint RefPoint in P) { PBase.Y -= RefPoint.Y; } return(PBase); }
public HPoint NegY(params int[] P) { HPoint PBase = Clone(); foreach (int Ref in P) { PBase.Y -= Ref; } return(PBase); }
public HPoint AddX(params HPoint[] P) { HPoint PBase = Clone(); foreach (HPoint RefPoint in P) { PBase.X += RefPoint.X; } return(PBase); }
static public HPoint Fit(HPoint dest, HPoint source, scaleFlags f) { HPoint HX = dest / source; if (f == scaleFlags.autoScale) { return((HX.Y > HX.X) ? source * HX.X : source *HX.Y); } else { return((f == scaleFlags.sWidth) ? source * HX.X : source *HX.Y); } }
/// <summary>use Flat or flatten calls.</summary> public HPoint ScaleTo(HPoint point) { if (point.X == X && point.Y == Y) { throw new InvalidOperationException("you mucker"); } System.Windows.Forms.MessageBox.Show(string.Format("X: {1},Y: {0}", Y / point.Y, X / point.X)); if (X > point.Y) { Global.cstat(ConsoleColor.Red, "X is BIGGER"); } else { Global.cstat(ConsoleColor.Red, "X is SMALLER"); } return(this); }
public HPoint Divide(params HPoint[] P) { if (P.Length == 0) { throw new ArgumentException("there is no data!"); } if (P.Length == 1) { return(new HPoint(X, Y) / P[0]); } HPoint NewPoint = new HPoint(X, Y) / P[0]; for (int i = 1; i < P.Length; i++) { NewPoint /= P[i]; } return(NewPoint); }
public HPoint Multiply(params float[] P) { if (P.Length == 0) { throw new ArgumentException("there is no data!"); } if (P.Length == 1) { return(new HPoint(X, Y) * P[0]); } HPoint NewPoint = new HPoint(X, Y) * P[0]; for (int i = 1; i < P.Length; i++) { NewPoint *= P[i]; } return(NewPoint); }
public bool IsYEq(HPoint P) { return(Y == P.Y); }
public bool IsXEq(HPoint P) { return(X == P.X); }
public bool IsYLEq(HPoint P) { return(IsYG(P) & IsYG(P)); }
/// <summary>same as FlattenPoint overload without boolean</summary> static public HPoint FlattenDown(HPoint _pin) { return(FlattenPoint(_pin)); }
public HPoint GetRation(HPoint dst) { return(dst / this); }
public bool IsYL(HPoint P) { return(Y < P.Y); }
public bool IsXL(HPoint P) { return(X < P.X); }
public bool IsYG(HPoint P) { return(Y > P.Y); }
public bool IsXG(HPoint P) { return(X > P.X); }
/// <summary>Flattens the calling point</summary> public void Flatten(bool roundUp) { HPoint f = Flat(roundUp); this.X = f.X; this.Y = f.Y; f = null; }
public HPoint GetScaledRation(HPoint dst) { return(this * (dst / this)); }
public void CopyPoint(HPoint inPoint) { X = inPoint.X; Y = inPoint.Y; }
/* /// todo: replace this with something more accurate and faster * /// use Boxed as the default scale flag * static public HPoint Fit(Point dest, Point source, scaleFlags sf) * { * HPoint skaler = new HPoint(); * float tr=0; * string omax,cmax; * if (source.X >= source.Y) omax = "width"; else omax="height"; * if (dest.X >= dest.Y) cmax = "width"; else cmax="height"; * switch (cmax) * { * case "width": if (omax==cmax) sf = scaleFlags.sWidth; else sf = scaleFlags.sHeight; break; * case "height": if (omax==cmax) sf = scaleFlags.sHeight; else sf = scaleFlags.sWidth; break; * } * skale: * switch (sf) * { * case scaleFlags.sHeight: * if ( source.Y > dest.Y ) { skaler.Y = dest.Y; tr = (float)((float)dest.Y / (float)source.Y); skaler.X = (int)Math.Round(source.X*tr); } * else skaler = source; break; * case scaleFlags.sWidth: * if ( source.X > dest.X ) { skaler.X = dest.X; tr = (float)((float)dest.X / (float)source.X); skaler.Y = (int)Math.Round(source.Y*tr); } * else skaler = source; break; * } * if ((skaler.X > dest.X) | (skaler.Y > dest.Y)) * { * switch (sf) * { * case scaleFlags.sWidth: sf = scaleFlags.sHeight; goto skale; * case scaleFlags.sHeight: sf = scaleFlags.sWidth; goto skale; * } * } * return skaler; * }*/ #endregion #endregion #region Help // public XPoint Translate(XPoint offset, XPoint zoom, bool ZoomAfterOffset, bool MultiplyOffset) // { // return (ZoomAfterOffset) ? (this+((MultiplyOffset) ? offset*zoom : offset ))*zoom : (this*zoom)+((MultiplyOffset) ? offset*zoom : offset ); // } /// In most scenarios (reminding my self of my application...) /// zoom is applied by the renderer, so we shouldn't need it? /// I could be wrong. We could be zoomed in to draw. public HPoint Translate(HPoint offset, HPoint zoom) { return((this + offset) * zoom); }
public bool IsLEq(HPoint p) { return((X <= p.X) && (Y <= p.Y)); }
public bool IsGEq(HPoint p) { return((X >= p.X) && (Y >= p.Y)); }
static public HPoint FlattenPoint(HPoint _pin) { return(FlattenPoint(_pin, false)); }
public bool IsXLEq(HPoint P) { return(IsXG(P) & IsXG(P)); }
static public HPoint FlattenUp(HPoint _pin) { return(FlattenPoint(_pin, true)); }
/// scales src to dest static public HPoint Fit(HPoint dest, HPoint source) { return(Fit(dest, source, scaleFlags.autoScale)); }