protected void PushScissor() { var wScissor = new Scissor(AbsoluteLocation, Size).Merge(mScissorStack.FirstOrDefault()); wScissor.Apply(); mScissorStack.Push(wScissor); }
public Scissor Merge(Scissor scissor) { if (scissor == null) { return(this); } var wX = Math.Max(mLocation.X, scissor.mLocation.X); var wY = Math.Max(mLocation.Y, scissor.mLocation.Y); var wTopLeft = new Vector2(wX, wY); var wThisBottomRight = mLocation + mSize; var wBottomRight = scissor.mLocation + scissor.mSize; wX = Math.Min(wThisBottomRight.X, wBottomRight.X); wY = Math.Min(wThisBottomRight.Y, wBottomRight.Y); wBottomRight = new Vector2(wX, wY); var wWidth = wBottomRight.X - wTopLeft.X; var wHeigth = wBottomRight.Y - wTopLeft.Y; var wSize = new Vector2(wWidth, wHeigth); return(new Scissor(wTopLeft, wSize)); }