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

Username:   Password: 
 RegisterRegister   
 Rorschach-esque Image Creator
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lapsus Antepedis




PostPosted: Wed Jun 01, 2005 6:04 pm   Post subject: Rorschach-esque Image Creator

I came up with this idea after writing a program that mirrors an image vertically then mirrors the result horizontally... I then thought of the inkblot tests, and out came this...

code:

/*
 +----------------------------------------------------------------------+
 | This program was created by Lapsus Antepedis in 2005, It creates a   |
 | series of rorschach-esque images.                                    |
 | Please do not rip off my code, at least tell me what you use it for. |
 | Thank you for your time.                                             |
 +----------------------------------------------------------------------+
*/

var window : int := Window.Open ("graphics:400;400, title: Rorschach-esuqe Image Maker")
View.Set ("offscreenonly")
var pixl : array 0 .. maxx, 0 .. maxy of int

put "Generating Rorschach Image..."
put "This may take a few seconds, please be patient..."
View.Update

cls

proc brownian (steps : int)

    var x, y, move : int
    x := maxx div 2
    y := maxy div 2

    for i : 1 .. steps
        drawdot (x, y, Rand.Int (1, 255))
        randint (move, 1, 4)
        if move = 1 and x < maxx + 1 then
            x += 1
        elsif move = 2 and x > -1 then
            x -= 1
        elsif move = 3 and y < maxy + 1 then
            y += 1
        elsif move = 4 and y > -1 then
            y -= 1
        end if
    end for
end brownian


proc fillarray
    for x : 0 .. maxx
        for y : 0 .. maxy
            pixl (x, y) := whatdotcolour (x, y)
        end for
    end for
end fillarray

proc drawpictor
    for x : 0 .. maxx
        for y : 0 .. maxy
            drawdot (x, y, pixl (x, y))
        end for
    end for
end drawpictor

proc verticalmirror
    for decreasing x : maxx .. maxx div 2
        for y : 0 .. maxy
            drawdot (x, y, pixl (maxx - x, y))
        end for
    end for
end verticalmirror

proc horizontalmirror
    for y : 0 .. maxy div 2
        for x : 0 .. maxx
            drawdot (x, y, pixl (x, maxy - y))
        end for
    end for
end horizontalmirror

proc rorschach
    brownian (444444)
    fillarray
    drawpictor
    verticalmirror
    fillarray
    horizontalmirror
end rorschach

loop
    rorschach
    View.Update
    delay (2000)
    cls
end loop


The procedure names are fairly self-explanatory, but if you have any questions about this program, feel free to ask! Thoughts and comments are welcome.

EDIT: Before you ask, I used the number 444444 after realizing that I needed to scale the window down from 900x900, so I used the same ratio to get a reasonable of dots... (A bit to the first person who can tell me what the original number of steps was in the 900x900 version )
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Wed Jun 01, 2005 7:01 pm   Post subject: (No subject)

Pretty neat stuff. However, there is a slightly easier way of doing this.

Say you want just a vertical mirror. Well, divide your screen up into two halves (in your head at least), and draw your shape (or half thereof) on the one side.
Next, take a Picture of that side using Pic.New(), and finally Pic.Draw it using Pic.Mirror().
Essentially, this will speed up your programme, and can be extended to four quadrants using Pic.Flip() as well.
(Or more using a combination of Pic.Rotate() and the above).

Keep up the good work though.
RaPsCaLLioN




PostPosted: Thu Jun 02, 2005 5:54 pm   Post subject: (No subject)

Why do you use the procedure name 'brownian'? I thought Brownian was a straight line algorithm, not a random motion.
MihaiG




PostPosted: Thu Jun 02, 2005 6:59 pm   Post subject: (No subject)

brownian motion refers to the iratic motion of particles... not straight
RaPsCaLLioN




PostPosted: Fri Jun 03, 2005 2:23 pm   Post subject: (No subject)

Yeah.. my bad. I confused w/ Bresenham.
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 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: