PostCPLUSPLUSLag-less Gradient Function

Posts 1–15 of 46 · Page 1 of 4
Lag-less Gradient Function
Lag-less gradient function
I made this around 2005-2006, it served me lots of time
Hope someone enjoys this!

Code:
void CDrawing::FillGradient(int x, int y, int h, int w, DWORD color1, DWORD color2)
{
	DWORD a1 = (color1 >> 24) & 0xFF;
	DWORD r1 = (color1 >> 16) & 0xFF;
	DWORD g1 = (color1 >> 8) & 0xFF;
	DWORD b1 = color1 & 0xFF;
	DWORD a2 = (color2 >> 24) & 0xFF;
	DWORD r2 = (color2 >> 16) & 0xFF;
	DWORD g2 = (color2 >> 8) & 0xFF;
	DWORD b2 = color2 & 0xFF;
	float aDif, rDif, gDif, bDif;
	aDif = ((float)a2 - (float)a1) / h;
	rDif = ((float)r2 - (float)r1) / h;
	gDif = ((float)g2 - (int)g1) / h;
	bDif = ((float)b2 - (float)b1) / h;
	DWORD DrawCol;
	for (int i = 0; i<h; i++)
	{
		DrawCol = (a1 + (int)(aDif*i) << 24) | (r1 + (int)(rDif * i) << 16) | (g1 + (int)(gDif * i) << 8) | (b1 + (int)(bDif*i));
		pDrawing.FillRGBA(x, y + i, w, 1, DrawCol);
	}
}
|81|& /\/\47|-| <0|>3|\|5 /\/\8
Quote Originally Posted by D3M0L1T10N View Post
|81|& /\/\47|-| <0|>3|\|5 /\/\8
wtf are u even saying

Quote Originally Posted by Defender2010 View Post
Round of applause everyone. Round of applause. This guy is the greatest coder on MPGH. Make him the owner now.


and yes i am the greatest gradient script coder on mpgh
Quote Originally Posted by D3M0L1T10N View Post
|81|& /\/\47|-| <0|>3|\|5 /\/\8
BIG MATH CODENS M8
/reveleated
Round of applause everyone. Round of applause. This guy is the greatest coder on MPGH. Make him the owner now.
bump you guys need this
why the fuck are you using dword as colors
make a class like a normal person
Quote Originally Posted by MeepDarknessMeep View Post
why the fuck are you using dword as numbers
make a class like a normal person
are you stupid
Quote Originally Posted by *atex View Post
are you stupid
hey i see youre new to this section but we dont meanpost here
Quote Originally Posted by *atex View Post
are you stupid
i understand that colors can be interpreted as a dword but use a class, it's cleaner and better
Quote Originally Posted by *atex View Post
are you stupid
i just realized i said that wrong, you are correct! i am stupid in that post! i edited it to make it make sense.
aDif = ((float)a2 - (float)a1) / h;
rDif = ((float)r2 - (float)r1) / h;
gDif = ((float)g2 - (int)g1) / h;
bDif = ((float)b2 - (float)b1) / h;

houston we have a problem here
Quote Originally Posted by Kona-chan View Post
aDif = ((float)a2 - (float)a1) / h;
rDif = ((float)r2 - (float)r1) / h;
gDif = ((float)g2 - (int)g1) / h;
bDif = ((float)b2 - (float)b1) / h;

houston we have a problem here
the whole code is shit honestly


Code:
struct Color {
	Color(int _r, int _g, int _b, int _a)
	{
		r = _r;
		g = _g;
		b = _b;
		a = _a;
	}
	void operator +=(Color &o)
	{
		r += o.r;
		g += o.g;
		b += o.b;
		a += o.a;
	}
	Color operator -(Color &o)
	{
		return Color(r - o.r, g - o.g, b - o.b, a - o.a);
	}
	char a,r,g,b;
}
void CSkidding::FillGradient(int x, int y, int h, int w, Color c1, Color c2)
{
	Color drawStep(c2 - c1); // add division since i am lazy
	int i = 0; // fix in edit
	while(i++ < h)
	{
		c1 += drawStep;
		this->FillRGBA(x, y + i, w, 1, c1);
	}
}
Nice you copy pasted a unkn0wncheats thread from 2009.

Original:
Code:
void FillGradient(IDirect3DDevice9 * m_pD3Ddev,int x, int y, int h, int w, DWORD color1, DWORD color2)
{
DWORD a1 = (color1>>24)&0xFF;
DWORD r1 = (color1>>16)&0xFF;
DWORD g1 = (color1>>8)&0xFF;
DWORD b1 = color1&0xFF;
DWORD a2 = (color2>>24)&0xFF;
DWORD r2 = (color2>>16)&0xFF;
DWORD g2 = (color2>>8)&0xFF;
DWORD b2 = color2&0xFF;
float aDif,rDif,gDif,bDif;
aDif = ((float)a2-(float)a1)/h;
rDif = ((float)r2-(float)r1)/h;
gDif = ((float)g2-(int)g1)/h;
bDif = ((float)b2-(float)b1)/h;
DWORD DrawCol;
for(int i = 0;i<h;i++)
{
DrawCol = (a1+(int)(aDif*i) << 24) | (r1+(int)(rDif * i) << 16) | (g1+(int)(gDif * i) << 8) | (b1+(int)(bDif*i));
DrawRect(m_pD3Ddev,x,y+i,w,1,DrawCol);
}
}
http://www.unkn0wncheats.me/forum/416715-post16.html

Replace 0 with o
Yeah meep is right, Please use a class for that it really looks awful like that.
Posts 1–15 of 46 · Page 1 of 4

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us