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

Username:   Password: 
 RegisterRegister   
 Partially Transparent/Semitransparent Pictures
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Albrecd




PostPosted: Fri Dec 30, 2005 1:16 pm   Post subject: Partially Transparent/Semitransparent Pictures

Is it possible to cause part of a picture to become transparent or semitransparent when the mouse is moved over it or another picture is moved over it (possibly with Xor?)?

What I am trying to do is make something like an X-ray effect. I have a background image and another image behind it and I want to make the image show through.

Thanks. Smile
Sponsor
Sponsor
Sponsor
sponsor
ecliptical




PostPosted: Fri Dec 30, 2005 3:38 pm   Post subject: (No subject)

With the new Turing (4.1) it is...don't think 4.03 can...
Cervantes




PostPosted: Fri Dec 30, 2005 4:28 pm   Post subject: (No subject)

You can use whatdotcolour to get the colour of the pixel, then use the RGB module to determine the red, green, and blue components of that colour. You can then average them with the RGB components of the cooresponding pixel in the other image, to get 50% transparency.

Of course, whatdotcolour only returns the closest match in the current Turing colour palette. To improve the accuracy of the effect (and I say this is a must), you'd have to alter the colour palette using RGB.SetColour. However, Turing can only hold 256 colours at once, so you'd have to set the palette to a certain range of colours, get the best match from there with whatdotcolour, then reset it to the next range of colours and get the best match from this palette. Continue doing this until you have, for example, 256 "best matches". That means you'd have done 256 whatdotcolours (for each pixel, remember) and changed the palette 256 times. Once you've got your 256 "best matches", you make a palette of those 256 "best matches" and use whatdotcolour to get the real "best match". At the end of this process, you will have used matched the colour against 256*256=65536 colours.

Hugely slow? I'd say so.
[Gandalf]




PostPosted: Sat Dec 31, 2005 2:01 am   Post subject: (No subject)

There have also been many tries at this previously. If Cervantes' explanation is not enough I suggest using the compsci search function and looking for 'transparency' in the Turing section. Delos made a quite successful program which does just this here.
do_pete




PostPosted: Sat Dec 31, 2005 2:20 am   Post subject: (No subject)

Just make it sothat every other pixel is transparent. That'll give the illusion of transparency. I also believe there is a procedure, Pic.Blend or something like that that could be used
zylum




PostPosted: Sat Dec 31, 2005 7:11 pm   Post subject: (No subject)

maybe this will help... i know its not exactly what youre looking for but its an old file i have.. it draws a bunch of random rectangles and then it draws four rectangles with different transparencies.

code:
View.Set ("graphics:250;250")
proc drawBox (x1, y1, x2, y2, clr, alpha : int)
    var alpha1 : real := alpha / 100
    var alpha2 : real := 1 - alpha1
    var r1, g1, b1, r2, g2, b2 : real
    for x : x1 .. x2
        for y : y1 .. y2
            RGB.GetColor (clr, 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)
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  [ 6 Posts ]
Jump to:   


Style:  
Search: