scale()

Scales Object in 3D from the Origin

Example

Syntax

scale(x, y, z)
InputDescription

x

scaling factor of edges and faces in the x-direction

y

scaling factor of edges and faces in the y-direction

z

scaling factor of edges and faces in the z-direction

Full Example

Example Full Code
def setup():
  createCanvas(300,300, WEBGL)

def draw():
  background(255, 79, 132)
  fill(112, 88, 255)
  stroke(176, 235, 51)
  strokeWeight(2)
  orbitControl()
  # draw3DAxes(100, (100, 50, 20))
  rotateX(frameCount/2)
  rotateZ(frameCount)
  sX = 1+0.75*cos(frameCount)
  sY = 1+0.25*sin(frameCount)
  sZ = 1+0.5*sin(frameCount)
  scale(sX, sY, sZ)
  torus(75, 15)
  # rotateY(-2*frameCount)
  cone(30, 30)

Description

Increases or decreases the size of a shape by expanding or contracting its edges and faces in a specific direction. Objects always scale from their relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the function call scale(2.0, 1, 1) increases the x dimension of a shape by 200%.

If a negative number was specified, the shape will flip, then scale. For example, scale(-2.0, 1, 1) first flips the shape, then increases the dimensions by 200%.

Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!

We'd love to hear your Feedback/Comments here.

Last updated