Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Transform

Atsuya Sato edited this page Nov 30, 2018 · 2 revisions

Transform


pushMatrix()

Available

iOS, OSX

Examples

fill(255, 255, 255)
rect(0, 0, 50, 50)  // White rectangle

pushMatrix()
translate(30, 20)
fill(0, 0, 0)
rect(0, 0, 50, 50)  // Black rectangle
popMatrix()

fill(100, 100, 100)
rect(15, 10, 50, 50)  // Gray rectangle

Description

Pushes the current transformation matrix onto the matrix stack


popMatrix()

Available

iOS, OSX

Examples

fill(255, 255, 255)
rect(0, 0, 50, 50)  // White rectangle

pushMatrix()
translate(30, 20)
fill(0, 0, 0)
rect(0, 0, 50, 50)  // Black rectangle
popMatrix()

fill(100, 100, 100)
rect(15, 10, 50, 50)  // Gray rectangle

Description

Pops the current transformation matrix off the matrix stack


scale(_ s: CGFloat)

scale(_ x: CGFloat, _ y: CGFloat)

Available

iOS, OSX

Examples

rect(30, 20, 50, 50)
scale(0.5)
rect(30, 20, 50, 50)

Description

Increases or decreases the size of a shape by expanding and contracting vertices


shear(_ angleX: CGFloat, _ angleY: CGFloat)

Available

iOS, OSX

Examples

shear(QUARTER_PI, 0)
rect(10, 10, 30, 30)

Description

Shears a shape.


rotate(_ angle: CGFloat)

Available

iOS, OSX

Examples

translate(width/2, height/2)
rotate(PI/3.0)
rect(-26, -26, 52, 52)

Description

Rotates the amount specified by the angle parameter.


translate(_ x: CGFloat, _ y: CGFloat)

Available

iOS, OSX

Examples

translate(30, 20)
rect(0, 0, 55, 55)

Description

Specifies an amount to displace objects within the display window.