# The MIT License (MIT)
#
# Copyright (C) 2026 Scott Duensing
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

.topic ctrl.picturebox
.title PictureBox
.toc 1 PictureBox
.index PictureBox
.index Canvas
.index Drawing
.index SetPenColor
.index SetPenSize

.h1 PictureBox

VB Equivalent: PictureBox -- DVX Widget: canvas | Name Prefix: Picture

A drawing surface (canvas). Supports drawing lines, rectangles, circles, text, and individual pixels. Can save and load BMP images. The default canvas size is 64x64 pixels.

Colors are specified as 0x00RRGGBB integers (e.g. &HFF0000 for red).

.h2 Type-Specific Methods

.table
  Method                                        Description
  ------                                        -----------
  Clear color%                                  Fill the entire canvas with the specified color.
  DrawLine x0%, y0%, x1%, y1%, color%           Draw a line between two points.
  DrawRect x%, y%, w%, h%, color%               Draw a rectangle outline.
  DrawText x%, y%, text$                        Draw text at the given position.
  FillCircle cx%, cy%, radius%, color%          Draw a filled circle.
  FillRect x%, y%, w%, h%, color%               Draw a filled rectangle.
  GetPixel(x%, y%)                              Returns the color at a pixel.
  Load path$                                    Load a BMP image onto the canvas.
  Resize w%, h%                                 Resize the canvas to new dimensions.
  Save path$                                    Save the canvas as a BMP file.
  SetPenColor color%                            Set the drawing color for subsequent operations.
  SetPenSize size%                              Set the pen/brush size in pixels.
  SetPixel x%, y%, color%                       Set the color of a single pixel.
.endtable

Default Event: Click

.h2 Example

.code
Picture1.Resize 200, 150
Picture1.Clear &HFFFFFF
Picture1.SetPenSize 2
Picture1.DrawRect 10, 10, 180, 130, &H000000
Picture1.FillCircle 100, 75, 40, &HFF0000
Picture1.DrawText 60, 130, "Hello!"
Picture1.Save "output.bmp"
.endcode

.link ctrl.common.props Common Properties, Events, and Methods
