drarem Posted May 5, 2016 Share Posted May 5, 2016 What's an easy way to get the entire screen to fade to white or fade to black? Thanks. Quote Link to comment Share on other sites More sharing options...
Genebris Posted May 5, 2016 Share Posted May 5, 2016 http://www.leadwerks.com/werkspace/page/api-reference/_/context/contextdrawrect-r724 Quote Link to comment Share on other sites More sharing options...
Josh Posted May 6, 2016 Share Posted May 6, 2016 Yeah, combine that with alpha blending. See the other context commands. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted May 6, 2016 Share Posted May 6, 2016 simple example of fading to black and to white: window = Window:Create("fade example",0,0,800,600, Window.Center) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:Move(0,0,-3) light = DirectionalLight:Create() light:SetRotation(35,35,0) model = Model:Box() model:SetColor(0,0,1) alpha = 0.01 toggle = 0.005 color = 1 while window:KeyDown(Key.Escape)==false do if window:Closed() then break end model:Turn(0,Time:GetSpeed(),0) if alpha>=1.0 then toggle = -0.005 end if alpha<=0.0 then toggle = 0.005 color = 1 - color end alpha = alpha + toggle Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) context:SetColor(color,color,color,alpha) context:DrawRect(0,0,800,600) context:SetColor(1,0,0,1) context:DrawText(string.format("alpha: %.2f",alpha),0,2) context:DrawText("color: "..color..", "..color..", "..color,0,22) context:SetBlendMode(Blend.Solid) context:Sync(true) end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
cassius Posted May 6, 2016 Share Posted May 6, 2016 Bits of code like that should be kept somewhere, maybe a code snipets section. Very usefull. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Josh Posted May 6, 2016 Share Posted May 6, 2016 Bits of code like that should be kept somewhere, maybe a code snipets section. Very usefull. http://www.leadwerks.com/werkspace/page/workshopcategory?tags=Script&queryType= Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
drarem Posted May 6, 2016 Author Share Posted May 6, 2016 thanks, the drawrect works great Quote Link to comment Share on other sites More sharing options...
CangoJoe Posted November 20, 2017 Share Posted November 20, 2017 On 5/5/2016 at 3:26 PM, Genebris said: http://www.leadwerks.com/werkspace/page/api-reference/_/context/contextdrawrect-r724 Anyone know where can I find this link now? I was looking for a fade-to-black example. Thanks Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 20, 2017 Share Posted November 20, 2017 That link is just the contect:DrawRect() from the old command index. If you look 5 posts up, I have code that shows how to fade from black to white and back to black - just modify it for your needs: 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
CangoJoe Posted November 24, 2017 Share Posted November 24, 2017 Ok cool thanks, I'm just trying to wrap my head around the purpose of DrawRect() in your sample. Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 24, 2017 Share Posted November 24, 2017 4 minutes ago, CangoJoe said: Ok cool thanks, I'm just trying to wrap my head around the purpose of DrawRect() in your sample. All I am doing is drawing a rectangle the same size as the window/context and fading to black/white by just adjusting the alpha component in the rectangle's color settings. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
CangoJoe Posted November 24, 2017 Share Posted November 24, 2017 Interesting, So if I were to hide the original camera with this script running and show another camera, should the alpha level would persist in the new camera? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.