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. C#
  4. vector based 2D line drawing

vector based 2D line drawing

Scheduled Pinned Locked Moved C#
graphicsquestioncsharp
10 Posts 5 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.
  • D Offline
    D Offline
    dataminers
    wrote on last edited by
    #1

    Hi, How can i vector based 2D line drawing in C#. I want to get smooth line when i get printout, so i don't want to pixel based drawing. Whats is the easiest way? many thanks...

    OriginalGriffO L D J 4 Replies Last reply
    0
    • D dataminers

      Hi, How can i vector based 2D line drawing in C#. I want to get smooth line when i get printout, so i don't want to pixel based drawing. Whats is the easiest way? many thanks...

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Sorry? You need to explain yourself in a reasonable amount of detail to get any real help - we only get exactly what you type to work from: we can't see your screen, access your HDD, or read your mind. What are you printing? what are you printing on? when you say "smooth line" what do you mean? Statistically smoothed, antialiased? Approximated to a particular curve? What have you tried? What did it do that you didn't want, or not do that you did? What help do you need? The better your question, the better the help we can give: conversely, the less information you give, the less help we can provide.

      Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      D 1 Reply Last reply
      0
      • D dataminers

        Hi, How can i vector based 2D line drawing in C#. I want to get smooth line when i get printout, so i don't want to pixel based drawing. Whats is the easiest way? many thanks...

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Using Vector (SVG) Graphics in C# .NET – lasitha.blog();[^]

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

        D 1 Reply Last reply
        0
        • D dataminers

          Hi, How can i vector based 2D line drawing in C#. I want to get smooth line when i get printout, so i don't want to pixel based drawing. Whats is the easiest way? many thanks...

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Ummm....Unless you have a vector monitor (think arcade games like Asteroids and Tempest), you have no choice. Those games are drawn on screen by directly controlling the electron gun in the display tube using analog signals. That simply isn't possible in modern monitors. They use completely different technology to render (and scan) the entire screen instead of just what's drawn on it. You're going to use pixel-based display technology no matter what. So, I think what you're looking for is to avoid the "jaggies" when drawing lines. Well, you can minimize the jaggies, but you cannot eliminate them. Commonly, that's done using anti-aliasing techniques, but exactly what you do is dependent on your application and what you're doing in it.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          D 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Sorry? You need to explain yourself in a reasonable amount of detail to get any real help - we only get exactly what you type to work from: we can't see your screen, access your HDD, or read your mind. What are you printing? what are you printing on? when you say "smooth line" what do you mean? Statistically smoothed, antialiased? Approximated to a particular curve? What have you tried? What did it do that you didn't want, or not do that you did? What help do you need? The better your question, the better the help we can give: conversely, the less information you give, the less help we can provide.

            Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

            D Offline
            D Offline
            dataminers
            wrote on last edited by
            #5

            Actually I want to draw cross line use with X - Y coordinates and save as PDF format. For example FROM New Point(x: 10, y: 10) TO New Point(x: 15, y: 5) AND DRAW LINE. If I use GDI+ library, this line shown pixel. I want to smooth line. MS Paint Pixel based drawing program, If I draw cross line on MS Paint, will be shown pixel. If I use Inkscape (its vector graphics software) and draw cross line after save as PDF file so line will be smooth.

            OriginalGriffO 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Ummm....Unless you have a vector monitor (think arcade games like Asteroids and Tempest), you have no choice. Those games are drawn on screen by directly controlling the electron gun in the display tube using analog signals. That simply isn't possible in modern monitors. They use completely different technology to render (and scan) the entire screen instead of just what's drawn on it. You're going to use pixel-based display technology no matter what. So, I think what you're looking for is to avoid the "jaggies" when drawing lines. Well, you can minimize the jaggies, but you cannot eliminate them. Commonly, that's done using anti-aliasing techniques, but exactly what you do is dependent on your application and what you're doing in it.

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
              Dave Kreskowiak

              D Offline
              D Offline
              dataminers
              wrote on last edited by
              #6

              Actually I want to draw cross line use with X - Y coordinates and save as PDF format. For example; FROM New Point(x: 10, y: 10) TO New Point(x: 15, y: 5) AND DRAW LINE. If I use GDI+ library, this line shown pixel. I want to smooth line. MS Paint Pixel based drawing program, If I draw cross line on MS Paint, will be shown pixel. If I use Inkscape (its vector graphics software) and draw cross line after save as PDF file so line will be smooth.

              1 Reply Last reply
              0
              • L Lost User

                Using Vector (SVG) Graphics in C# .NET – lasitha.blog();[^]

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                D Offline
                D Offline
                dataminers
                wrote on last edited by
                #7

                Thanks for reply, bu i dont want to render image, i just; want to draw line from x-y point to x-y point GDI+ Sample; Pen myPen = new Pen(Color.Blue, 2); Point myStartPoint = new Point(10, 10); Point myEndPoint = new Point(15, 5); myGraphics.DrawLine(myPen, myStartPoint, myEndPoint); But its created pixel by pixel. Real example; If I use MS Paint and i draw cross line, line will be shown pixel by pixel If I use Inkscape (its vector graphics software) and i draw cross line, line will be shown smooth. thanks...

                L 1 Reply Last reply
                0
                • D dataminers

                  Actually I want to draw cross line use with X - Y coordinates and save as PDF format. For example FROM New Point(x: 10, y: 10) TO New Point(x: 15, y: 5) AND DRAW LINE. If I use GDI+ library, this line shown pixel. I want to smooth line. MS Paint Pixel based drawing program, If I draw cross line on MS Paint, will be shown pixel. If I use Inkscape (its vector graphics software) and draw cross line after save as PDF file so line will be smooth.

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  So draw it directly onto the PDF rather than onto a bitmap. What code are you using at the moment to draw it into the PDF file?

                  Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  1 Reply Last reply
                  0
                  • D dataminers

                    Thanks for reply, bu i dont want to render image, i just; want to draw line from x-y point to x-y point GDI+ Sample; Pen myPen = new Pen(Color.Blue, 2); Point myStartPoint = new Point(10, 10); Point myEndPoint = new Point(15, 5); myGraphics.DrawLine(myPen, myStartPoint, myEndPoint); But its created pixel by pixel. Real example; If I use MS Paint and i draw cross line, line will be shown pixel by pixel If I use Inkscape (its vector graphics software) and i draw cross line, line will be shown smooth. thanks...

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    dataminers wrote:

                    If I use MS Paint and i draw cross line, line will be shown pixel by pixel

                    Aight; do that on a 100x100 pixel canvas. Draw a line from (0,0) to (100,100). Now zoom in. The pixels "grow", yes? Traditionally, we save a picture by describing each pixel*. If you save a set of drawing-instructions, like "line (0,0) (x-max, y-max)", then you will always get the smoothest line possible. The line itself is still pixels toggeling, because that is what your screen is showing you: pixels that form a screen. If you look up the resolution of your monitor, then that is expressed in "dots per inch", because dots is what make up your image. As long as we use dots to display stuff, we will have pixels to draw on. --edit The "SVG" filetype is a way of saving graphics in said form; it will look "sharp" when importing in PDF. That's the format Inkscape is using too.

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                    1 Reply Last reply
                    0
                    • D dataminers

                      Hi, How can i vector based 2D line drawing in C#. I want to get smooth line when i get printout, so i don't want to pixel based drawing. Whats is the easiest way? many thanks...

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #10

                      dataminers wrote:

                      i get printout,

                      All printers generally available are pixel based. Thus there is no absolute way to produce a 'line'. There might be expensive line based printers. There used to be but that was when pixel based printing was very rough or even non-existent. What one does these days is to craft a pixel based output that looks like a line. Which should be fairly easy to do now given how small the pixels are these days. There are articles about how to do line approximation using pixels which you can google for.

                      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