Paint.rectangle
From codeTank
Contents |
Description
paint.rectangle will draw a rectangle in a window. It must be used on a paint object, which is passed to the onpaint event when a window needs to be redrawn.
Arguments
pnt:rectangle(x, y, width, height) pnt:rectangle(x, y, width, height, color) pnt:rectangle(x, y, width, height, color, fill) pnt:rectangle(x, y, width, height, color, fill, thickness)
x, y, width, and height define the properties of the rectangle.
color is the border color, which can either be a normal color (generated using rgb), or it can be the value false, which means no border will be drawn. If no border color is provided, it will default to black.
fill is the color used to fill the rectangle. If no fill color is provided, then it will default to transparent, and the rectangle will not be filled.
thickness is the thickness (in pixels) of the border. If a border isn't drawn, then this parameter doesn't matter. If it isn't specified, it will default to 0, which means the border will be 1 pixel thick.
Returns
paint.rectangle doesn't return anything.
Example
wnd = window.create{ width = 300, height = 300, onpaint = function(wnd, pnt) -- draw a black border rectangle pnt:rectangle(10, 10, 50, 20) -- draw a solid blue rectangle, without a border pnt:rectangle(10, 90, 50, 20, false, rgb(0, 0, 255)) -- draw a solid red rectangle, with a thick dark green border pnt:rectangle(10, 150, 50, 20, rgb(0, 127, 0), rgb(255, 0, 0), 5) end, } while window.getcount() > 0 do window.pumpmessages() end

