# scale()

### Example

<div><figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FUpchQOBOlbxWUWHh17IL%2Foriginal.png?alt=media&#x26;token=08da1259-199f-43e7-94da-edeffb176a7f" alt=""><figcaption><p>Original Shape (Front View)</p></figcaption></figure> <figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FpsA9AXkrwFlEWG47HMCJ%2Foriginalz.png?alt=media&#x26;token=40c13fd8-9f5a-46e9-8cc2-96a550534c52" alt=""><figcaption><p>Original Shape (Side View)</p></figcaption></figure></div>

<div><figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FPjARJ9CesPyuMkIcP8Q4%2F1.5x.png?alt=media&#x26;token=710d31c9-e988-40ca-972b-5def9b4e89a1" alt=""><figcaption><p>scaling by <strong>1.5</strong> in x-direction</p></figcaption></figure> <figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FvaktsIl5L1UdwyNX5VRF%2F0.5y.png?alt=media&#x26;token=19cf3587-83f1-41c6-a86c-37b2712e4dcb" alt=""><figcaption><p>scaling by <strong>0.5</strong> in y-direction</p></figcaption></figure> <figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FbIh2kT6XvrKEKypLzxwF%2Fz3.png?alt=media&#x26;token=044d89e2-0145-41bf-b631-05057e7dd395" alt=""><figcaption><p>scaling by <strong>3</strong> in z-direction</p></figcaption></figure></div>

### Syntax

```
scale(x, y, z)
```

<table><thead><tr><th width="114.33333333333331">Input</th><th>Description</th></tr></thead><tbody><tr><td>x</td><td>scaling factor of edges and faces in the x-direction</td></tr><tr><td>y</td><td>scaling factor of edges and faces in the y-direction</td></tr><tr><td>z</td><td>scaling factor of edges and faces in the z-direction</td></tr></tbody></table>

### Full Example

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FqZ4wkWJEMacaZn32NriS%2Fscale%20full.gif?alt=media&#x26;token=7aab5f62-ae44-4339-b2a9-39e7010ba3b4" alt=""><figcaption></figcaption></figure>

<details>

<summary>Example Full Code</summary>

```python
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)
```

</details>

### 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%.

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}
