CPolygon:Skew


The Skew method skews the CPolygon by applying cross-scaling factors relative to the center. Scale factors of 1.0 apply no scaling.

Syntax

CPolygon:Skew( nScaleX, nScaleY )

where

    nScale is the multiplication factor to be applied in both directions.

    nScaleX, nScaleY are the multiplication factors for the x and y directions.

 

This method transforms a rectangle into a parallelogram by applying a skew transformation to each vertex point. Let (xc,yc) be the center of the CPolygon. Then for scale factors nScaleX and nScaleY, the new vertex coordinates are calculated using the following equations:

     x' = x - xc

     y' = y - yc

     x = xc + x' + nScaleX * y'

     y = yc + y' + nScaleY * x'      

Example

The following script creates a CPolygon from 2 arrays and applies a skew factors of 1.5 and 2.5:

A = NewPolygon( {4,5,6,7}, {1,2,-3,5} )

-- create CPolygon A

Printf("x,y = %lg, %lg", A:GetPt(3) )

-- result: x,y = 6, -3

A:Skew( 1.5, 2.5 )

-- skew the polygon

Printf("x,y = %lg, %lg", A:GetPt(3) )

-- result: x,y = -.375, -2.75

Related Topics

Rotate

Scale

Shift

CPolygon class