Graphical Object drawing algorithms
-
Hi, Can anyone point me to algorithms for drawing a line/spiral/ellipse, if its a c++ code then its my lucky day :) otherwise anything will do. Also i need to draw a gradient as well and i cant use GradientFill api (lucky me ;)) Any help at all will be much appreciated Thanks
C++ where friends have access to your private members !
-
Hi, Can anyone point me to algorithms for drawing a line/spiral/ellipse, if its a c++ code then its my lucky day :) otherwise anything will do. Also i need to draw a gradient as well and i cant use GradientFill api (lucky me ;)) Any help at all will be much appreciated Thanks
C++ where friends have access to your private members !
-
Well i am sorry if i was not clear on the question i actually need to implement functions like
DrawLine(POINT ptFrom,POINT ptTo);
DrawGradient(CRect rc,COLORREF FromColor,COLORREF ToColor);For some reasons i cant use the stock functions provided (i need to get all the points in the line)
C++ where friends have access to your private members !
-
Well i am sorry if i was not clear on the question i actually need to implement functions like
DrawLine(POINT ptFrom,POINT ptTo);
DrawGradient(CRect rc,COLORREF FromColor,COLORREF ToColor);For some reasons i cant use the stock functions provided (i need to get all the points in the line)
C++ where friends have access to your private members !
:doh:
-
Well i am sorry if i was not clear on the question i actually need to implement functions like
DrawLine(POINT ptFrom,POINT ptTo);
DrawGradient(CRect rc,COLORREF FromColor,COLORREF ToColor);For some reasons i cant use the stock functions provided (i need to get all the points in the line)
C++ where friends have access to your private members !
-
Monty2 wrote:
For some reasons i cant use the stock functions provided
Care to give us a clue to why so we know better what to suggest?
If you don't have the data, you're just another asshole with an opinion.
Tim Craig wrote:
Care to give us a clue to why so we know better what to suggest?
Fair enough, let me explain it further I need to draw N rectangles side by side (their centers lying on a line or trajectory). Works like this, user gives two points (left and right) then i need to draw a series of rectangles from the first point to the second with the rectangles centers lying on the line. i figured for that i need to calculate the points that will lie on that line, hence the requirement for an algorithm that will give me the points that will lie on a line(x1,y1,x2,y2) Secondly user will provide the color of the first rectangle and the last and i need to fill the rest of the rects with the gradient color, hence the requirement for a gradient algorithm Here is a sample image (it uses sine wave i think instead of a line) Sample[^] And lastly thanks for your valuable time :)
C++ where friends have access to your private members !
-
Tim Craig wrote:
Care to give us a clue to why so we know better what to suggest?
Fair enough, let me explain it further I need to draw N rectangles side by side (their centers lying on a line or trajectory). Works like this, user gives two points (left and right) then i need to draw a series of rectangles from the first point to the second with the rectangles centers lying on the line. i figured for that i need to calculate the points that will lie on that line, hence the requirement for an algorithm that will give me the points that will lie on a line(x1,y1,x2,y2) Secondly user will provide the color of the first rectangle and the last and i need to fill the rest of the rects with the gradient color, hence the requirement for a gradient algorithm Here is a sample image (it uses sine wave i think instead of a line) Sample[^] And lastly thanks for your valuable time :)
C++ where friends have access to your private members !
Well, this might be a place to get started. Bresenham's algorithm[^] certainly picks pixels to draw straight lines and some other curves. You might also check some of the 3D drawing class libraries, like VRML or the library that originated at SGI, as they often implement a process they call "extrude" where they sweep a shape through space that follows a curve, a cylinder is an example of extruding a circle along a straight line. I don't think they use pixels generally but you might get some ideas.
If you don't have the data, you're just another asshole with an opinion.
-
Well, this might be a place to get started. Bresenham's algorithm[^] certainly picks pixels to draw straight lines and some other curves. You might also check some of the 3D drawing class libraries, like VRML or the library that originated at SGI, as they often implement a process they call "extrude" where they sweep a shape through space that follows a curve, a cylinder is an example of extruding a circle along a straight line. I don't think they use pixels generally but you might get some ideas.
If you don't have the data, you're just another asshole with an opinion.