Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Polygon per-pixel control
Index -> Programming, Turing -> Turing Submissions
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
RaPsCaLLioN




PostPosted: Fri Apr 01, 2005 9:36 pm   Post subject: (No subject)

That is pretty fast. Mine's a tad quicker because your running 11 divides per polygon. And if you do this to your code...

code:
import GUI in "%oot/lib/GUI"
setscreen ("offscreenonly")

var X : array 1 .. 3 of int
var Y : array 1 .. 3 of int

proc NewPoints
    for i : 1 .. 3
        X (i) := Rand.Int (maxx div 4, maxx div 4 * 3)
        Y (i) := Rand.Int (maxy div 4, maxy div 4 * 3)
    end for
    var temp : int
    for i : 1 .. 2
        for j : i + 1 .. 3
            if Y (i) < Y (j) then
                temp := X (i)
                X (i) := X (j)
                X (j) := temp
                temp := Y (i)
                Y (i) := Y (j)
                Y (j) := temp
            end if
        end for
    end for
end NewPoints

proc ShadeTriangle
    var b1, m1, b2, m2, b3, m3 : real
    m1 := (Y (1) - Y (3)) / (X (1) - X (3) + 0.0001) + 0.0001
    b1 := Y (1) - m1 * X (1)
    m2 := (Y (1) - Y (2)) / (X (1) - X (2) + 0.0001) + 0.0001
    b2 := Y (2) - m2 * X (2)
    m3 := (Y (2) - Y (3)) / (X (2) - X (3) + 0.0001) + 0.0001
    b3 := Y (3) - m3 * X (3)

    for decreasing y : Y (1) .. Y (2)
        for x : min (round ((y - b1) / m1), round ((y - b2) / m2)) .. max (round ((y - b1) / m1), round ((y - b2) / m2))
            drawdot (x, y, 7)
        end for
    end for
    for decreasing y : Y (2) .. Y (3)
        for x : min (round ((y - b1) / m1), round ((y - b3) / m3)) .. max (round ((y - b1) / m1), round ((y - b3) / m3))
            drawdot (x, y, 7)
        end for
    end for
    View.Update
end ShadeTriangle

var mx, my, md : int
GUI.SetBackgroundColour (7)
loop
    GUI.SetBackgroundColour (7)
    NewPoints
    Draw.FillPolygon (X, Y, 3, 60)
    ShadeTriangle
    loop
        mousewhere (mx, my, md)
        exit when md = 1
    end loop
    cls
end loop


We can see some flaws.
Sponsor
Sponsor
Sponsor
sponsor
Drakain Zeil




PostPosted: Wed Apr 06, 2005 6:14 am   Post subject: (No subject)

Polygon resources.

http://claymore.engineer.gvsu.edu/~jackh/eod/software/software-108.html
http://www.math.montana.edu/Rweb/Rhelp/polygon.html
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 17 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: