Computer Science Canada

Text Flashlight (also Pic Flashlight)

Author:  Catalyst [ Thu Apr 03, 2003 3:13 pm ]
Post subject:  Text Flashlight (also Pic Flashlight)

Something i made cuz i was bored



code:
View.Set ("graphics:640,640,nobuttonbar,offscreenonly")
function distance (x1, y1, x2, y2 : real) : real
    result ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
end distance
var clr : int
for i : 1 .. 255
    clr := RGB.AddColor (i / 255, i / 255, i / 255)
end for
var rad : int := 125
var text : array 1 .. maxrow, 1 .. maxcol of char
for i : 1 .. maxrow
    for k : 1 .. maxcol
        text (i, k) := chr (Rand.Int (35, 65))
    end for
end for
var x, y, z : int
loop
    mousewhere (x, y, z)
    for i : 1 .. maxrow
        for k : 1 .. maxcol
            if distance (x, y, k * 8, maxy - (i * 12)) < rad then
                locate (i, k)
                color (510-round (((distance (x, y, k * 8, maxy - (i * 12)) / rad) * 255)))
                colorback (7)
                put text (i, k) ..
            end if
        end for
    end for
    View.Update
    drawfillbox (0, 0, maxx, maxy, 7)
end loop


I'd like to see you bored more often Very Happy I couldn't understand how you did that until I looked at the code behind it. Really interesting and I learned something new... which so good... so +10Bits for that - Tony

Author:  Catalyst [ Thu Apr 03, 2003 5:44 pm ]
Post subject:  Picture Flashlight

heres something i came up with after the text light,
its based on the same ideas...

** Set it up with a picture, but dont put the radius over 30 or it lag badly **

code:

View.Set ("graphics:150,150,nobuttonbar,offscreenonly,position:300;300")
function distance (x1, y1, x2, y2 : real) : real
    result ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
end distance
var clr : int
var homer : int := Pic.FileNew ("pic.jpg")
var r1, g1, b1 : real
var r2, g2, b2 : array 0 .. 255 of real
for i : 0 .. 255
    RGB.GetColor (i, r2 (i), g2 (i), b2 (i))
end for
var p, p0 : real
var c1, c2 : int := 7
var rad : int := 24
var picA : array 0 .. maxx, 0 .. maxy of int
Pic.Draw (homer, 0, 0, picCopy)
for i : 0 .. maxx
    for k : 0 .. maxy
        picA (i, k) := whatdotcolor (i, k)
    end for
end for
RGB.GetColor (c1, r1, g1, b1)
const a := 50
var x, y, z : int
loop
    mousewhere (x, y, z)
    for i : x - rad .. x + rad
        for k : y - rad .. y + rad
            if i > 1 and i < maxx and k > 1 and k < maxy then
                if distance (x, y, i, k) < rad then
                    p := (distance (x, y, i, k) / rad) * 100
                    p0 := 100 - p
                    RGB.SetColor (1, (((r1 * p) + (r2 (picA (i, k)) * p0)) / 2) / a, (((g1 * p) + (g2 (picA (i, k)) * p0)) / 2) / a, (((b1 * p) + (b2 (picA (i, k)) * p0)) / 2) / a)
                    drawdot (i, k, 1)
                end if
            end if
        end for
    end for
    View.Update
    drawfillbox (0, 0, maxx, maxy, black)
end loop

Author:  Asok [ Thu Apr 03, 2003 8:50 pm ]
Post subject: 

*bows to catalyst*

WE ARE NOT WORTHY!!

Very Happy

Author:  Homer_simpson [ Sat Apr 05, 2003 7:47 pm ]
Post subject: 

sweet 8)

Author:  nate [ Sun Apr 06, 2003 5:12 pm ]
Post subject:  man ur good

Catalyst how long have u been using turing cause ur amazin at it!!

-nate

Author:  Catalyst [ Sun Apr 06, 2003 6:29 pm ]
Post subject: 

ive been doin turing for 6 months

Author:  Prince [ Mon Apr 07, 2003 10:08 am ]
Post subject: 

6 months Shocked ... and u say u made this wen ur bored?? Confused

Author:  Prince [ Mon Apr 07, 2003 10:11 am ]
Post subject: 

did u make this on turing 4 cus its not workin for me (still usin 3.1.1 Sad )

Author:  Tony [ Mon Apr 07, 2003 10:52 am ]
Post subject: 

yes, it was made in v4
RGB. and View.Update are v4 only

Author:  Delta [ Mon Apr 07, 2003 12:14 pm ]
Post subject:  Maybe in turing but...

Catalyst how long have you been programming though, not just in TURING but in other languages like BASIC, Pascal, C/C++, VB or something else???

Author:  Catalyst [ Mon Apr 07, 2003 2:32 pm ]
Post subject: 

ive been doin turing since october and have been doin c++ and opengl for the past month or so (didnt do ne thing b4 turing)

Author:  Martin [ Tue Apr 22, 2003 8:17 pm ]
Post subject: 

Just a quick question, what's a for? I see that it changes the shading of the flashlight, but why?

Author:  Catalyst [ Tue Apr 22, 2003 8:50 pm ]
Post subject: 

a converts one the value i get with, for ex.
code:

((r1 * p) + (r2 (c2) * p0)) / 2)

from a percentage to a realnumber 0 to 1

it affects the brightness and dropoff of the shading
i have it set at 50 so it is brighter (technically it should be 100)

note: if you go below 50 you can get some interesting results

Author:  Martin [ Tue Apr 22, 2003 10:49 pm ]
Post subject: 

Yeah, I noticed that

Author:  HeTeRiC [ Mon Nov 17, 2003 8:04 pm ]
Post subject:  Holy CraP!

6 months and catalyst is doint that when here's BOARD!!!
i've been prooging turing fer about 2 hours now and i had no idea turning was capable of something like that!! Claping Claping Claping
amazing! you've inspired me to learn turing inside and out!!!!
ClapingClapingClaping

Author:  Mazer [ Mon Nov 17, 2003 8:27 pm ]
Post subject:  Re: Holy CraP!

HeTeRiC wrote:
inspired me to learn turing inside and out!!!!


careful now, if you do, you'll end up regretting it! Wink

Author:  rizzix [ Mon Nov 17, 2003 8:57 pm ]
Post subject: 

listen to his words of wisdom

Author:  Catalyst [ Mon Nov 17, 2003 9:10 pm ]
Post subject: 

i very much agree

Author:  santabruzer [ Thu Nov 20, 2003 6:44 pm ]
Post subject: 

Catalyst is freaking amazing.. though i started just this month... hopefully i'll get to the same level as him...
Catalyst is my role model!

Author:  JayLo [ Thu Nov 20, 2003 10:30 pm ]
Post subject: 

don't idolize. although catalyst is that good, come on people. common sense?


: