> For the complete documentation index, see [llms.txt](https://docs.wisej.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/docs/controls/content/canvas-1.md).

# Canvas

The `Canvas` is a control which can be used to draw graphics via scripting. This can, for instance, be used to draw graphs, combine photos, or create simple (and not so simple) animations.

{% hint style="info" %}
For a full list of properties, methods and events see the [API documentation.](http://docs.wisej.com/api)
{% endhint %}

## Features

### Drawing

The Wisej.NET `Canvas` control implements all the same properties and methods as the JavaScript [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial) control. You can use methods like `LineTo()`, `FillRect()`, and `FillText()` to draw directly on the control in the browser.

![Interactive drawing demonstration using Canvas control](/files/-MelEB9O9XU7Zw_XuFD0)

{% hint style="info" %}
You must still call `BeginPath()` and `Stroke()` to draw lines. See <https://www.w3schools.com/tags/canvas_lineto.asp>.
{% endhint %}

## How To

### Draw a Line

You can draw a line with the `Wisej.Web.Canvas` control the same way you would a JavaScript Canvas element:

Note that all drawing must be done inside of the Canvas's Redraw event.

{% tabs %}
{% tab title="C#" %}

<pre class="language-csharp"><code class="lang-csharp">private void canvas1_Redraw(object sender, EventArgs e)
{
<strong>    canvas1.BeginPath();
</strong>    canvas1.MoveTo(0, 0);
    canvas1.LineTo(100, 100);
    canvas1.StrokeStyle = Color.Red;
    canvas1.Stroke();
}
</code></pre>

{% endtab %}
{% endtabs %}

## Advanced

### JavaScript Widget

| Item             | Description                                                                                                         |
| ---------------- | ------------------------------------------------------------------------------------------------------------------- |
| Class name       | wisej.web.Canvas                                                                                                    |
| Theme appearance | "canvas", see [Themes](https://docs.wisej.com/theme-builder/theme-elements/elements).                               |
| Child components | "canvas" is the HTML5 canvas element. See [JavaScript](/docs/concepts/javascript-object-model.md).                  |
| Source code      | [https://github.com/iceteagroup/wisej-js](https://github.com/iceteagroup/wisej-js/blob/master/wisej.web.TextBox.js) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/docs/controls/content/canvas-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
