Page 1 of 1

"Noise" drawing...

PostPosted: Thu May 10, 2007 5:32 am
by Sgt. Sparky
here is a way to draw pixles that shade from the center(darkest) to the edges(lightest) with shading from the middle,
put any of these codes in the draw actor event of your canvas:
code with "noise" and shading,
Code: Select all
float i, i2, R, G, B;
while(i < width)
{
    for(i2 = 0; i2 < height; i2++)
    {
    R = rand(55) + (distance(i, i2, x + width / 2, y + height / 2 ) * (width/2)) / 200;
    G = rand(55) + (distance(i, i2, x + width / 2, y + height / 2 ) * (width/2)) / 200;
    B = rand(55) + (distance(i, i2, x + width / 2, y + height / 2 ) * (width/2)) / 200;
    setpen(R, G, B, 0, 1);
    putpixel(i, i2);
    }
    i++;
}
while(i2 >= height)i2 = 0;
while(i >= height)i = 0;


code with just shading,
Code: Select all
float i, i2, R, G, B;
while(i < width)
{
    for(i2 = 0; i2 < height; i2++)
    {
    R = (distance(i, i2, x + width / 2, y + height / 2 ) * (width/2)) / 200;
    G = R
    B = G
    setpen(R, G, B, 0, 1);
    putpixel(i, i2);
    }
    i++;
}
while(i2 >= height)i2 = 0;
while(i >= height)i = 0;

code with just "noise"
Code: Select all
float i, i2, R, G, B;
while(i < width)
{
    for(i2 = 0; i2 < height; i2++)
    {
    R = rand(255);
    G = rand(255);
    B = rand(255);
    setpen(R, G, B, 0, 1);
    putpixel(i, i2);
    }
    i++;
}
while(i2 >= height)i2 = 0;
while(i >= height)i = 0;


:D:D:D
just another random canvas function,
although it is not as cool as Gogo's canvas thing. :)

PostPosted: Thu May 10, 2007 6:01 am
by Sgt. Sparky
oh,
and here is a cool light effect sort of things that makes it look almost like a box of light in the dark,
Code: Select all
float X, Y, SHADE;
for(X = 0; X < 36000; X++)
{
    moveto(width / 2, height / 2);

    SHADE = cos(X)*255;
    setpen(SHADE, SHADE / 1.1, 0, 0, 1);
    lineto(sin(Y) * height, cos(X) * width);
    Y += .01;
}

just put that on the create actor event of the view. :)

PostPosted: Fri May 11, 2007 12:39 pm
by morcior
awww I was hoping for some perlin noise :(

drawing random pixels was already covered in the tutorials at trajectorylabs.com Sparky

PostPosted: Fri May 11, 2007 11:29 pm
by Game A Gogo
Nice!
There is an error on the second script, you forgot to place an ";" at the 8th and 7th line.

thx for the compliment :P