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

Username:   Password: 
 RegisterRegister   
 see through colors
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
msimard8




PostPosted: Sat Oct 08, 2005 10:10 am   Post subject: see through colors

Is there a way in turing where you can draw a coloured box in which you can see through.

Thanks
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Oct 08, 2005 11:00 am   Post subject: (No subject)

It won't actually be seethrough, but what you can do is average the RGB values of each pixel in the box with the RGB values of whatever is behind it. You may need whatdotcolour for this, if you don't know the RGB values of what is behind the box.
If you don't want a perfect 50% transparency, you'll have to do something different than simply average them. You'd have to weight RGB values accordingly.
zylum




PostPosted: Sat Oct 08, 2005 9:09 pm   Post subject: (No subject)

i would agree but the thing is, you would have to draw pixel by pixel... which means it will end up *very* slow...

code:
View.Set ("graphics:250;250")
proc drawBox (x1, y1, x2, y2, c, a : int)
    var alpha1 : real := a / 100
    var alpha2 : real := 1 - alpha1
    var r1, g1, b1, r2, g2, b2 : real
    for x : x1 .. x2
        for y : y1 .. y2
            RGB.GetColor (c, r1, g1, b1)
            RGB.GetColor (whatdotcolor (x, y), r2, g2, b2)
            r1 := r1 * alpha1 + r2 * alpha2
            g1 := g1 * alpha1 + g2 * alpha2
            b1 := b1 * alpha1 + b2 * alpha2
            Draw.Dot (x, y, RGB.AddColor (r1, g1, b1))
        end for
    end for
end drawBox

for i : 1 .. 7
    Draw.FillBox (Rand.Int (1, maxx), Rand.Int (1, maxy), Rand.Int (1, maxx), Rand.Int (1, maxy), Rand.Int (1, maxcolor))
end for

drawBox (1, maxy div 2, maxx div 2, maxy, 7, 5)
drawBox (1, 1, maxx div 2, maxy div 2, 7, 25)
drawBox (maxx div 2, 1, maxx, maxy div 2, 7, 50)
drawBox (maxx div 2, maxy div 2, maxx, maxy, 7, 75)
Drakain Zeil




PostPosted: Mon Oct 10, 2005 10:15 am   Post subject: (No subject)

kinda helpful:
http://www.fastgraph.com/help/alpha_blending.html
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: