#include #include #include #include Vector2 newPoint(Vector2 start, float len, float angleD){ float angleR = (angleD * PI) / 180; // radian return {start.x + len * cos(angleR), start.y - len * sin(angleR)}; } void drawBranch(Vector2 startV, Vector2 endV, Color startC, Color endC, int startR, int endR){ float fstep = 0.05; for (float i = 0; i < 1.05; i += fstep) { Vector2 point = Vector2Lerp(startV, endV, i); Color color = ColorLerp(startC, endC, i); int size = Lerp(startR, endR, i); DrawCircleV(point, size, color); } } constexpr float screenWidth = 800; constexpr float screenHeight = 800; constexpr float len = 300; constexpr float angleD = 100; constexpr Vector2 start = {screenWidth / 2, screenHeight - 100}; constexpr float radius = 20; constexpr float radiusS = 80; constexpr float radiusE = 60; constexpr Color colorS = RED; constexpr Color colorE = GREEN; typedef void (*slika)(); int idx = 0; std::vector v_slik = { []() { DrawCircleV(start, radius, BLACK); }, []() { Vector2 end = {start.x, start.y - len}; DrawCircleV(start, radius, BLACK); DrawLineEx(start, end, 10, BLACK); }, []() { Vector2 end = newPoint(start, len, angleD); DrawCircleV(start, radius, BLACK); DrawLineEx(start, end, 10, BLACK); DrawCircleV(end, radius, BLACK); DrawCircleSectorLines(start, len / 3, 360 - angleD, 360, 30, BLACK); }, []() { Vector2 end = newPoint(start, len, angleD); DrawCircleV(start, radius, BLACK); DrawLineEx(start, end, 10, BLACK); DrawCircleV(end, radius, BLACK); DrawCircleLinesV(start, radiusS, BLACK); DrawCircleLinesV(end, radiusE, BLACK); }, []() { Vector2 end = newPoint(start, len, angleD); DrawLineEx(start, end, 10, BLACK); DrawCircleV(start, radiusS, colorS); DrawCircleV(end, radiusE, colorE); }, []() { Vector2 end = newPoint(start, len, angleD); drawBranch(start, end, colorS, colorE, radiusS, radiusE); }, []() { Vector2 p = newPoint(start, len, angleD); drawBranch(start, p, colorS, colorE, radiusS, radiusE); Vector2 p1 = newPoint(p, len, 135); Vector2 p2 = newPoint(p, len, 90); Vector2 p3 = newPoint(p, len, 45); DrawLineEx(p, p1, 10, BLACK); DrawLineEx(p, p2, 10, BLACK); DrawLineEx(p, p3, 10, BLACK); DrawCircleV(p, radius, BLACK); DrawCircleV(p1, radius, BLACK); DrawCircleV(p2, radius, BLACK); DrawCircleV(p3, radius, BLACK); }, []() { Vector2 p = newPoint(start, len, angleD); drawBranch(start, p, colorS, colorE, radiusS, radiusE); Vector2 p1 = newPoint(p, len, 135); Vector2 p2 = newPoint(p, len, 90); Vector2 p3 = newPoint(p, len, 45); drawBranch(p, p1, colorE, BLUE, radiusE, 50); drawBranch(p, p2, colorE, ORANGE, radiusE, 50); drawBranch(p, p3, colorE, PURPLE, radiusE, 50); }, }; int main(int argc, char *argv[]) { InitWindow(screenWidth, screenHeight, "Slike"); SetTargetFPS(60); while (!WindowShouldClose()) { BeginDrawing(); if (IsKeyPressed(KEY_S)) { TakeScreenshot(TextFormat("slika%.2d.png", idx)); } if (IsKeyPressed(KEY_N)) { idx++; if (idx >= v_slik.size()) idx = v_slik.size() - 1; } if (IsKeyPressed(KEY_P)) { idx--; if (idx < 0) idx = 0; } ClearBackground(WHITE); v_slik[idx](); EndDrawing(); } CloseWindow(); return 0; }