-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to paint a circle #77
Comments
The way this library is set up to draw, each element has its own path. So from what you described, each of the first four steps creates and draws a path which leaves the fifth step to which this library doesn't have. Whilst it uses OpenVG's paths internally, it doesn't expose those paths and doesn't provide any way for you to have multiple elements in a path. Can you show the code you are using to draw this? |
Thanks for your reply. I draw the circle using OpenVG directly. the code is too large, I can show some part. // void DrawARC(VGubyte** segments, int* segments_amout, VGfloat** coords, int* coords_amout, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat startAngle, VGfloat angleExtent, float* end_x, float* end_y)` and then I compute the circle:
and then draw it. |
I try to draw the outside Arc in clockwise, and then draw the line between then end point of outside Arc and the start point(anti clockwise) of inside Arc, and then draw the inside Arc in anti clockwise, at the end, connect the end point of inside Arc to start point of outside. the strange line is still has. I think maybe OpenVG can not draw this kind of shape use Arc. It need triangle net to draw it like OpenGL 1.0. But if a SVG image like this, how OpenVG to paint it ? |
The VG_CLOSE_PATH will draw a line from the current coordinate which is the end of the last line drawn at (OutCoordsEndX, OutCoordsEndY) back to the very first coordinate of the path which is at (OutCoords[0], OutCoords[1]). You don't want to use VG_CLOSE_PATH if you've already drawn all the connecting lines and the last coordinate drawn to isn't the same as the first. It's purpose is for closing a loop where the last coordinate drawn to wasn't at the same location as the first but you do want a line from it back to the start. |
When you are filling paths OpenVG uses the areas of their sub-paths to define the area to fill. Each time you have a VG_MOVE_TO segment you are starting a new sub-path so a fill will implicitly close the previous sub-path. In your example the first sub-path is the outer arc plus the line from the end of the outer arc to the end of the inner arc, that defines the first sub-area. The best way to define the path would be to just concatenate the two arcs as you are (making sure they are in the opposite direction to each other) but change the second arc's initial VG_MOVE_TO segment into a VG_LINE_TO segment (that makes the first connecting line for you) and add a VG_CLOSE_PATH at the very end (which makes the other connecting line). You end up with one complete path that exactly describes the area to fill with no sub-paths to worry about. And it works for stroking as well. |
Thanks again. I have tired this way, but the result is same. the outside arc is clockwise, the inside arc is anti-clockwise. and use line to link. but the strange line still is there. |
I took time with my previous answer because I wanted to verify my reasoning on a running program. I had to guess at how you created the arc paths, I went with a simple MOVE_TO followed by multiple (20) LINE_TO segments rather than using arc segments (e.g. LCCWARC_TO). |
My code similar with you:
} |
I draw a circle, use the openvg command.
but I find a strange line between two Arcs. Why does it like this?
The text was updated successfully, but these errors were encountered: