add random/slike
This commit is contained in:
@@ -57,3 +57,8 @@ add_executable(view
|
|||||||
)
|
)
|
||||||
target_include_directories(view PRIVATE view/inc)
|
target_include_directories(view PRIVATE view/inc)
|
||||||
target_link_libraries(view PRIVATE shared)
|
target_link_libraries(view PRIVATE shared)
|
||||||
|
|
||||||
|
add_executable(slike
|
||||||
|
random/slike.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(slike PRIVATE shared)
|
||||||
@@ -121,7 +121,7 @@ bool try_remove(std::filesystem::path path)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::filesystem::remove("old_build");
|
std::filesystem::remove(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
|
|||||||
140
random/slike.cpp
Normal file
140
random/slike.cpp
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
#include <raylib.h>
|
||||||
|
#include <raymath.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
float len = 300;
|
||||||
|
float angleD = 100;
|
||||||
|
float angleR = (angleD * PI) / 180; // radian
|
||||||
|
Vector2 start = {250, 400};
|
||||||
|
Vector2 end = {250, start.y - len};
|
||||||
|
Vector2 end_kot = {};
|
||||||
|
float radius = 20;
|
||||||
|
float radiusS = 80;
|
||||||
|
float radiusE = 60;
|
||||||
|
Color colorS = RED;
|
||||||
|
Color colorE = GREEN;
|
||||||
|
|
||||||
|
typedef void (*slika)();
|
||||||
|
|
||||||
|
Vector2 tstart = {10, 10};
|
||||||
|
int tsize = 30;
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
|
std::vector<slika> v_slik = {
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Zacetna tocka", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawCircleV(start, radius, BLACK);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Dolzina", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawCircleV(start, radius, BLACK);
|
||||||
|
DrawLineEx(start, end, 10, BLACK);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Kot in Koncna tocka", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawCircleV(start, radius, BLACK);
|
||||||
|
DrawLineEx(start, end_kot, 10, BLACK);
|
||||||
|
DrawCircleV(end_kot, radius, BLACK);
|
||||||
|
DrawCircleSectorLines(start, len / 3, 360 - angleD, 360, 30, BLACK);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Zacetna debelina", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawCircleV(start, radius, BLACK);
|
||||||
|
DrawLineEx(start, end_kot, 10, BLACK);
|
||||||
|
DrawCircleV(end_kot, radius, BLACK);
|
||||||
|
DrawCircleLinesV(start, radiusS, BLACK);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Koncna debelina", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawCircleV(start, radius, BLACK);
|
||||||
|
DrawLineEx(start, end_kot, 10, BLACK);
|
||||||
|
DrawCircleV(end_kot, radius, BLACK);
|
||||||
|
DrawCircleLinesV(start, radiusS, BLACK);
|
||||||
|
DrawCircleLinesV(end_kot, radiusE, BLACK);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Zacetna barva", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawLineEx(start, end_kot, 10, BLACK);
|
||||||
|
DrawCircleV(end_kot, radius, BLACK);
|
||||||
|
DrawCircleV(start, radiusS, colorS);
|
||||||
|
DrawCircleLinesV(end_kot, radiusE, BLACK);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Koncna barva", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
DrawLineEx(start, end_kot, 10, BLACK);
|
||||||
|
DrawCircleV(start, radiusS, colorS);
|
||||||
|
DrawCircleV(end_kot, radiusE, colorE);
|
||||||
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Veja", tstart.x, tstart.y, tsize, BLACK);
|
||||||
|
float fstep = 0.05;
|
||||||
|
for (float i = 0; i < 1.05; i += fstep)
|
||||||
|
{
|
||||||
|
Vector2 point = Vector2Lerp(start, end_kot, i);
|
||||||
|
Color color = ColorLerp(colorS, colorE, i);
|
||||||
|
int size = Lerp(radiusS, radiusE, i);
|
||||||
|
DrawCircleV(point, size, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int screenWidth = 500;
|
||||||
|
int screenHeight = 500;
|
||||||
|
|
||||||
|
float ny = len * sin(angleR);
|
||||||
|
float nx = len * cos(angleR);
|
||||||
|
end_kot.x = start.x + nx;
|
||||||
|
end_kot.y = start.y - ny;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user