Init repository

This commit is contained in:
Krzosa Karol
2026-03-19 23:16:20 +01:00
parent eee4198ac8
commit df706003dd
50 changed files with 27733 additions and 0 deletions

180
src/visualize/backup.cpp Executable file
View File

@@ -0,0 +1,180 @@
#if 0
S8_String filename = S8_Lit("../assets/SkillCraft.csv");
PLOT_CSV = CSV_Load(G_Perm, filename);
UI_Notification(2.0f, "CSV: %s, loaded!", filename.str);
CSV_Column *gap_between_pacs = PLOT_CSV.columns + 12;
CSV_Column *apm = PLOT_CSV.columns + 5;
PLOT_X = gap_between_pacs->floats;
PLOT_XLabel = gap_between_pacs->name;
PLOT_Y = apm->floats;
PLOT_YLabel = apm->name;
PLOT_Title = PLOT_CSV.filename;
PLOT_DataSize = (int)PLOT_CSV.row_count;
#endif
#if 0
for (MU_DroppedFile *iter = Mu->window->first_dropped_file; iter; iter = iter->next) {
S8_String filename = S8_Make(iter->filename, iter->filename_size);
PLOT_CSV = CSV_Load(G_Perm, filename);
UI_Notification(2.0f, "CSV: %s, loaded!", filename.str);
CSV_Column *gap_between_pacs = PLOT_CSV.columns + 12;
CSV_Column *apm = PLOT_CSV.columns + 5;
PLOT_X = gap_between_pacs->floats;
PLOT_XLabel = gap_between_pacs->name;
PLOT_Y = apm->floats;
PLOT_YLabel = apm->name;
PLOT_Title = PLOT_CSV.filename;
PLOT_DataSize = (int)PLOT_CSV.row_count;
}
#else
int SPREAD_MaxY;
int SPREAD_MaxX;
MAP_Map SPREAD_Map;
Vec2 SPREAD_Pos;
if (!PLOT_Initialized) {
SPREAD_Pos = Mu->window->sizef;
}
MAP_InsertEvent(&SPREAD_Map, {0 + current_series->id * 2, data_point_count}, iter.event);
MAP_InsertEvent(&SPREAD_Map, {1 + current_series->id * 2, data_point_count}, iter.event);
SPREAD_MaxY = data_point_count;
SPREAD_MaxX = 4;
Vec4 spreadsheet_background = COLOR_spreadsheet_background;
//
// SPREADSHEET
//
Vec2 spreadsheet_pos = SPREAD_Pos * G_Camera.zoom;
Rect2 spreadsheet_rect = {};
{
float xcell_size = 150.f * G_Camera.zoom;
float ycell_size = R2_RenderO.font->size * G_Camera.zoom;
float all_columns_size = xcell_size * SPREAD_MaxX;
Vec2 spreadsheet_size = {all_columns_size, -(SPREAD_MaxY + 1) * ycell_size};
Vec2 spreadcamoffset = spreadsheet_pos - G_Camera.pos;
spreadsheet_rect = Rect2Size(spreadcamoffset, spreadsheet_size);
if (spreadsheet_rect.min.y > spreadsheet_rect.max.y) {
Swap(spreadsheet_rect.min.y, spreadsheet_rect.max.y);
}
int visible_row_begin = 0;
int visible_row_end = 0;
int visible_col_begin = 0;
int visible_col_end = 0;
{
float ystart = (-Mu->window->sizef.y + spreadcamoffset.y) / ycell_size;
float ysize = Mu->window->sizef.y / ycell_size;
visible_row_begin = Clamp((int)floorf(ystart) - 1, 0, SPREAD_MaxY);
visible_row_end = Clamp((int)(ceilf(ystart + ysize)), 0, SPREAD_MaxY);
float when_spreadcamoffset_incamera_offset = Clamp(Mu->window->sizef.x, 0.f, spreadcamoffset.x);
float xstart = (spreadcamoffset.x - when_spreadcamoffset_incamera_offset) / xcell_size;
float xsize = Mu->window->sizef.x / xcell_size;
visible_col_begin = Clamp((int)floorf(xstart) - 1, 0, SPREAD_MaxX);
visible_col_end = Clamp((int)(ceilf(xstart + xsize)), 0, SPREAD_MaxX);
}
// Draw the background rect
R2_DrawRect(spreadsheet_rect, spreadsheet_background);
R2_DrawCircle(spreadcamoffset, 4.0f, {1, 0, 0, 1}); //@debug
// Draw label
{
Rect2 rect = spreadsheet_rect;
Vec2 size = GetSize(spreadsheet_rect);
float label_scale = G_Camera.zoom * 1.0f;
float label_t = 0;
if (G_Camera.zoom > 0.5f) {
label_t = 0.0f;
}
else {
float t = ((1.f / G_Camera.zoom) - 2.0f) / 4.0f / 32.f;
label_t = Clamp01(Lerp(0, 1, t));
if (t <= 1.0f) {
label_scale = Lerp(label_scale, 1.0f, PingPong(t));
}
else {
label_scale = Lerp(0.5f, 1.0f, PingPong(t));
}
}
Vec2 plot_midtop = rect.max;
plot_midtop.x -= size.x / 2;
plot_midtop.y += 2;
Vec2 plot_mid = rect.min + (rect.max - rect.min) / 2.f;
// We want T that is 0 when zoom is 4 or less
Vec2 label_pos = Lerp(plot_midtop, plot_mid, label_t);
S8_String label_string = PLOT_Title;
Vec2 top_label_size = R2_GetStringSize(label_string, label_scale);
label_pos.x -= top_label_size.x / 2;
R2_DrawString(label_pos, label_string, text_color, label_scale);
}
float x_accumulator = 0;
if (should_render) {
for (int col_i = visible_col_begin; col_i < visible_col_end; col_i += 1) {
// Draw the first row, the label row
{
Vec2 cell_pos = Vec2{x_accumulator, -ycell_size * (float)(1.f)} + spreadcamoffset;
S8_String label = S8_Lit("");
if (col_i == 0) label = PLOT_XLabel;
if (col_i == 1) label = PLOT_YLabel;
Rect2 rect = R2_DrawString(cell_pos, label, disappearing_text_color, G_Camera.zoom);
}
for (int row_i = visible_row_begin; row_i < visible_row_end; row_i += 1) {
VIS_Event *event = MAP_GetEvent(&SPREAD_Map, {col_i, row_i});
if (!event) continue;
float point = event->point[(col_i % 2)];
S8_String it = S8_Format(G_Frame, "%f", point);
// Draw the cell
// We start from row 2 (row 1 is reserved)
{
Vec2 cell_pos = Vec2{x_accumulator, -ycell_size * (float)(row_i + 2.f)} + spreadcamoffset;
Rect2 cell_rect = Rect2Size(cell_pos, Vec2{xcell_size, ycell_size});
R2_DrawRectOutline(cell_rect, cell_outline_color);
Vec2 string_size = R2_GetStringSize(it, G_Camera.zoom);
Vec2 string_pos = cell_pos + (GetSize(cell_rect) / 2 - string_size / 2);
R2_DrawString(string_pos, it, disappearing_text_color, G_Camera.zoom);
}
}
x_accumulator += xcell_size;
}
}
}
//
// Zoomed out view object moving
//
if (should_render == false) {
if (AreColliding(rect, Mu->window->mouse.posf)) {
R2_DrawRectOutline(rect, {1, 0, 0, 1});
if (Mu->window->mouse.right.down) {
PLOT_Pos += Mu->window->mouse.delta_pos_normalized * 1000.0f / G_Camera.zoom;
}
}
else if (AreColliding(spreadsheet_rect, Mu->window->mouse.posf)) {
R2_DrawRectOutline(spreadsheet_rect, {1, 0, 0, 1});
if (Mu->window->mouse.right.down) {
SPREAD_Pos += Mu->window->mouse.delta_pos_normalized * 1000.0f / G_Camera.zoom;
}
}
}