> 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/text-and-images.md).

# Text and Images

## Text

`new EasyDraw.Text(centerX, centerY, text)`

![](https://651142499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRAMSGwqRIdQ2ADsTkz%2F-MR_npajpEZf8wpIj8HL%2F-MRaFmdYU9IGnMtLINHu%2Fimage.png?alt=media\&token=d19c999e-dfc5-4ad0-920b-73d86b65957a)

| Setter                                  | Default | Description                                                                                    |
| --------------------------------------- | ------- | ---------------------------------------------------------------------------------------------- |
| `setText(text)`                         | -       | The text you want to display.                                                                  |
| `setColor(color)` / `setColor(r, g, b)` | "black" | The color of the text.                                                                         |
| `setFont(font)`                         | "Arial" | The font family used for the text. Font must be installed on the computer viewing the drawing. |
| `setSize(size)`                         | 16      | The font size of the text.                                                                     |
| `setBold(true)`                         | false   | Bolds the text.                                                                                |
| `setItalic(true)`                       | false   | Italicizes the text.                                                                           |
| `setUnderline(true)`                    | false   | Underlines the text.                                                                           |
| `setStrikethrough(true)`                | false   | Strikes-out the text.                                                                          |
| `setVisible(visible)`                   | true    | true = Text can be seen. false = Text cannot be seen.                                          |

Getters: `getText()`, `getColor()`, `getFont()`, `getSize()`, `isBold()`, `isItalic()`, `isUnderline()`, `isStrikethrough()`, `getCenterX()`, `getCenterY()`. Move it with `setCenter(x, y)`.

Example:

```java
EasyDraw.Text words = new EasyDraw.Text(300, 100, "I Love Java");
words.setColor(0, 200, 50);      // Optional
words.setFont("Times");          // Optional
words.setSize(32);               // Optional
words.setBold(true);             // Optional
words.setItalic(true);           // Optional
```

## Images

First open the image with `EasyDraw.openImage()`. The image file should be in the folder you run your program from.

```java
EasyDraw.ImageFile pic = EasyDraw.openImage("super_cool_image.png");
```

Easy Draw can open `.png`, `.gif`, `.jpg`, `.webp`, `.bmp`, and `.svg` images.

`openImage()` also works with a public image link that starts with `http://` or `https://`:

```java
EasyDraw.ImageFile pic = EasyDraw.openImage("https://example.com/cat.png");
```

{% hint style="info" %}
Make sure you copy the image's address (right-click the image and choose "Copy image address"), not the web page's address. The browser loads the image straight from the link, so viewing the drawing needs an internet connection.
{% endhint %}

Then you can create an image object.

`new EasyDraw.Image(centerX, centerY, image)`

![](https://651142499-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRAMSGwqRIdQ2ADsTkz%2F-MR_npajpEZf8wpIj8HL%2F-MRaGEPex2n6zJasiFXn%2Fimage.png?alt=media\&token=4ad09f11-5064-4217-b1ea-0e630e426741)

| Value                | Description                                                                   |
| -------------------- | ----------------------------------------------------------------------------- |
| `centerX`, `centerY` | The center coordinate of where to draw the image.                             |
| `image`              | An `ImageFile` from `EasyDraw.openImage()`, or the image's file name or link. |

Getters and setters: `getCenterX()`, `getCenterY()`, `setCenter(x, y)`, `getImage()`, `setImage(image)`, `setVisible(visible)`

Example:

```java
EasyDraw.ImageFile pic = EasyDraw.openImage("super_cool_image.png");
EasyDraw.Image img = new EasyDraw.Image(300, 300, pic);

// OR, in one step:
EasyDraw.Image img2 = new EasyDraw.Image(300, 300, "super_cool_image.png");
```

Images can rotate, just like every other Easy Draw object:

```java
img.rotate(45);
```
