Okay but I cannot be able to extend the width of the polygon and also I cannot be able to make the polygons at anywhere on the whole canvas in the above project.
Thanks for your time and help.
You can also use SVG graphics in a WebView for this, depending on your Android version:
webviewer_SVG.aia (3.7 KB)
I am now also confused in making shapes. So, please help me.
The polygon.aia project just draws regular polygons.
This is a powerful block for shapes:
It is fast, so you can modify your list of points as you drag Balls around the Canvas, and erase and redraw the shape(s) on the Canvas when you TouchUp.
Play with it.
How can I find the point list of triangle, square, rectangle, etc?
You set the points based upon the size of your canvas, and where you want to position your shape. This becomes more complicated if your canvas is sized dynamically to the device....
e.g. to draw a square of 100 x 100 pixels in the middle of a canvas sized 200 x 200 pixels, your point list would be:
[[50,50],[150,50],[150,150],[50,150]]
If I want to make the square at any place on the canvas, then how can I make the point list?
See my previous example, you should be able to figure this out for yourself...
(hint: the first x,y is [50,50] which is the top left corner of the square, 50 pixels in from the left, and 50 pixels down from the top of the canvas)
I hadn't noticed that before.
Apparently, it must come from my copy of the MemuPlay Android emulator, since it only appears when my cursor crosses that emulator window.
Thank You for your reply
How to make proper and straight (not in diagonal) square and rectangle using this code?
One way
Please experiment @Sarthak ; only you know what you want to do and expect to happen.
DrawShape( pointList , fill ) draws a shape on the canvas. pointList should be a list contains sub-lists with two number which represents a coordinate. The first point and last point does not need to be the same. e.g. ((x1 y1) (x2 y2) (x3 y3)) When fill is true, the shape will be filled.
I need help for drawing Star can somone help me for my school project
You would use the DrawShape block. You should be able to work up a pointslist for a star, even if you use paper and pencil. Set your canvas to fixed dimensions.
How many points in the star?
Pick the px,py for the center of the star, and the radius of the star.
The points of the star are located by imagining a line from the center, rotating at degrees = 360/points around the center to get to each point.
Here is sample code for a triangle from one of my projects ...
Really thanks you helped me to pass my project