Compare commits
6 Commits
98bc42be7d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ff4a66551 | |||
| 45f73c721e | |||
| e99bd33985 | |||
| 40b2f963a6 | |||
| cc00586bc9 | |||
| d7ea0b99ac |
@@ -47,7 +47,6 @@ target_link_libraries(app PRIVATE shared)
|
||||
add_executable(server
|
||||
server/src/server.cpp
|
||||
server/src/checker.cpp
|
||||
|
||||
)
|
||||
target_include_directories(server PRIVATE server/inc)
|
||||
target_link_libraries(server PRIVATE shared)
|
||||
@@ -59,7 +58,6 @@ add_executable(view
|
||||
target_include_directories(view PRIVATE view/inc)
|
||||
target_link_libraries(view PRIVATE shared)
|
||||
|
||||
|
||||
add_executable(slike
|
||||
random/slike.cpp
|
||||
)
|
||||
|
||||
121
random/slike.cpp
121
random/slike.cpp
@@ -3,109 +3,116 @@
|
||||
#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;
|
||||
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)();
|
||||
|
||||
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);
|
||||
Vector2 end = {start.x, start.y - len};
|
||||
DrawCircleV(start, radius, BLACK);
|
||||
DrawLineEx(start, end, 10, BLACK);
|
||||
},
|
||||
|
||||
[]()
|
||||
{
|
||||
DrawText("Kot in Koncna tocka", tstart.x, tstart.y, tsize, BLACK);
|
||||
Vector2 end = newPoint(start, len, angleD);
|
||||
DrawCircleV(start, radius, BLACK);
|
||||
DrawLineEx(start, end_kot, 10, BLACK);
|
||||
DrawCircleV(end_kot, radius, BLACK);
|
||||
DrawLineEx(start, end, 10, BLACK);
|
||||
DrawCircleV(end, radius, BLACK);
|
||||
DrawCircleSectorLines(start, len / 3, 360 - angleD, 360, 30, BLACK);
|
||||
},
|
||||
|
||||
[]()
|
||||
{
|
||||
DrawText("Zacetna debelina", tstart.x, tstart.y, tsize, BLACK);
|
||||
Vector2 end = newPoint(start, len, angleD);
|
||||
DrawCircleV(start, radius, BLACK);
|
||||
DrawLineEx(start, end_kot, 10, BLACK);
|
||||
DrawCircleV(end_kot, radius, BLACK);
|
||||
DrawLineEx(start, end, 10, BLACK);
|
||||
DrawCircleV(end, radius, BLACK);
|
||||
DrawCircleLinesV(start, radiusS, BLACK);
|
||||
DrawCircleLinesV(end, radiusE, 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);
|
||||
Vector2 end = newPoint(start, len, angleD);
|
||||
DrawLineEx(start, end, 10, BLACK);
|
||||
DrawCircleV(start, radiusS, colorS);
|
||||
DrawCircleLinesV(end_kot, radiusE, BLACK);
|
||||
DrawCircleV(end, radiusE, colorE);
|
||||
},
|
||||
|
||||
[]()
|
||||
{
|
||||
DrawText("Koncna barva", tstart.x, tstart.y, tsize, BLACK);
|
||||
DrawLineEx(start, end_kot, 10, BLACK);
|
||||
DrawCircleV(start, radiusS, colorS);
|
||||
DrawCircleV(end_kot, radiusE, colorE);
|
||||
Vector2 end = newPoint(start, len, angleD);
|
||||
drawBranch(start, end, colorS, colorE, radiusS, radiusE);
|
||||
},
|
||||
|
||||
[]()
|
||||
{
|
||||
DrawText("Veja", tstart.x, tstart.y, tsize, BLACK);
|
||||
float fstep = 0.05;
|
||||
for (float i = 0; i < 1.05; i += fstep)
|
||||
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 point = Vector2Lerp(start, end_kot, i);
|
||||
Color color = ColorLerp(colorS, colorE, i);
|
||||
int size = Lerp(radiusS, radiusE, i);
|
||||
DrawCircleV(point, size, color);
|
||||
}
|
||||
}
|
||||
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[])
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
@@ -136,7 +136,11 @@ namespace Similarity
|
||||
}
|
||||
else if (f == &Similarity::hamming_distance)
|
||||
{
|
||||
return "hamming";
|
||||
return "hamming_distance";
|
||||
}
|
||||
else if (f == &Similarity::hamming_distance_without_seeds)
|
||||
{
|
||||
return "hamming_distance_without_seeds";
|
||||
}
|
||||
else if (f == &Similarity::levenshtein_distance)
|
||||
{
|
||||
@@ -144,7 +148,7 @@ namespace Similarity
|
||||
}
|
||||
else
|
||||
{
|
||||
return "unknown";
|
||||
return "unknown nameofFunc";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +171,6 @@ namespace Similarity
|
||||
|
||||
const auto int_ms = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
|
||||
|
||||
TraceLog(LOG_INFO, "%s, %d", nameofFunc(f), int_ms);
|
||||
return average_similarity * 100.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
private:
|
||||
bool showSelection;
|
||||
bool showStats;
|
||||
bool saveToFile;
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *get_gen_num;
|
||||
std::vector<int64_t> ids;
|
||||
|
||||
@@ -110,7 +110,7 @@ void Vapp::update()
|
||||
stageOfDrawing = DrawingStage::save;
|
||||
break;
|
||||
case DrawingStage::save:
|
||||
drawToFile();
|
||||
if(saveToFile) drawToFile();
|
||||
stageOfDrawing = DrawingStage::done;
|
||||
break;
|
||||
case DrawingStage::done:
|
||||
@@ -140,6 +140,10 @@ void Vapp::draw()
|
||||
{
|
||||
setUpTable();
|
||||
}
|
||||
if(ImGui::MenuItem("Save to File", nullptr, saveToFile, true))
|
||||
{
|
||||
saveToFile = !saveToFile;
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
@@ -335,10 +339,10 @@ void Vapp::setUpTable()
|
||||
}
|
||||
|
||||
sql::reset(get_gen_stmt);
|
||||
|
||||
if(saveToFile)
|
||||
{
|
||||
int64_t id = ids[selected_id_index];
|
||||
char buff[50];
|
||||
sprintf(buff, "%ld.txt", id);
|
||||
const char* buff = TextFormat("%ld.txt", id);
|
||||
std::ofstream file(buff);
|
||||
|
||||
file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n";
|
||||
@@ -356,6 +360,7 @@ void Vapp::setUpTable()
|
||||
file << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sql::finalize(get_gen_stmt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user