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

Username:   Password: 
 RegisterRegister   
 alpha blending
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HyperFlexed




PostPosted: Mon Nov 08, 2004 9:34 pm   Post subject: alpha blending

I searched the forum, but didn't find much. none really.

anyone have a link to a site that describes the theory behind alpha blending (2d)?
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Mon Nov 08, 2004 9:55 pm   Post subject: (No subject)

attached is my GFX libaray that implements RGBA functionality

here's one way of using it:

code:


GFXDrawDot(x, y, RGBAi(255, 123, 100, 0.5))



this will draw a dot with the color (255, 123, 100, 0.5) (R, G, B, alpha index) at location (x, y)


the function RGBAi returns a temporary RGBA object that you can pass to the GFXDrawDot proc.

it is temporary cuz it changes everytime you call the RGBAi function.. so use it more like a the way i showed you up there in teh example.

if you want a non-temporary object that you can use over and over again.. u can use the GFXCreateRGBAr function which returns a new object that u can use at your disposal. it accepts the same arguments as the RGBAi function... note it ends with r instead of i ... cuz r represents a real number while i represents an integer.. the real value of the interger = the interger / 255.. simple as that.. basically what that means if u wanted the color red which is (255, 0, 0) just divide all the (R, G, B) components by 255.. the alpha value is always real and is a value from 0.0 to 1.0

if ever you want to use the GFXCreateRGBAr function it would be something like this:
code:

var RGBA : bright_red := GFXCreateRGBAr(1.0, 0.0, 0.0, 1.0)
GFXDrawDot(x, y, bright_red)
GFXDisposeRGBA(bright_red)

note always dispose of the object

there's anothe fucntion in the library that is quite useful... namely GFXFlattenRGBA, what it does is it take a RGBA object and blends it with any turing defined colour.... and returns a new temprorary turing defined color that represents the result of the blending.. also note.. the GFXDrawDot finction will automatically blend the RGBA colour with the background colour.

note i dont have any other function implemented except the drawdot.. you could use standard turing function along with the GFX function if you wish if you wish to use other functions beside drawdot.. and to do so basically requires you to fattern any RGBA object with the background and use that result in any of those turing functions' colour parameter.



GFX.tu
 Description:

Download
 Filename:  GFX.tu
 Filesize:  7.82 KB
 Downloaded:  154 Time(s)

rizzix




PostPosted: Mon Nov 08, 2004 10:25 pm   Post subject: (No subject)

sorry about the turing libaray.. cuz it one of my old libraries.. and its the only one that was involved in colour mixing etc.. (turing was/is soo limited)... i dont use turing anymore.. so i felt like gettin rid of it.. yet not loosing it completly. ha!
HyperFlexed




PostPosted: Tue Nov 09, 2004 6:17 pm   Post subject: (No subject)

ummm... not exactly what I wanted. I guess I'll have to pick apart your code and see if I can learn the algorithm.
Display posts from previous:   
   Index -> General Programming
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: