Всем привет.Похоже,что эту часть форума уже давно закинули,но я попытаюсь восстановить ее.
Функция была написана когда-то Крайслером(qazwar).Я ее переписал под свои нужды.
В этом коде не будет использоваться спрайт с палитрой(много жрет,много кода).
Тут будет использоваться средства директа.
Итак,начнем.
Заводим структуру:
Код:
struct MyColor
{
int R, G, B;
MyColor(int R, int G, int B)
{
this->R = R;
this->G = G;
this->B = B;
}
};
Объявляем переменные и создаем функцию:
Код:
int AR, AG,AB;
Код:
MyColor Select_Color(int x, int y, bool &Var, LPDIRECT3DDEVICE9 pDevice)
{
int xred,xgreen,xblue;
D3DCOLOR BLACK = D3DCOLOR_ARGB(255, 0, 0, 0),;
DWORD retColor;
POINT pos;
GetCursorPos(&pos);
if (Var)
{
DP(x, y+20, 150, 150, pDevice);
}
if (IsInBox(x, y, 150, 150))
{
if (GetAsyncKeyState(VK_LBUTTON)<0)
{
HDC hScreenDC = GetDC(NULL);
COLORREF ColorsS = GetPixel(hScreenDC, pos.x, pos.y);
ReleaseDC(NULL, hScreenDC);
xred = GetRValue(ColorsS);
xgreen = GetGValue(ColorsS);
xblue = GetBValue(ColorsS);
AR = xred;
AG = xgreen;
AB = xblue;
}
}
retColor = D3DCOLOR_XRGB(AR, AG, AB);
if (Var)
{
Box(x + 150, y + 20, 15, 150, retColor, pDevice);
Border(x, y + 20, 150, 150, 2, BLACK, pDevice);
Border(x + 150, y + 20, 15, 150, 2, BLACK, pDevice);
}
MyColor ret = MyColor(AR, AG, AB);
return ret;
}