Ejemplo n.º 1
0
 /// <summary>
 /// Creates a rectangle inside of another rectangle.
 /// </summary>
 /// <returns>A rectangle at coords x,y -> x+width,y+height inside of rel.</returns>
 /// <param name="rel">The relative rectangle.</param>
 /// <param name="x">The local x coordinate of the new rectangle.</param>
 /// <param name="y">The local y coordinate of the new rectangle..</param>
 /// <param name="width">The width of the new rectangle.</param>
 /// <param name="height">The height of the new rectangle.</param>
 /// <param name="mode">Defaultss to floating.</param>
 Rect relRec(Rect rel, float x, float y, float width, float height, relRecMode mode = relRecMode.floating)
 {
     if (mode == relRecMode.floating)
     {
         return(new Rect(rel.x + x, rel.y + y, width, height));
     }
     else if (mode == relRecMode.singleEdgeClamp)
     {
         // Clamps RHS edge to within rel.
         return(new Rect(rel.x + x, rel.y + y,
                         (x + width) > rel.width ? rel.width - x : width,
                         (y + height) > rel.height ? rel.height - y : height));
     }
     else         /*clamp*/
     {
         return(new Rect(rel.x + x <0 ? 0 : rel.x + x,
                                    rel.y + y <0 ? 0 : rel.y + y,
                                               (x + width)> rel.width ? rel.width - x : width,
                                    (y + height)> rel.height ? rel.height - y : height));
     }
 }
Ejemplo n.º 2
0
 Rect relRec(Rect rel, Rect input, relRecMode mode = relRecMode.floating)
 {
     return(relRec(rel, input.x, input.y, input.width, input.height, mode));
 }