Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -----------------------------------------
- * Game hacking QTS ( Quickie Tip Series )
- * no. 23 - Primitive rectangle and line gradients
- -----------------------------------------
- * Author: SEGnosis - GHAnon.net
- * Thanks to:
- * bitterbanana - No known site
- * Drunken Cheetah - No known site
- * fatboy88 - No known site
- * Geek4Ever - No known site
- * learn_more - www.uc-forum.com
- * Novocaine - http://ilsken.net/blog/?page_id=64
- * Philly0494 - No known site
- * Roverturbo - www.uc-forum.com
- * SilentKarma - www.halocoders.com - offline
- * Strife - www.uc-forum.com
- * Wieter20 - No known site
- */
- struct FVect3
- {
- float x, y, z;
- };
- struct FVect2
- {
- float x, y;
- };
- struct FTrigFunc
- {
- float sine,
- cosine,
- tangent,
- hypotenuse,
- radian;
- };
- void GradientRect( D3DXVECTOR2 vPos, int iWidth, int iHeight, D3DCOLOR coA, D3DCOLOR coB )
- {
- CDraw.Rect( vPos.x, vPos.y, iWidth, iHeight, coA );
- S_D3DCOLOR* pColor = ( S_D3DCOLOR* )&coB;
- pColor->a = 0;
- float fRateY = 255 / iHeight;
- for( int i = 0; i < iHeight; i++ )
- {
- CDraw.Rect( vPos.x, vPos.y + i, iWidth, 1, coB );
- pColor->a = min( 255, pColor->a + fRateY );
- }
- }
- void GradientLine( D3DXVECTOR2 vPosA, D3DXVECTOR2 vPosB, D3DCOLOR coA, D3DCOLOR coB, DWORD dwWidth = 1 )
- {
- S_D3DCOLOR* pColor = ( S_D3DCOLOR* )&coB;
- FTrigFunc vTrig;
- // get total distance and quadrent
- FVect2 vDistance = { vPosA.x - vPosB.x + 0.000001f, vPosA.y - vPosB.y + 0.000001f };
- // get trig stats
- vTrig.hypotenuse = CAimbot.VectToHypot( vDistance ) + 0.000001f;
- vTrig.radian = acosf( ( vDistance.y ) / vTrig.hypotenuse );
- // offset based on quadrent
- if( vDistance.x < 0 && vDistance.y < 0 || vDistance.x < 0 && vDistance.y > 0 ) // in quad 2 - 3
- vTrig.radian = ( PI - vTrig.radian );
- else
- vTrig.radian = ( PI + vTrig.radian );
- // Ratio to offset by
- vTrig.cosine = cosf( vTrig.radian );
- vTrig.sine = sinf( vTrig.radian );
- // Rate that alpha should increase ( must be float or max line distance is 255 D: )
- float fRateY = 255 / abs( vTrig.hypotenuse ),
- fAlpha = 0;
- // Set alpha to 0
- pColor->a = 0;
- // Start second line from first line
- D3DXVECTOR2 vPosC = vPosA;
- // Draw Underlying Line
- CDraw.Line( vPosA.x, vPosA.y, vPosB.x, vPosB.y, dwWidth, coA );
- // Draw overlying line with increasing alpha channel
- for( float i = 0; i < vTrig.hypotenuse; i++ )
- {
- // Draw line from position to second position
- CDraw.Line( vPosC.x, vPosC.y, vPosC.x + vTrig.sine, vPosC.y + vTrig.cosine, dwWidth, coB );
- // Offset by ratio
- vPosC.x += vTrig.sine;
- vPosC.y += vTrig.cosine;
- // Increase alpha
- if( fAlpha + fRateY < 255.0000f )
- fAlpha += fRateY;
- // set alpha
- pColor->a = fAlpha;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement