View Full Version : arg.graphics.FillRectangle transpency?
How can I set a transparent value for a fillRectangle?
|
|
Problem might be greater then I thought. I have a transparent form and I want a semi transparent label in it. Either I get fully transparent or solid.
Gravey
10-28-2009, 06:12 AM
where exactly are you drawing your rectangle? i can draw on to a dotnet form and a dotnet label and the opacity of the form is retained just fine. see below: (
global testRoll
try( testRoll.close(); testRoll.dispose() )catch()
local fillColor = (dotnetclass "System.Drawing.Color").fromARGB 255 100 150 200
local fillBrush = dotnetobject "System.Drawing.SolidBrush" fillColor
fn FillLabel sender arg =
(
arg.graphics.FillRectangle fillBrush (dotnetobject "System.Drawing.Rectangle" 5 5 30 30)
)
fn OnFormPaint sender arg =
(
arg.graphics.FillRectangle fillBrush (dotnetobject "System.Drawing.Rectangle" 50 50 100 100)
)
local lab = dotnetobject "System.Windows.Forms.Label"
lab.width = 200
lab.height = 50
lab.text = "test text"
lab.TextAlign = lab.TextAlign.MiddleCenter
lab.backColor = (dotnetclass "System.Drawing.Color").fromARGB 128 200 200
testRoll = dotnetobject "System.Windows.Forms.Form"
testRoll.width = 200
testRoll.height = 200
testRoll.opacity = 0.5
testRoll.controls.Add lab
dotnet.addEventHandler testRoll "Paint" OnFormPaint
dotnet.addEventHandler lab "Paint" FillLabel
testRoll.Show()
)
That is just making everything have the same transparency. What I need is a 100% transparent form with varying transparencies on rectangles.
global testRoll
try( testRoll.close(); testRoll.dispose() )catch()
fillColor = (dotnetclass "System.Drawing.Color").fromARGB 50 100 150 200
fillBrush = dotnetobject "System.Drawing.SolidBrush" fillColor
formBackColor=(dotNetClass "system.drawing.color").fromArgb 0 255 0
fn OnFormPaint sender arg =
(
arg.graphics.FillRectangle fillBrush (dotnetobject "System.Drawing.Rectangle" 50 50 100 100)
)
testRoll = dotnetobject "System.Windows.Forms.Form"
testRoll.width = 200
testRoll.height = 200
-- testRoll.opacity = 0.5
showProperties testRoll
testRoll.backColor=formBackColor
testRoll.TransparencyKey=formBackColor
dotnet.addEventHandler testRoll "Paint" OnFormPaint
testRoll.Show()
I should point out that in that example the fill color for the rectangle has a value of 50 so that it why it is coming out the color that it is. Change and the color will change to the formBackColor until you hit a low enough number and the rectangle will be come transparent.
CGTalk Moderation
10-28-2009, 02:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.