Draw Circle Line And Rectangle Dynamically Using Flex
While working on a project, I came across a requirement where we had to draw annotations over a Video frame by frame. We are using Flex for the purpose. I would like to share the details of how we can draw a Line, a circle, a rectangle dynamically on video using flex.
Flex provides easy functions to draw the line, circle, and rectangle.
To draw annotations, I am using Canvas container because Canvas is the only container that can explicitly specify the location of its children within the container.
MXML Syntax:-User can define a canvas by using mx:Canvas tag and specif its properties. Like, the following code snippet.
We can use the Graphics class to draw different shapes like Circle, Line, Rounded Rectangle, Rectangle etc.
Here is the sample code to draw the circle:-
Summary of graphics functions:-
"clear()" is used to remove all the drawing output associate with the current object.
"lineStyle()" is used to define the stroke of lines. The three parameters (thickness, color, and alpha)
"drawCircle()" is used to draw the circle. We can pass X, y position and radius of the circle.
Here is the one example to draw circle, rectangle, and line dynamically.
Hope it helps :)
Sumit Rathi
[email protected]