public Point2I _normalPoint(Point2I nPoint) { int width_ = mWidth * 2 - 3; int height_ = mHeight * 3 - 3; Point2I point_ = new Point2I(nPoint); int x_ = point_._getX(); if (x_ < 3) { point_._setX(3); } if (x_ > width_) { point_._setX(width_); } int y_ = point_._getY(); if (y_ < 3) { point_._setY(3); } if (y_ > height_) { point_._setY(height_); } return point_; }
public static Point2I operator -(Point2I nLeft, Point2I nRight) { Point2I result_ = new Point2I(); result_._setX(nLeft._getX() - nRight._getX()); result_._setY(nLeft._getY() - nRight._getY()); return result_; }
public static Point2I operator +(Point2I nLeft, Size2I nRight) { Point2I result_ = new Point2I(); result_._setX(nLeft._getX() + nRight._getWidth()); result_._setY(nLeft._getY() + nRight._getHeight()); return result_; }
public Point2I _begPoint(int nLength = 16) { Point2I point_ = this._vector(); float length_ = this._length(); if (length_ < nLength) { return null; } float x_ = point_._getX() / length_; float y_ = point_._getY() / length_; Point2I result_ = new Point2I(); result_._setX((int)(nLength * x_ + mBeg._getX())); result_._setY((int)(nLength * y_ + mBeg._getY())); return result_; }
public Rect2I(Point2I nPoint, Size2I nSize) { Point2I point_ = new Point2I(); point_._setX(nPoint._getX() + nSize._getWidth()); point_._setY(nPoint._getY() + nSize._getHeight()); __tuple<Point2I, Point2I> tuple_ = nPoint._minMax(point_); Point2I min_ = tuple_._get_0(); Point2I max_ = tuple_._get_1(); Size2I size_ = new Size2I(); size_._setWidth(max_._getX() - min_._getX()); size_._setHeight(max_._getY() - min_._getY()); mPoint = new Point2I(min_); mSize = new Size2I(size_); }
public Rect2I(int nX, int nY, int nWidth, int nHeight) { Point2I point0_ = new Point2I(nX, nY); Point2I point_ = new Point2I(); point_._setX(nX + nWidth); point_._setY(nY + nHeight); __tuple<Point2I, Point2I> tuple_ = point0_._minMax(point_); Point2I min_ = tuple_._get_0(); Point2I max_ = tuple_._get_1(); Size2I size_ = new Size2I(); size_._setWidth(max_._getX() - min_._getX()); size_._setHeight(max_._getY() - min_._getY()); mPoint = new Point2I(min_); mSize = new Size2I(size_); }
public Point2I _getRTPoint() { Point2I result_ = new Point2I(); result_._setX(this._getX() + this._getWidth()); result_._setY(this._getY()); return result_; }
public Point2I _getLBPoint() { Point2I result_ = new Point2I(); result_._setX(this._getX()); result_._setY(this._getY() + this._getHeight()); return result_; }
public Point2I _connectPoint(Point2I nPoint) { Point2I result_ = new Point2I(); Point2I center_ = this._centerPoint(); if (center_._getX() > nPoint._getX()) { result_._setX(mPoint._getX()); } else { result_._setX(mPoint._getX() + mSize._getWidth()); } result_._setY(center_._getY()); return result_; }
public Point2I _connectPoint(Point2I nBeg, Point2I nEnd) { if (this._contain(nEnd)) { return nEnd; } if (!this._contain(nBeg)) { return nEnd; } Point2I result_ = new Point2I(); int x0_ = mPoint._getX(); int x1_ = x0_ + mSize._getWidth(); int y0_ = mPoint._getY(); int y1_ = y0_ + mSize._getHeight(); if (nEnd._getY() < this._centerY()) { if (nBeg._getY() == y0_) { result_._setPoint(nBeg); return result_; } float temp_ = this._connectPointY(nBeg, nEnd, y0_); if (temp_ > x0_ && temp_ < x1_) { int int_ = (int)temp_; result_._setX(int_); result_._setY(y0_); return result_; } } else { if (nBeg._getY() == y1_) { result_._setPoint(nBeg); return result_; } float temp_ = this._connectPointY(nBeg, nEnd, y1_); if (temp_ > x0_ && temp_ < x1_) { int int_ = (int)temp_; result_._setX(int_); result_._setY(y1_); return result_; } } if (nEnd._getX() > nBeg._getX()) { result_._setX(x1_); } else { result_._setX(x0_); } if (nEnd._getY() > nBeg._getY()) { result_._setY(y1_); } else { result_._setY(y0_); } return result_; }
public __tuple<Point2I, Point2I> _minMax(int nX, int nY) { Point2I min_ = new Point2I(); Point2I max_ = new Point2I(); if (nX > mX) { min_._setX(mX); max_._setX(nX); } else { min_._setX(nX); max_._setX(mX); } if (nY > mY) { min_._setY(mY); max_._setY(nY); } else { min_._setY(nY); max_._setY(mY); } return new __tuple<Point2I, Point2I>(min_, max_); }
public __tuple<Status_, Point2I> _borderPoint(Point2I nPoint) { Point2I center_ = _centerPoint(); Point2I point_ = new Point2I(); point_._setX(nPoint._getX() - center_._getX()); point_._setY(nPoint._getY() - center_._getY()); long x_ = point_._getX() * mSize._getHeight(); long y_ = point_._getY() * mSize._getWidth(); Point2I result_ = new Point2I(); Quadrant_ quadrant_ = _getQuadrant(nPoint); // | // | // _______0_______ // | // | // | if (Quadrant_.mCenter_ == quadrant_) { return new __tuple<Status_, Point2I>(Status_.mSucess_, center_); } // | // | // _______|_______1 // | // | // | else if (Quadrant_.mUdx_ == quadrant_) { result_._setX(mPoint._getX() + mSize._getWidth()); result_._setY(center_._getY()); return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // | // | 2 // _______|_______ // | // | // | else if (Quadrant_.mFirst_ == quadrant_) { y_ = -y_; if (x_ > y_) { result_._setX(mPoint._getX() + mSize._getWidth()); long temp_ = y_ / 2; y_ = (int)(temp_ / point_._getX()); result_._setY((int)(center_._getY() - y_)); } else if (x_ == y_) { result_._setX(mPoint._getX() + mSize._getWidth()); result_._setY(mPoint._getY()); } else { result_._setY(mPoint._getY()); long temp_ = x_ / 2; x_ = (int)(temp_ / point_._getY()); result_._setX((int)(center_._getX() - x_)); } return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // 3 // | // | // _______|_______ // | // | // | else if (Quadrant_.mUdy_ == quadrant_) { result_._setX(center_._getX()); result_._setY(mPoint._getY()); return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // | // 4 | // _______|_______ // | // | // | else if (Quadrant_.mSecond_ == quadrant_) { x_ = -x_; y_ = -y_; if (x_ > y_) { result_._setX(mPoint._getX()); long temp_ = y_ / 2; y_ = (int)(temp_ / point_._getX()); result_._setY((int)(center_._getY() + y_)); } else if (x_ == y_) { result_._setX(mPoint._getX()); result_._setY(mPoint._getY()); } else { result_._setY(mPoint._getY()); long temp_ = x_ / 2; x_ = (int)(temp_ / point_._getY()); result_._setX((int)(center_._getX() + x_)); } return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // | // | // 5_______|_______ // | // | // | else if (Quadrant_.mSdx_ == quadrant_) { result_._setX(mPoint._getX()); result_._setY(center_._getY()); return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // | // | // _______|_______ // | // 6 | // | if (Quadrant_.mThree_ == quadrant_) { x_ = -x_; if (x_ > y_) { result_._setX(mPoint._getX()); long temp_ = y_ / 2; y_ = (int)(temp_ / point_._getX()); result_._setY((int)(center_._getY() - y_)); } else if (x_ == y_) { result_._setX(mPoint._getX()); result_._setY(mPoint._getY() + mSize._getHeight()); } else { result_._setY(mPoint._getY() + mSize._getHeight()); long temp_ = x_ / 2; x_ = (int)(temp_ / point_._getY()); result_._setX((int)(center_._getX() - x_)); } return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // | // | // _______|_______ // | // | // | // 7 if (Quadrant_.mSdy_ == quadrant_) { result_._setX(center_._getX()); result_._setY(mPoint._getY() + mSize._getHeight()); return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } // | // | // _______|_______ // | // | 8 // | else if (Quadrant_.mFour_ == quadrant_) { if (x_ > y_) { result_._setX(mPoint._getX() + mSize._getWidth()); long temp_ = y_ / 2; y_ = (int)(temp_ / point_._getX()); result_._setY((int)(center_._getY() + y_)); } else if (x_ == y_) { result_._setX(mPoint._getX() + mSize._getWidth()); result_._setY(mPoint._getY() + mSize._getHeight()); } else { result_._setY(mPoint._getY() + mSize._getHeight()); long temp = x_ / 2; x_ = (int)(temp / point_._getY()); result_._setX((int)(center_._getX() + x_)); } return new __tuple<Status_, Point2I>(Status_.mSucess_, result_); } else { return new __tuple<Status_, Point2I>(Status_.mError_, result_); } }
public Point2I _vectorTo(int nX, int nY) { Point2I result_ = new Point2I(); result_._setX(nX - mX); result_._setY(nY - mY); return result_; }
public Point2I _vectorFrom(int nX, int nY) { Point2I result_ = new Point2I(); result_._setX(mX - nX); result_._setY(mY - nY); return result_; }
public static void _drawPull(Rect2I nRect, Graphics nGraphics, RGB nRGB, int nSize = 4) { Point2I lefttop_ = nRect._getPoint(); lefttop_._offset(-nSize, -nSize); Point2I righttop_ = nRect._getRTPoint(); righttop_._offset(nSize, -nSize); Point2I leftbottom_ = nRect._getLBPoint(); leftbottom_._offset(-nSize, nSize); Point2I rightbottom_ = nRect._getRBPoint(); rightbottom_._offset(nSize, nSize); Point2I lt_ = new Point2I(); lt_._setX(nRect._getX() - nSize); lt_._setY(nRect._centerY() - 3); Point2I lb_ = new Point2I(); lb_._setX(nRect._getX() - nSize); lb_._setY(nRect._centerY() + 3); Point2I lp_ = new Point2I(); lp_._setX(nRect._getX() - 4); lp_._setY(nRect._centerY()); Point2I rt_ = new Point2I(); rt_._setX(nRect._getRTX() + nSize); rt_._setY(nRect._centerY() - 3); Point2I rb_ = new Point2I(); rb_._setX(nRect._getRTX() + nSize); rb_._setY(nRect._centerY() + 3); Point2I rp_ = new Point2I(); rp_._setX(nRect._getRTX() + 4); rp_._setY(nRect._centerY()); Line2I top_ = new Line2I(lefttop_, righttop_); _drawBroken(top_, nGraphics, nRGB); Line2I bottom_ = new Line2I(leftbottom_, rightbottom_); _drawBroken(bottom_, nGraphics, nRGB); Line2I left0_ = new Line2I(lefttop_, lt_); _drawBroken(left0_, nGraphics, nRGB); Line2I left1_ = new Line2I(leftbottom_, lb_); _drawBroken(left1_, nGraphics, nRGB); Line2I right0_ = new Line2I(righttop_, rt_); _drawBroken(right0_, nGraphics, nRGB); Line2I right1_ = new Line2I(rightbottom_, rb_); _drawBroken(right1_, nGraphics, nRGB); _drawEllipse(lp_, nGraphics, nRGB); _drawEllipse(rp_, nGraphics, nRGB); }
__tuple<Point2I, Size2I> _moveInfo(Point2I nPoint) { Point2I vector_ = nPoint._vectorFrom(mMouseDown); __tuple<Point2I, Point2I> tuple_ = this._moveMinMax(); Point2I min_ = tuple_._get_0(); Point2I max_ = tuple_._get_1(); Size2I size_ = new Size2I(); int width_ = max_._getX() - min_._getX(); int height_ = max_._getY() - min_._getY(); size_._setWidth(width_); size_._setHeight(height_); Point2I begin_ = new Point2I(); if (vector_._getX() > 0) { begin_._setX(max_._getX()); } else { begin_._setX(min_._getX()); } if (vector_._getY() > 0) { begin_._setY(max_._getY()); } else { begin_._setY(min_._getY()); } Point2I end_ = begin_ + vector_; ScreenSingleton screenSingleton_ = __singleton<ScreenSingleton>._instance(); end_ = screenSingleton_._normalPoint(end_); vector_ = end_ - begin_; return new __tuple<Point2I, Size2I>(vector_, size_); }
public Point2I _centerPoint() { Point2I result_ = new Point2I(); int x_ = mSize._getWidth(); int y_ = mSize._getHeight(); x_ /= 2; y_ /= 2; result_._setX(mPoint._getX() + x_); result_._setY(mPoint._getY() + y_); return result_; }