# scale()

### Example

<div><figure><img src="/files/mLuAnpSTW8N3SSC5M7Av" alt=""><figcaption><p>Original Shape (Front View)</p></figcaption></figure> <figure><img src="/files/jjP3RleWKmJKi5lqaQ23" alt=""><figcaption><p>Original Shape (Side View)</p></figcaption></figure></div>

<div><figure><img src="/files/v73kewwGxhHham9rMeBs" alt=""><figcaption><p>scaling by <strong>1.5</strong> in x-direction</p></figcaption></figure> <figure><img src="/files/H5JueT645MiMhpocZfFP" alt=""><figcaption><p>scaling by <strong>0.5</strong> in y-direction</p></figcaption></figure> <figure><img src="/files/7GCJcV1qJtnBPDmaeYoZ" 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="/files/sFDksfI0FR8iN4QWEAxv" 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnpython.strivemath.com/p5-python-web/reference/3d-controls/scale.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
