Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have been writing a small "ribbon" like screensaver program using bezier curves.
It all works fine apart from a couple of colouring routines such as the snippet below.

d1,d2,d3,d4 represent the start, end and control points of the curve.
The formula calculates a couple of distance values and stores them in the xp/yp variables and these values are then used as rgb values.

Dim xp As Integer = Sqrt((d1.X - d4.X) ^ 2 + (d1.Y - d4.Y) ^ 2)
Dim yp As Integer = Sqrt((d2.X - d3.X) ^ 2 + (d2.Y - d3.Y) ^ 2)
mypen.Color = Color.FromArgb(1, xp Mod 255, yp Mod 255, xp + yp Mod 255)

Again the code works fine and produces some nice effects. However the Alpha value set to a value of 1 will cause the "shader" to produce a transparent colour occasionally. i.e the desktop or windows behind my black background will be shown inside the curves.

upping the alpha value cures the problem but causes washed out looking colours rather than the vibrant colours produced with a value of 1.

I have tried changing the forms transparency key and looking for rgb values that match the key then changing them to a near value instead but none of this seems to work. (I may have done something wrong here)

So anyone have any ideas?

[edit]
A picture to show the problem in action :

https://dl.dropboxusercontent.com/u/47121409/umm.jpg[
Posted
Updated 14-Sep-14 9:05am
v4

What else would you expect? The A value of 1 means very transparent color. Read this: "To create an opaque color, set alpha to 255":
http://msdn.microsoft.com/en-us/library/at1k42eh%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
Comments
5everin 15-Sep-14 7:26am    
I want transparent colours. I just want them on a black background, not "cutting" through it to reveal the desktop.
Sergey Alexandrovich Kryukov 15-Sep-14 10:31am    
Then chose proper transparency... :-)
—SA
Ok the penny suddenly dropped :)

Me.AllowTransparency = False


Though again this cures the problem. The program can also run in a transparent window over the desktop. So I thought a simple toggle of the boolean would do it. It seems not. First change is fine but then the program appears to ignore any further toggling.

have tried :

Me.AllowTransparency = Not Me.AllowTransparency
and if/then statements and both seem to do the same thing.

Still I guess my question is answered.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 14-Sep-14 21:32pm    
No, it is not answered. This property it totally irrelevant to ARGB transparency.
—SA
5everin 16-Sep-14 9:18am    
I accept what you say. But it does cure the problem.

I think what is happening is that when the b' curves are drawn on top of previously drawn b' curves the blending that takes place sometimes results in a shade that matches the forms transparency key and the problem occurs. So its not something I can control without adding a ton of complexity and probably slowing down the program to the point of a slide show.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900