Class

# PictureBrush

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Uses the supplied image to draw an area based upon the mode set.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                        | Type                             | Read-Only | Shared |
|-----------------------------|----------------------------------|-----------|--------|
| `Image<picturebrush.image>` | `Picture</api/graphics/picture>` |           |        |
| `Mode<picturebrush.mode>`   | `Modes<picturebrush.modes>`      |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                    | Parameters                                                                                                                                     | Returns | Shared |
|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `Constructor<picturebrush.constructor>` | image As `Picture</api/graphics/picture>`, mode As `PictureBrush.Modes<picturebrush.modes>` = `PictureBrush.Modes.Default<picturebrush.modes>` |         |        |

## Enumerations

<div id="picturebrush.modes">

<div class="rst-class">

forsearch

</div>

</div>

PictureBrush.Modes

### Modes

> The various ways in which the picture can be used as a brush.
>
> | Enum    | Description                                                                                                                                                                          |
> |---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
> | Default | The default mode is Pad.                                                                                                                                                             |
> | Pad     | Draws the picture in the upper-left corner then extends the pixels at the right and bottom sides to the right and bottom sides of the graphics area. Not supported for macOS or iOS. |
> | Tile    | Repeats the picture over and over in rows and columns.                                                                                                                               |
> | Mirror  | Like Tile, except that each image is a horizontal mirror of the previous and alternating rows are vertical mirror of the previous rows. Not supported for macOS or iOS.              |

## Property descriptions

<div id="picturebrush.image">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PictureBrush.Image

**Image** As `Picture</api/graphics/picture>`

> The `Picture</api/graphics/picture>` to be used as a brush.

<div id="picturebrush.mode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PictureBrush.Mode

**Mode** As `Modes<picturebrush.modes>`

> The mode to be used when drawing the `Image<picturebrush.image>` in the drawing.
>
> Not all modes are supported on all platforms. See the `Modes<picturebrush.modes>` enumeration for details.
>
> <div class="warning">
>
> <div class="title">
>
> Warning
>
> </div>
>
> Setting this property to a mode that is not supported on the OS upon which the app is running will result in an `UnsupportedFormatException</api/exceptions/unsupportedformatexception>` occurring.
>
> </div>
>
> In this example, the Mode of the <span class="title-ref">PictureBrush</span> is set to Tile in the `Paint<desktopcanvas.paint>` event of a `Canvas</api/user_interface/desktop/desktopcanvas>`:
>
> ``` xojo
> Var pb As New PictureBrush
> pb.Image = Moon
> pb.Mode = PictureBrush.Modes.Tile
> ```

## Method descriptions

<div id="picturebrush.constructor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PictureBrush.Constructor

**Constructor**(image As `Picture</api/graphics/picture>`, mode As `PictureBrush.Modes<picturebrush.modes>` = `PictureBrush.Modes.Default<picturebrush.modes>`)

> Creates a <span class="title-ref">PictureBrush</span> from the parameters passed.

## Notes

Not all draw modes are supported on all platforms. See the `Modes<picturebrush.modes>` property for details.

## Sample code

This example draws a picture (a project item named "Moon") into a rectangle the size of the a `Canvas</api/user_interface/desktop/desktopcanvas>` using the Tile mode:

``` xojo
Var pbrush As New PictureBrush
pbrush.Image = Moon
pbrush.Mode = PictureBrush.Modes.Tile
g.Brush = pbrush

g.FillRectangle(0, 0, g.Width, g.Height)
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`GraphicsBrush</api/graphics/graphicsbrush>` parent class; `Graphics</api/graphics/graphics>`, `LinearGradientBrush</api/graphics/lineargradientbrush>`, `ShadowBrush</api/graphics/shadowbrush>`, and `RadialGradientBrush</api/graphics/radialgradientbrush>` classes.

</div>
