Drawing a circle in openGL for android - android

So I'd like to be able to draw a circle where I can specify the amount of circle drawn as shown in the following diagram.
AS an opengl newbie I'm not really sure how to approach this.. I've previously drawn full circles using GL_TRIANGLE_FAN

You already know how to draw a circle using a triangle fan. Now you just have to calculate the angles of the cutoff corners, use those as the beginning and end of the arc and place the hub of the triangle fan at the middle of the cutoff edge.

you could use a glScissor test to cut off the parts of the circle that you don't want.
http://www.khronos.org/opengles/sdk/1.1/docs/man/glScissor.xml

Related

Draw a rounded corner square in android canvas

Picture 1 depicting path to draw. Picture 2 depicting the final result
This is a bit more of a geometry-inside-java question. Basically, I want to round a single corner of a square I drew on a canvas, sometimes it's on the top left, other times on the top right, or bottom left or right. How could a shape like the red highlight be drawn and filled using Android's drawing methods? I've read the drawing tutorials on Oracle, but I can't still figure out how to draw something like that in that position. Any help would be greatly appreciated.

Linking borders of geometric figures

I'm creating an Android app which simulates petri nets. I'm representing place by circle and transition by square and I'm connecting those views by arc (it's just the name from petri nets for my purpose it's just a straight line) and here's the problem I'm facing, I know how to connect the centre point of those views but i don't know how to connect the border of circle and border of square, look at the image it should explain everything:
In my app I know if I'm pointing a place (circle) or transition (square), I also know the dimension of those views and it's coordinates, can you suggest me any start point for writing an algorithm which will connect borders of those two shapes and draw the arrow at the end of the line? Thanks in advance
You can make a method that takes in an angle and returns the point on the boundary at that angle from the center. This involves a little trigonometry, and cases for the square. To draw a line between the boundaries of two shapes, determine the angle of the difference vector atan2(difference in ys, difference in xs). Choose the point on the boundary with that angle. (This chooses the point that is on the line segment connecting the centers. You can change this if you want.) Connect the two points you get with a line, and add the arrow's head.

How can I draw a filled in circle with andengine?

I am using Andengine GLES 2.0 anchor center branch and I am trying to draw a filled in circle. I tried using the Ellipse class it comes with but all I can get is an outline of a circle not a filled in one like I want. I looked around and all I could find were places showing how to draw an outline so this must be a simple thing. So how can I draw a filled in circle with Andengine GLES 2.0 anchor center?
To make a filled circle/ellipse just go
mEllipse.setDrawMode(DrawMode.TRIANGLE_FAN);

Cut region out of intersecting lines on Android canvas

I have an Android canvas on which I'm drawing a series of lines to represent a hexagonal game board. The hexagon is subdivided with several intersecting interior lines.
I'm trying to figure out how to "cut out" a smaller hexagon from the center of the main hexagon, similar to this image: http://www.dcc.fc.up.pt/~pbv/stuff/hstzaar/hstzaar.png.
Is it possible to position a polygon over the intersecting lines and take the "difference" of the shapes, such that the lines underneath are modified to end at the polygon edges?
It might be sufficient to simply place an opaque polygon on top of the board center, but I was curious if it was possible to actually modify the underlying lines.
Since there are only 3 interior lines that run through the center of the hexagon, it's actually easier to draw each of them in two segments rather than try to cut them out later.
I'd still be interested to know if my original question was possible, but I solved the problem for now.

Android: how to make a drawn shape move & how to draw just part of a shape like a 3/4 solid circle

Animation:
All the animations on the Android books I read are made on an existing image. They load an image on the SD card and use animation functions (like alpha, scale, translate and rotate) to make it move. However, what if I want to make the shapes I drew move on the screen. For example, I just draw a circle on the screen and want to make it move from left to right. How can I do this?
Painting:
Functions like drawCircle can draw complete geometric shapes but I just want to draw part of a shape, for example, a 3/4 solid circle. How should I do? If I use drawArc, there will be a 'V' recess on the circle and I want it to be flat.

Categories

Resources