MCPcopy Create free account
hub / github.com/SimHacker/micropolis / RectToArea

Function RectToArea

micropolis-activity/src/tk/tkrectov.c:687–723  ·  view source on GitHub ↗

ARGSUSED */

(canvasPtr, itemPtr, areaPtr)

Source from the content-addressed store, hash-verified

685 * -1 is returned if the item is entirely outside the area
686 * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
687 * inside the given area.
688 *
689 * Side effects:
690 * None.
691 *
692 *--------------------------------------------------------------
693 */
694
695 /* ARGSUSED */
696static int
697RectToArea(canvasPtr, itemPtr, areaPtr)
698 Tk_Canvas *canvasPtr; /* Canvas containing item. */
699 Tk_Item *itemPtr; /* Item to check against rectangle. */
700 double *areaPtr; /* Pointer to array of four coordinates
701 * (x1, y1, x2, y2) describing rectangular
702 * area. */
703{
704 register RectOvalItem *rectPtr = (RectOvalItem *) itemPtr;
705 double halfWidth;
706
707 halfWidth = rectPtr->width/2.0;
708 if (rectPtr->outlineGC == None) {
709 halfWidth = 0.0;
710 }
711
712 if ((areaPtr[2] <= (rectPtr->bbox[0] - halfWidth))
713 || (areaPtr[0] >= (rectPtr->bbox[2] + halfWidth))
714 || (areaPtr[3] <= (rectPtr->bbox[1] - halfWidth))
715 || (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) {
716 return -1;
717 }
718 if ((rectPtr->fillGC == None) && (rectPtr->outlineGC != None)
719 && (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth))
720 && (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth))
721 && (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth))
722 && (areaPtr[3] <= (rectPtr->bbox[3] - halfWidth))) {
723 return -1;
724 }
725 if ((areaPtr[0] <= (rectPtr->bbox[0] - halfWidth))
726 && (areaPtr[1] <= (rectPtr->bbox[1] - halfWidth))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected