# RegionFreeHand

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg)   |
|--------------------|--------------------------------------------------------------------------------------------------------------|
| Required licenses  | Any                                                                                                          |
| Recommended images | Any                                                                                                          |
| Location           | `Image Processing/RegionFreeHand`                                                                            |

## Purpose

This sample program demonstrates how to:

- Create an `ERegion` using the `ERegionFreeHandPainter`.

![](assets/images/sample_programs/image_processing-regionfreehand.webp)

## Code highlights

1. Set the size of the canvas (painting area) for subsequent painting.
   ```c++
   painter_.SetCanvasSize(width, height);
   ```
2. Set the painter brush. It can be a region of any shape you desire.
   ```c++
   painter_.SetBrush(region);
   ```
3. Apply the brush to the canvas at the given coordinates.
   ```c++
   painter_.Paint(x, y);
   ```
4. Retrieve the painted region from the painter.
   ```c++
   ERegion region = painter_.RetrieveRegion();
   ```
5. Clear the canvas for later reuse.
   ```c++
   painter_.ClearCanvas();
   ```
