Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6694675d1a | |||
| a1bfb5b273 | |||
| 91b2cf3c28 |
114
veinCur.cpp
114
veinCur.cpp
@ -13,6 +13,7 @@ LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
Gdiplus::Graphics* graphics;
|
||||
ULONG_PTR gdiplusToken;
|
||||
HWND hwnd;
|
||||
HHOOK hook;
|
||||
mutex mtx;
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||
@ -41,8 +42,7 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszA
|
||||
}
|
||||
|
||||
CreateFullScreenTransparentWindow(L"鼠标特效", L"cursor_anim");
|
||||
HHOOK hook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);
|
||||
|
||||
hook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);
|
||||
|
||||
|
||||
// 创建线程
|
||||
@ -55,7 +55,7 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszA
|
||||
|
||||
// 设置线程优先级为低
|
||||
SetThreadPriority(hThread, THREAD_PRIORITY_LOWEST);
|
||||
|
||||
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
|
||||
|
||||
|
||||
|
||||
@ -122,6 +122,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
delete graphics;
|
||||
UnregisterHotKey(hwnd, g_hotkeyId);
|
||||
Gdiplus::GdiplusShutdown(gdiplusToken);
|
||||
UnhookWindowsHookEx(hook);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
@ -146,27 +147,22 @@ void vine2(int x1, int y1, float anchor, float turn, int speed, int cost, Color
|
||||
penline.SetStartCap(LineCapRound);
|
||||
mtx.lock();
|
||||
graphics->DrawLine(&penline, x1, y1, x2, y2);
|
||||
vines.push(VineDraw{x1,y1,x2,y2,speed,50});
|
||||
mtx.unlock();
|
||||
Sleep(1);
|
||||
vines.push(VineDraw{x1,y1,x2,y2,speed,10});
|
||||
|
||||
if (clone > 0 && rand() % 10 == 0)
|
||||
{
|
||||
int x_copy = x1;
|
||||
int y_copy = y1;
|
||||
float anchor_copy = anchor + rand() % 10 / 26.0;
|
||||
float turn_copy = turn * (-1 + rand() % 2 * 2);
|
||||
int speed_copy = speed + rand() % 3;
|
||||
int cost_copy = cost + rand() % 3;
|
||||
thread t(vine2, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
|
||||
thread t(vine2, x1, y1, anchor + rand() % 10 / 20.0, turn * (-1 + rand() % 2 * 2), speed + rand() % 2, cost, Color(rand() % 70, 115 + rand() % 3 * 70, 20 + rand() % 20), 0, --clone);
|
||||
t.detach();
|
||||
}
|
||||
if (count % 10 == 0)
|
||||
if (count % 9 == 0)
|
||||
speed -= cost;
|
||||
anchor += turn;
|
||||
if (count % 3 == 0)
|
||||
turn += turn / 2;
|
||||
if (turn > 0.6)
|
||||
speed = 0;
|
||||
mtx.unlock();
|
||||
Sleep(1);
|
||||
vine2(x2, y2, anchor, turn, speed, cost, color, count, clone);
|
||||
}
|
||||
|
||||
@ -191,55 +187,55 @@ DWORD WINAPI eraser(LPVOID lpParam)
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep(50);
|
||||
Sleep(70);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vine(int x1, int y1, float anchor, float turn, int speed, int cost, Color color, int count, int clone)
|
||||
{
|
||||
if (speed <= 0)
|
||||
{
|
||||
Sleep(300);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
int x2 = x1 + (speed)*cos(anchor);
|
||||
int y2 = y1 + (speed)*sin(anchor);
|
||||
Pen penline(color, speed);
|
||||
penline.SetEndCap(LineCapRound);
|
||||
penline.SetStartCap(LineCapRound);
|
||||
mtx.lock();
|
||||
graphics->DrawLine(&penline, x1, y1, x2, y2);
|
||||
mtx.unlock();
|
||||
Sleep(1);
|
||||
if (clone > 0 && rand() % 10 == 0)
|
||||
{
|
||||
int x_copy = x1;
|
||||
int y_copy = y1;
|
||||
float anchor_copy = anchor + rand() % 10 / 26.0;
|
||||
float turn_copy = turn * (-1 + rand() % 2 * 2);
|
||||
int speed_copy = speed + rand() % 3;
|
||||
int cost_copy = cost + rand() % 3;
|
||||
thread t(vine, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
|
||||
t.detach();
|
||||
}
|
||||
if (count % 10 == 0)
|
||||
speed -= cost;
|
||||
anchor += turn;
|
||||
if (count % 3 == 0)
|
||||
turn += turn / 2;
|
||||
if (turn > 0.6)
|
||||
speed = 0;
|
||||
vine(x2, y2, anchor, turn, speed, cost, color, count, clone);
|
||||
Sleep(count / 3);
|
||||
Pen erase(Color(255, 0, 0), speed * 2 + 3);
|
||||
erase.SetEndCap(LineCapRound);
|
||||
erase.SetStartCap(LineCapRound);
|
||||
mtx.lock();
|
||||
graphics->DrawLine(&erase, x1, y1, x2, y2);
|
||||
mtx.unlock();
|
||||
}
|
||||
//void vine(int x1, int y1, float anchor, float turn, int speed, int cost, Color color, int count, int clone)
|
||||
//{
|
||||
// if (speed <= 0)
|
||||
// {
|
||||
// Sleep(300);
|
||||
// return;
|
||||
// }
|
||||
// count++;
|
||||
// int x2 = x1 + (speed)*cos(anchor);
|
||||
// int y2 = y1 + (speed)*sin(anchor);
|
||||
// Pen penline(color, speed);
|
||||
// penline.SetEndCap(LineCapRound);
|
||||
// penline.SetStartCap(LineCapRound);
|
||||
// mtx.lock();
|
||||
// graphics->DrawLine(&penline, x1, y1, x2, y2);
|
||||
// mtx.unlock();
|
||||
// Sleep(1);
|
||||
// if (clone > 0 && rand() % 10 == 0)
|
||||
// {
|
||||
// int x_copy = x1;
|
||||
// int y_copy = y1;
|
||||
// float anchor_copy = anchor + rand() % 10 / 26.0;
|
||||
// float turn_copy = turn * (-1 + rand() % 2 * 2);
|
||||
// int speed_copy = speed + rand() % 3;
|
||||
// int cost_copy = cost + rand() % 3;
|
||||
// thread t(vine, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
|
||||
// t.detach();
|
||||
// }
|
||||
// if (count % 10 == 0)
|
||||
// speed -= cost;
|
||||
// anchor += turn;
|
||||
// if (count % 3 == 0)
|
||||
// turn += turn / 2;
|
||||
// if (turn > 0.6)
|
||||
// speed = 0;
|
||||
// vine(x2, y2, anchor, turn, speed, cost, color, count, clone);
|
||||
// Sleep(count / 3);
|
||||
// Pen erase(Color(255, 0, 0), speed * 2 + 3);
|
||||
// erase.SetEndCap(LineCapRound);
|
||||
// erase.SetStartCap(LineCapRound);
|
||||
// mtx.lock();
|
||||
// graphics->DrawLine(&erase, x1, y1, x2, y2);
|
||||
// mtx.unlock();
|
||||
//}
|
||||
|
||||
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||
if (nCode >= 0) {
|
||||
|
||||
@ -104,6 +104,8 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -120,7 +122,7 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user