xXBlasterXx Posted April 7, 2021 Share Posted April 7, 2021 Hi, I wanted create black dxDrawRectangle which alpha is from left 255 to right 0. Something like this Image isn't my. Please help, I know so far that I should use Interpolatebetween but don't have idea how to. Link to comment
XaskeL Posted April 7, 2021 Share Posted April 7, 2021 Try creating something like this in a shader (it's really easy) or make a similar background in Photoshop. 1 Link to comment
ITrex Posted April 7, 2021 Share Posted April 7, 2021 23 minutes ago, XaskeL said: Try creating something like this in a shader (it's really easy) or make a similar background in Photoshop. How is this IDE for shader edit? Link to comment
xXBlasterXx Posted April 7, 2021 Author Share Posted April 7, 2021 2 hours ago, XaskeL said: Try creating something like this in a shader (it's really easy) or make a similar background in Photoshop. Could you explain more? I don't know how to use this. I was thinking smoething like that (from user Pa3ck), above is for 2-colors dxDraw, I need for alpha addEventHandler ("onClientResourceStart", resourceRoot, function () texture = dxCreateTexture (300, 25) local pixels = dxGetTexturePixels (texture) for i=0,300 do local progress = 100 / 300 * i / 100 local r, g, b = interpolateBetween ( 255, 0, 0, 255, 255, 0, progress, "Linear") for j=0,25 do dxSetPixelColor (pixels, i, j, r, g, b, 255) end end dxSetTexturePixels (texture, pixels) texture2 = dxCreateTexture (600, 25) local pixels2 = dxGetTexturePixels (texture2) for i=0,300 do local progress = 100 / 300 * i / 100 local r, g, b = interpolateBetween ( 255, 255, 0, 0, 255, 0, progress, "Linear") for j=0,25 do dxSetPixelColor (pixels2, i, j, r, g, b, 255) end end dxSetTexturePixels (texture2, pixels2) end) addEventHandler ("onClientRender", root, function () dxDrawImage (300, 300, 300, 25, texture) dxDrawImage (600, 300, 300, 25, texture2) end) Link to comment
XaskeL Posted April 7, 2021 Share Posted April 7, 2021 As soon as I get free from work, I will give a ready-made code. 1 Link to comment
Popular Post XaskeL Posted April 7, 2021 Popular Post Share Posted April 7, 2021 2 hours ago, xXBlasterXx said: Could you explain more? I don't know how to use this. I was thinking smoething like that (from user Pa3ck), above is for 2-colors dxDraw, I need for alpha addEventHandler ("onClientResourceStart", resourceRoot, function () texture = dxCreateTexture (300, 25) local pixels = dxGetTexturePixels (texture) for i=0,300 do local progress = 100 / 300 * i / 100 local r, g, b = interpolateBetween ( 255, 0, 0, 255, 255, 0, progress, "Linear") for j=0,25 do dxSetPixelColor (pixels, i, j, r, g, b, 255) end end dxSetTexturePixels (texture, pixels) texture2 = dxCreateTexture (600, 25) local pixels2 = dxGetTexturePixels (texture2) for i=0,300 do local progress = 100 / 300 * i / 100 local r, g, b = interpolateBetween ( 255, 255, 0, 0, 255, 0, progress, "Linear") for j=0,25 do dxSetPixelColor (pixels2, i, j, r, g, b, 255) end end dxSetTexturePixels (texture2, pixels2) end) addEventHandler ("onClientRender", root, function () dxDrawImage (300, 300, 300, 25, texture) dxDrawImage (600, 300, 300, 25, texture2) end) local SHADER_CODE = [===[ float3 g_f3Color = (float3)0.0; struct PSInput { float4 Position : POSITION0; float2 TexCoord : TEXCOORD0; }; float4 PixelShaderFunction ( PSInput PS ) : COLOR0 { return float4( g_f3Color, 1.0 - PS.TexCoord.x ); }; technique { pass P0 { PixelShader = compile ps_2_a PixelShaderFunction(); } } ]===]; local _dxDrawRectangle = dxDrawRectangle; local g_pShader = dxCreateShader( SHADER_CODE ); function dxDrawRectangle( fX, fY, fWidth, fHeight, pColor, bPostGUI, bLerpAlpha ) if ( not bLerpAlpha ) then _dxDrawRectangle( fX, fY, fWidth, fHeight, pColor, bPostGUI ); else dxSetShaderValue( g_pShader, "g_f3Color", pColor ); dxDrawImage( fX, fY, fWidth, fHeight, g_pShader, 0, 0, 0, -1, bPostGUI ); end end; addEventHandler( "onClientRender", root, function ( ) dxDrawRectangle( 600, 400, 256, 256, { 0, 0, 0 }, false, true ); end ); Please put a reaction to the message, it is on the bottom right. Don't be indifferent. 4 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now