# screen_x()#

Takes a three-dimensional X, Y, Z position and returns the X value for where it will appear on a (two-dimensional) screen.

## Examples#

``` 1def setup():
2    py5.size(100, 100, py5.P3D)
3
4
5def draw():
6    py5.background(204)
7
8    x = py5.mouse_x
9    y = py5.mouse_y
10    z = -100
11
12    # draw "X" at z = -100
13    py5.stroke(255)
14    py5.line(x-10, y-10, z, x+10, y+10, z)
15    py5.line(x+10, y-10, z, x-10, y+10, z)
16
17    # draw gray line at z = 0 and same
18    # x value. notice the parallax
19    py5.stroke(102)
20    py5.line(x, 0, 0, x, py5.height, 0)
21
22    # draw black line at z = 0 to match
23    # the x value element drawn at z = -100
24    py5.stroke(0)
25    the_x = py5.screen_x(x, y, z)
26    py5.line(the_x, 0, 0, the_x, py5.height, 0)
```

## Description#

Takes a three-dimensional X, Y, Z position and returns the X value for where it will appear on a (two-dimensional) screen.

Underlying Processing method: screenX

## Syntax#

```screen_x(x: float, y: float, /) -> float
screen_x(x: float, y: float, z: float, /) -> float
```

## Parameters#

• x: float - 3D x-coordinate to be mapped

• y: float - 3D y-coordinate to be mapped

• z: float - 3D z-coordinate to be mapped

Updated on November 12, 2021 11:30:58am UTC