Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Graphical Object drawing algorithms

Graphical Object drawing algorithms

Scheduled Pinned Locked Moved Algorithms
c++graphicsjsonhelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monty2
    wrote on last edited by
    #1

    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 !

    7 1 Reply Last reply
    0
    • M Monty2

      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 !

      7 Offline
      7 Offline
      73Zeppelin
      wrote on last edited by
      #2

      Monty2 wrote:

      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.

      Is something like this[^] sufficient? It's pretty nice - I've used it in one of my projects. Less in your favour is this[^] implementation in C#.

      M 1 Reply Last reply
      0
      • 7 73Zeppelin

        Monty2 wrote:

        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.

        Is something like this[^] sufficient? It's pretty nice - I've used it in one of my projects. Less in your favour is this[^] implementation in C#.

        M Offline
        M Offline
        Monty2
        wrote on last edited by
        #3

        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 !

        7 T 2 Replies Last reply
        0
        • M Monty2

          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 !

          7 Offline
          7 Offline
          73Zeppelin
          wrote on last edited by
          #4

          :doh:

          1 Reply Last reply
          0
          • M Monty2

            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 !

            T Offline
            T Offline
            Tim Craig
            wrote on last edited by
            #5

            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.

            M 1 Reply Last reply
            0
            • T Tim Craig

              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.

              M Offline
              M Offline
              Monty2
              wrote on last edited by
              #6

              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 !

              T 1 Reply Last reply
              0
              • M Monty2

                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 !

                T Offline
                T Offline
                Tim Craig
                wrote on last edited by
                #7

                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.

                M 1 Reply Last reply
                0
                • T Tim Craig

                  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.

                  M Offline
                  M Offline
                  Monty2
                  wrote on last edited by
                  #8

                  Thanks a bunch for your ideas the Bresenham should work perfectly i think


                  C++ where friends have access to your private members !

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups