PtTranslateRect

PtTranslateRect — changes the position of PhRect class instances.

Syntax

TranslateRect (original_rect, translation_point)

		

Arguments

original_rect

An instance of a PhRect class.

translation_rect

An instance of a PhPoint class.

Returns

The original_rect instance of the PhRect class with its members modified by the amount of the translation_point.

Description

This function allows users to create instances of the PhPoint class to act as modifiers to PhRect instances. Mathematically, the result of the function (result), in relation to the original PhRect instance (original) and the translation (point) is:

    result.lr.x = original.lr.x + point.x

    result.lr.y = original.lr.y + point.y

    result.ul.x = original.ul.x + point.x

    result.ul.y = original.ul.y + point.y

Example

This output:

A rectangle:
{PhRect (lr . {PhPoint (x . 7) (y . 9)})
        (ul . {PhPoint (x . 4) (y . 1)})}

A translation point:
{PhPoint (x . 20) (y . 30)}

The rectangle, translated:
{PhRect (lr . {PhPoint (x . 27) (y . 39)})
        (ul . {PhPoint (x . 24) (y . 31)})}

Was generated using this code:

#!/usr/cogent/bin/phgamma

require_lisp("PhotonWidgets");
PtInit(nil);

r1 = new(PhPoint);
r2 = new(PhPoint);
TransPoint = new(PhPoint);

r1.x = 4;
r1.y = 1;
r2.x = 7;
r2.y = 9;

TransPoint.x = 20;
TransPoint.y = 30;

RectOrig = new(PhRect);
RectOrig.ul = r1;
RectOrig.lr = r2;
princ("A rectangle:\n",RectOrig, "\n\n");

princ("A translation point:\n",TransPoint, "\n\n");

TransRect = PtTranslateRect(RectOrig, TransPoint);
princ("The rectangle, translated:\n", TransRect, "\n\n");
		

See Also

In Photon documentation: PtTranslateRect.