Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: curve with straight lines

  1. #1
    Banned
    Join Date
    Jan 2002
    Location
    scotland
    Posts
    1,938

    Default curve with straight lines

    does anyone know how you would draw a curve with straight lines? i know what it looks like. a set of increasing gradient lines from the horizontal and vertical planes. but i can't do it all using my way. can someone give me a step by step process or a link please?

  2. #2

    Default

    Cloud, your too smart. IS this what you are looking for? :LINKAGE

  3. #3
    Old school, like an old fool. Flying Mullet's Avatar
    Join Date
    Apr 2003
    Location
    Napping in a peach tree.
    Posts
    19,185
    Articles
    6
    Blog Entries
    7
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    Quote Originally Posted by bipper
    Cloud, you're too smart. IS this what you are looking for? :LINKAGE
    Figaro Castle

  4. #4
    Banned
    Join Date
    Jan 2002
    Location
    scotland
    Posts
    1,938

    Default

    okay i worked it out. now my little program is complete.

  5. #5
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Program? Ah, so that's what you were taking about. I thought you wanted to draw it by hand or something along those lines. :rolleyes2

  6. #6
    Banned
    Join Date
    Jan 2002
    Location
    scotland
    Posts
    1,938

    Default

    yeah well i wanted to understand how it was done by hand first so i got the idea.

  7. #7

    Default

    Quote Originally Posted by Flying Mullet
    lol, yup your such a smart primate

    Ah cloud, why didn't you say it was a program, we had to do about the same in an intro to video game programming class. Actually, I think I have had to do it in 4 different classes, all with different languages..... redundant really

    You'res truly,

    Bipper

  8. #8
    Banned
    Join Date
    Jan 2002
    Location
    scotland
    Posts
    1,938

    Default

    i don't think many people code in ada/jewl.

  9. #9
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Code:
    #!/usr/bin/ruby
    require 'gtk2'
    require 'gnomecanvas2'
    
    class CurveFromLines
    
        def initialize(size=150)
            Gtk.init()
    
    
            @window = Gtk::Window.new()
            @window.set_title("LinesFromCurve")
            @window.set_default_size(size*2,size*2)
            @window.signal_connect("delete_event") { Gtk::main_quit() }
    
            @canvas = Gnome::Canvas.new()
    
            @canvas.set_center_scroll_region(true)
            @canvas.set_pixels_per_unit(0.8)
            @root = @canvas.root
    
            0.upto(size) do |x|
                color = 65535 - (x * 65535 / size)
                line = Gnome::CanvasLine.new(
                    @root,
                    { 
                        :points => [[0,x], [size-x,0]],
                        :"fill-color-gdk" => Gdk::Color.new(color,color,color)
                    }
                )
                line2 = Gnome::CanvasLine.new(
                    @root,
                    { 
                        :points => [[0,-x], [-size+x,0]],
                        :"fill-color-gdk" => Gdk::Color.new(color,color,color)
                    }
                )
            end
    
            @vbox = Gtk::VBox.new()
            @vbox.pack_start(@canvas)
    
            @window.add(@vbox)
            @window.show_all()
            Gtk.main()
        end
    end
    
    curve = CurveFromLines.new(250)
    Attached Images Attached Images

  10. #10
    ..a Russian mountain cat. Yamaneko's Avatar
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    15,927
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    In the real world aren't all curves a set of increasing gradient lines?

  11. #11

    Default

    No, in the real world, curves are approximated using infinitesimally small lines.

    "Gradient lines" don't even exist - you're probably referring to infinitely small lines.

  12. #12

    Default

    Ada is just fine. No harder than any other language really.

    And I like that Unne

    Bipper

  13. #13
    Banned
    Join Date
    Jan 2002
    Location
    scotland
    Posts
    1,938

    Default

    unne did it silly. it was too long. and it don't look like ada to me.

  14. #14

    Default

    Who cares. ADA is next to worthless, and Unne created his for a Linux enviroment. Assuming you may have used a differet complier, which CAN support different features, regaurdless of what ADAvangalists claim

    Sides, this programming language looks like a simple cross between basic and c/C++. It makes me sick. Seriously though, the language is quite primative, and can tend to be bulky. Nothing speacial or new in my eyes.

    Bipper

  15. #15
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Quote Originally Posted by Cloud No.9
    unne did it silly. it was too long. and it don't look like ada to me.
    Ah, too long. OK...

    <pre style="font-size:8pt">perl -MTk -MTk::Canvas -e '$c=MainWindow->new->Canvas->pack;$c->createLine(0,$_,250-$_,0)for(0..250);MainLoop'</pre>
    I agree ADA is next to worthless.

    EDIT: Ruby is only like C on the surface. Ruby is pretty nice. The code I wrote looks like C because GTK is based on C and it's just using a Ruby wrapper over GTK. A Ruby-ish program written in Ruby looks quite different.
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •