
-----------------------------------
tristanbryce7
Tue Dec 04, 2012 10:46 pm

Using loops to get all possible x,y co-ordinates of a value
-----------------------------------
Hey, I wanted to know if there was any way to use loops, to get all the possible x,y co-ordinates in an output window? so far all I can manage to figure out is, how to get all values for (1,y), where y is all the y values of the co-ordinate up to the max y co-ordinate, but thats only when x = 1, how would I change my code to get it to get all the possible co-ordinates in my program. How would I use the loop statement to acheive this?



var x, y : int := 0

setscreen ("graphics:600;600")

forward proc code

var dexter : int
var stream : int
open : stream, "turing.txt", put

dexter := Pic.FileNew ("dexter.jpg")

Pic.Draw (dexter, 0, 0, picCopy)

body proc code


    for lool : 1 .. maxy
        x := 1
        y := y + 1
        put : stream, "drawdot(", x, ",", y, ",", whatdotcolor (x, y), ")"
    end for


end code

code


-----------------------------------
Insectoid
Tue Dec 04, 2012 11:04 pm

RE:Using loops to get all possible x,y co-ordinates of a value
-----------------------------------
You might try putting a loop inside a loop.

-----------------------------------
tristanbryce7
Tue Dec 04, 2012 11:39 pm

Re: Using loops to get all possible x,y co-ordinates of a value
-----------------------------------

var x, y : int := 0

setscreen ("graphics:600;600")

forward proc code

var dexter : int
var stream : int
open : stream, "turing.txt", put

dexter := Pic.FileNew ("dexter.jpg")

Pic.Draw (dexter, 0, 0, picCopy)

body proc code


    for xloop : 1 .. maxx
        x := x + 1


        for yloop : 1 .. maxy
            put : stream, "drawdot(", x, ",", y, ",", whatdotcolor (x, y), ")"
            y := y + 1

        end for
        y := 0
    end for

end code

code



It took the longest time ever to run :( , and the final output to draw the dude was like 300,000+ lines, but i got it though, after I got the output on the turing.txt file i copied and pasted, and voila, done. I dont know of any better way to do it though , if you could tell me a better way that I did, id appreciate it (for like getting turing to draw it for you). Did you have a different idea in mind, if you did, id love to know :), cuz this seems pretty inefficent lol (300,000 lines toooo much xD)

-----------------------------------
Tony
Wed Dec 05, 2012 12:02 am

RE:Using loops to get all possible x,y co-ordinates of a value
-----------------------------------

draw black dot
draw black dot
draw black dot
draw black dot
draw black dot

it can be shortened to 

draw black line, length 5


Welcome to the exciting ideas of http://en.wikipedia.org/wiki/Image_compression

-----------------------------------
Zren
Wed Dec 05, 2012 12:24 pm

RE:Using loops to get all possible x,y co-ordinates of a value
-----------------------------------
You do realize that when the window's width/height is 600, maxx and maxy are equal to 599 right? Which is the last coordinate on screen (599, 599) in your case. The screen coordinates start from (0, 0) and go to (window.width - 1, window.height - 1).

This beings up the matter of your for loops. Which cover the range of:
[code]
x = 0
for each value represented as x2 (or xloop in your case) in the range 1 