Drawing a filled circle segment - graphics

I want to draw something like a pie chart segment filled with a certain color.
I know we can draw a circle using the Me.Circle function in a PictureBox to get a filled circle. However, when you add the start and end the circle becomes just a single lined arc.
Can anyone offer me a solution?

It is possible.
Check http://www.wiley.com/college/mckeown/0471418625/ppt/ch11.ppt

Related

Is there a simple algorithm that can find the envelope of several circles?

Given a number of points on a 2d surface and radiuses for these points I can easily paint circles for them. What I need is an algorithm that only paints the envelope (right word for what I am looking for?) or outer bound of these combined circles. Additionally a second set of circles can 'encroach' on these circles, resulting in a kind of 'border'.
Image of what I am looking for
A quick way to draw the outline of the union of the disks is to
fill all disks in yellow, then
fill all disks in white with a smaller radius.
This can be adapted to the "encroached" circles, provided you only fill the remaining portions of the disks. Unfortunately, in a general setting finding the remaining portions can be an uneasy geometric problem.
There is an alternative approach which can work in all cases:
fill an image with zeroes, then for all disks fill every pixel with the value of the distance to the circumference (maximum at the center), but only keep the highest value so far.
while you do this, fill a second image with the color of the disk that achieved that highest value. (Initialize the image with the background color.)
At the end of this process, the first image will represent a "terrain" made of intersecting cones; and for every point of the terrain, you will know the color.
finally, color the pixels that have a height smaller than the desired stroke width, using the color map.
You can do the drawing in two steps.
1) Draw the outline using the following method: For each point, draw a circle using your favorite circle-drawing method, but before drawing a pixel, ensure that it is not contained inside any other circle. Do this for every point and you will get your outline.
2) Draw the borders between different sets using the following method: For each pair of points from different sets, calculate the two intersection points of the circles. If there is an intersection, the border can be drawn as a segment joining these two points. However, you have to make two lines, one for circle A, and another for circle B. To draw the line for circle A, slightly offset the segment towards point A. Then, use your favorite line-drawing method, but before drawing a pixel, ensure that it is closer to point A that any other point of the opposite set. After drawing the line, repeat the process for circle B. Note that both segment are not guaranteed to be the same length since the asymmetry of the points of the different sets. It will, however, always form a closed shape when all outlines and borders are drawn.

Corona SDK: Rotating an object with specific reference point consecutively

I'm trying to make a square move by rotating it sideways with its reference point set to the bottom side of the direction it is moving to.
For example: if I would move the square to the right, I would set its reference point to the bottom right of it and animate a rotation of 90 degrees, after the movement is done, I increase the square X by the width of it and centrally set its rotation to 90 degrees (so that I can keep track of its position)
The thing is, how should I proceed to keep repeating it? 'cause if I try to rotate by another 90 degrees using bottom right reference point, it won't be using the right position. What should I do to get the new bottom right relative position?
Thanks!
Create a transparent image twice as wide and high as the square.
Place the square in the top left corner.
Rotating the image around its center will now rotate the square in the way you describe.
You will need some maths to track where the new bottom is, using some simple formula for 2D rotation, so you calculate BEFORE rotating, where the point you wish to modify.
Then you use xReference and yReference variables :)

How to fill part of shapes in Actionscript

I want to fill some part of the shapes in actionscript, lets say "half of a circle", but unfortunately i could not find any suitable way to do it ?. Any suggestions will be appreciated thanks :)
one solution, in your case you have to draw some Close-region# square and rectangle triangle etc. in your Main region and then you can fill it whole part of the region which you draw. so if you want to fill a part of the region then you must draw a region on your main region then you can fill it so user have a feeling that he has filling a half region.
May This link'll be helpfull the ActionScript Drawing API & Drawing and Filling Partial Circles

Finding a point clicked in a grid

Given this grid ( http://i.stack.imgur.com/Nz39I.jpg is a trapezium/trapezoid, not a square), how do you find the point clicked by the user? I.e. When the user clicks a point in the grid, it should return the coordinates like A1 or D5.
I am trying to write pseudo code for this and I am stuck. Can anyone help me? Thanks!
EDIT: I am still stuck... Does anyone know of any way to find the height of the grid?
If it is a true perspective projection, you can run the click-point through the inverse projection to find it's X,Z coordinates in the 3D world. That grid has regular spacing and you can use simple math to get the A1,D5,etc.
If it's just something you drew, then you'll have to compare the Y coordinates to the positions of the horizontal lines to figure out which row. Then you'll need to check its position (left/right) relative to the angled lines to get the column - for that, you'll need either coordinates of the end-points, or equations for the lines.
Yet another option is to store an identical image where each "square" is flood-filled with a different color. You then check the color of the pixel where the user clicked but in this alternate image. This method assumes that it's a fixed image and is the least flexible.
If you have the coordinates of end points of the grid lines then
Try using the inside-outside test for each grid line and find the position
Since this grid is just a 3D view of a 2D grid plane, there is a projective transform that transforms the coordinates on the grid into coordinates on the 2D plane. To find this transform, it is sufficient to mark 4 different points on the plane (say, the edges), assign them coordinates on the 2D plane and solve the resulting linear equation system.

Stop LinearGradientBrush repeating

I'm trying to figure out how to stop LinearGradientBrush to repeat along with shape I'm drawing. So, for example I created gradient with height equal to 50, but next I draw rectangle with height equal to 150. In that case gradient will repeat itself three times. But I'd like to draw only first gradient and draw nothing for the rest of rectangle.
Seems GradientBrush in WPF supports SpreadMethod(http://msdn.microsoft.com/en-us/library/system.windows.media.gradientbrush.spreadmethod.aspx) for this purpose, but does something exists for WinForms as well?
Paul, I think the easiest way may be to create your fill the same way, but only draw using a rect of 50 pixels. If you need to fill the other 100 pixels with a specific color, then do a solid fill with that color first.
Alternatively, you can try to set a blend in your gradient fill (LinearGradientbrush::SetBlend), but that seems like a lot of effort to achieve the same effect.

Resources