> For the complete documentation index, see [llms.txt](https://easy-draw.joemazzone.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easy-draw.joemazzone.net/java/module-reference/the-drawing-canvas.md).

# The Drawing Canvas

All shapes will be drawn on a canvas.

The Easy Draw canvas is 600 x 600 pixels (600 pixels wide by 600 pixels tall). So (300, 300) is the middle of the canvas, and (600, 600) is the bottom-right corner.

The coordinate system origin (0, 0) is the top-left corner of the canvas.

As x increases, objects move right. As y increases, objects move down (not up!).

![](https://651142499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRAMSGwqRIdQ2ADsTkz%2F-MRSz1hx0nb7qnoNWat3%2F-MRT-Gv1H7yZTFGl5LLU%2Fimage.png?alt=media\&token=a4585fe9-c159-4731-8a5e-7929c28c2f13)

{% hint style="info" %}
Turn on the **Grid** button in the Easy Draw page to see the coordinates on the canvas.
{% endhint %}

## Loading the Canvas

`EasyDraw.loadCanvas()`

Every Easy Draw program must start with this method call. It writes your drawing to an `index.html` file in the folder you run your program from and opens the live drawing in your web browser.

You can give it a background color:

```java
EasyDraw.loadCanvas("black");
```

You can also pick the port for the live drawing (default `8765`) and set `openBrowser` to `false` if you want to open the page yourself:

```java
EasyDraw.loadCanvas("white", 8000, false);
```

## Changing the Background Color

`EasyDraw.setCanvasColor(color)`

Used to change the canvas background color at any point in the program.

```java
EasyDraw.setCanvasColor("blue");
EasyDraw.setCanvasColor(0, 0, 255);
```

## Ending the Program

`EasyDraw.end()`

Every Easy Draw program must end with this method call. It keeps your program running so the browser can send events (like clicks and key presses) to your program.

Closing the Easy Draw browser tab (or pressing Ctrl+C) stops your program.

```java
EasyDraw.end();
```

To print the finished page's HTML code, pass `true`:

```java
EasyDraw.end(true);
```

## Colors

There are 3 ways you can use colors in Easy Draw:

```java
shape.setColor("red");          // 1. Name of the color
shape.setColor(255, 0, 0);      // 2. RGB value
shape.setColor("#FF0000");      // 3. Hex value
```

To turn an RGB value into a hex value, use `EasyDraw.rgbConvert()`:

```java
String red = EasyDraw.rgbConvert(255, 0, 0);    // "#ff0000"
```

Colors work the same as in the Python version. See the Colors page for more about each kind of color value:

{% content-ref url="/pages/-MRAv4THLzk2KzBvDpW7" %}
[Colors](https://easy-draw.joemazzone.net/python/module-reference/colors.md)
{% endcontent-ref %}

## Errors

When Easy Draw is not used properly, it throws an `EasyDraw.EasyDrawException` with a message that explains what went wrong.
