Working with Drawables

From Lianjapedia
Jump to: navigation, search

Overview

Custom Container and Image objects are drawable.

The draw(operation, args) method can be used to superimpose a drawing on top of a container or image.

You create a "drawing" by issuing a list of drawing operations specified by the draw() method.

Operations consist of: clear, moveto, lineto, point, rectangle, fill, ellipse, image, save, restore, pen, font, brush.

This functionality can be used in data collection applications such as insurance inspection to draw on top of photos.

You can detect mouseDown, mouseUp and mouseMove events by declaring delegates for these and issue draw() operations.

There are several new methods and properties that can be used to draw; mouseDown(), mousex and mousey.

The example_drawable app included in the distribution shows you how to use this functionality.

//cont as container
cont.draw("clear")
cont.draw("redraw")
cont.draw("save", filename)
cont.draw("restore", filename)
cont.draw("push")
cont.draw("pop")
cont.draw("push")
cont.draw("brush", "color")
cont.draw("pen", "color")
cont.draw("font", "pointsize")
cont.draw("font", "pointsize", "weight")
cont.draw("font", "pointsize", "weight")
cont.draw("font", "pointsize", "weight", "italics")
cont.draw("moveto", "x", "y")
cont.draw("lineto", "x", "y")
cont.draw("rect", "x", "y", "width", "height" [,"color"])
cont.draw("roundedrect", "x", "y", "width", "height", "xradius", "yradius" [,"color"])
cont.draw("line", "x", "y", "x2", "y2" [,"color", ["height"]])
cont.draw("image", "x", "y", "width", "height", "filename")
cont.draw("ellipse", "x" , "y" ",width", "height" [,"color"])
cont.draw("fillrect", "x", "y", "width", "height", "color")
cont.draw("drawpoint", "x", "y" [,"color"])
cont.draw("drawtext", "x", "y", "text" [,"color"])