# Lesson goal: Draw lines in 3D

Previous: Drawing in 3D with cubes | Home | Next: Drawing polylines in 3D

In a previous lesson, you learned how to draw lines in 2D graphics. In this mode, you used line(x1,y1,x2,y2) to draw a line between the points $(x_1,y_1)$ and $(x_2,y_2)$.

In this lesson, we introduce a 3D line drawing function, called line3d, that'll draw a line between two points in 3D space, $(x_1,y_1,z_1)$ and $(x_2,y_2,z_2)$.

line3d(x1,y1,z1,x2,y2,z2,color,thickness)
Move the mouse over a dotted box for more information.

You can find a list of color codes here. The 3D drawing area will appear under your code-editor. You might have to scroll down to see it.

# Now you try. Mess around with the code a bit and see what you can come up with.

Type your code here:

See your results here:

To get you started, here a red and blue sphere connected by a red line. Dismiss.
Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

3. Then click the "Use on iPhone" button that you'll see.