Scale the coordinate system.

The transform methods are used to position objects in your application. You can scale an object along a particular axis (x,y,z) or uniformly in all directions. See the examples section below for usage.

Be sure to wrap scale calls with pushMatrix() and popMatrix() to restore the environment to its original state. Otherwise, all subsequent rendering calls will be scaled.

See the coordinate system tutorial for more information.

syntax

scale(sx, sy, sz)
scale([sx, sy, sz])
scale(size)

parameters

sx amount to scale in x-direction
sy amount to scale in y-direction
sz amount to scale in z-direction
size amount to scale in all directions

examples

cube scaled in x-direction

def display():
   lighting(False)

   cube(1.0)
   
   scale(3.0, 1.0, 1.0)
   color(green)
   cube(1.0)

cube scaled in y-direction

def display():
   lighting(False)

   cube(1.0)

   scale(1.0, 3.0, 1.0)
   color(green)
   cube(1.0)

cube scaled in z-direction

def display():
   lighting(False)

   cube(1.0)

   scale(1.0, 1.0, 3.0)
   color(green)
   cube(1.0)

cube scaled in all directions

def display():
   lighting(False)

   cube(1.0)

   scale(3.0)
   color(green)
   cube(1.0)