src/boxbasic.c
BOX *
boxCreate(l_int32  x,
          l_int32  y,
          l_int32  w,
          l_int32  h)
{
BOX  *box;

    PROCNAME("boxCreate");

    if (w < 0 || h < 0)
        return (BOX *)ERROR_PTR("w and h not both >= 0", procName, NULL);
    if (x < 0) {  /* take part in +quad */
        w = w + x;
        x = 0;
        if (w <= 0)
            return (BOX *)ERROR_PTR("x < 0 and box off +quad", procName, NULL);
    }
    if (y < 0) {  /* take part in +quad */
        h = h + y;
        y = 0;
        if (h <= 0)
            return (BOX *)ERROR_PTR("y < 0 and box off +quad", procName, NULL);
    }

    if ((box = (BOX *)CALLOC(1, sizeof(BOX))) == NULL)
        return (BOX *)ERROR_PTR("box not made", procName, NULL);
    boxSetGeometry(box, x, y, w, h);
    box->refcount = 1;

    return box;
}
/*!
 *  boxCreate()
 *
 *      Input:  x, y, w, h
 *      Return: box, or null on error
 *
 *  Notes:
 *      (1) This clips the box to the +quad.  If no part of the
 *          box is in the +quad, this returns NULL.
 *      (2) We allow you to make a box with w = 0 and/or h = 0.
 *          This does not represent a valid region, but it is useful
 *          as a placeholder in a boxa for which the index of the
 *          box in the boxa is important.  This is an atypical
 *          situation; usually you want to put only valid boxes with
 *          nonzero width and height in a boxa.  If you have a boxa
 *          with invalid boxes, the accessor boxaGetValidBox()
 *          will return NULL on each invalid box.
 *      (3) If you want to create only valid boxes, use boxCreateValid(),
 *          which returns NULL if either w or h is 0.
 */
boxCreate()
Input:  x, y, w, h
Return: box, or null on error

(1) This clips the box to the +quad.  If no part of the
box is in the +quad, this returns NULL.
(2) We allow you to make a box with w = 0 and/or h = 0.
This does not represent a valid region, but it is useful
as a placeholder in a boxa for which the index of the
box in the boxa is important.  This is an atypical
situation; usually you want to put only valid boxes with
nonzero width and height in a boxa.  If you have a boxa
with invalid boxes, the accessor boxaGetValidBox()
will return NULL on each invalid box.
(3) If you want to create only valid boxes, use boxCreateValid(),
which returns NULL if either w or h is 0.
boxCreate () Input : x y w h Return : box or null on error ( 1 ) This clips the box to the + quad . If no part of the box is in the + quad this returns NULL . ( 2 ) We allow you to make a box with w = 0 and / or h = 0 . This does not represent a valid region but it is useful as a placeholder in a boxa for which the index of the box in the boxa is important . This is an atypical situation ; usually you want to put only valid boxes with nonzero width and height in a boxa . If you have a boxa with invalid boxes the accessor boxaGetValidBox () will return NULL on each invalid box . ( 3 ) If you want to create only valid boxes use boxCreateValid () which returns NULL if either w or h is 0 .
BOX *
boxCreate(l_int32  x,
          l_int32  y,
          l_int32  w,
          l_int32  h)
{
BOX  *box;
    PROCNAME("boxCreate");
    if (w < 0 || h < 0)
        return (BOX *)ERROR_PTR("w and h not both >= 0", procName, NULL);
    if (x < 0) {  
        w = w + x;
        x = 0;
        if (w <= 0)
            return (BOX *)ERROR_PTR("x < 0 and box off +quad", procName, NULL);
    }
    if (y < 0) {  
        h = h + y;
        y = 0;
        if (h <= 0)
            return (BOX *)ERROR_PTR("y < 0 and box off +quad", procName, NULL);
    }
    if ((box = (BOX *)CALLOC(1, sizeof(BOX))) == NULL)
        return (BOX *)ERROR_PTR("box not made", procName, NULL);
    boxSetGeometry(box, x, y, w, h);
    box->refcount = 1;
    return box;
}
BOX * boxCreate ( l_int32 x , l_int32 y , l_int32 w , l_int32 h ) { BOX * box ; PROCNAME ( " " ) ; if ( w < 0 || h < 0 ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; if ( x < 0 ) { w = w + x ; x = 0 ; if ( w <= 0 ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; } if ( y < 0 ) { h = h + y ; y = 0 ; if ( h <= 0 ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; } if ( ( box = ( BOX * ) CALLOC ( 1 , sizeof ( BOX ) ) ) == NULL ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; boxSetGeometry ( box , x , y , w , h ) ; box -> refcount = 1 ; return box ; }
boxCreate()
      Input:  x, y, w, h
      Return: box, or null on error
boxCreate () Input : x y w h Return : box or null on error
/* take part in +quad */ /* take part in +quad */