diff options
Diffstat (limited to 'src/createcalls.cpp')
-rw-r--r-- | src/createcalls.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/createcalls.cpp b/src/createcalls.cpp index 09bcea5..fc50b6e 100644 --- a/src/createcalls.cpp +++ b/src/createcalls.cpp @@ -35,6 +35,9 @@ File_Open(project_data *File, project_state *State, memory *Memory, char *Filena } } String_Copy(State->Filename, State->DummyName, 512); + + File->UI.Shape = {}; + State->Initializing = 4; Memory->History.NumberOfEntries = 0; Memory->History.EntryPlayhead = 0; @@ -489,7 +492,7 @@ void Slide_Test(project_data *File, project_state *State, memory *Memory, sorted v2 LayerPos = V2(Layer->x.CurrentValue, Layer->y.CurrentValue); int Width, Height; Layer_GetDimensions(Memory, Layer, &Width, &Height); - v2 Difference = V2(abs(CompPos.x - LayerPos.x), abs(CompPos.y - LayerPos.y)); + v2 Difference = V2(fabs(CompPos.x - LayerPos.x), fabs(CompPos.y - LayerPos.y)); printf("Diff: %.1f, %.1f\n", Difference.x, Difference.y); if (Difference.x < Threshold && Difference.y < Threshold) @@ -849,7 +852,7 @@ Project_ShapeLayer_New(project_data *File, project_state *State, memory *Memory) // SortedCompArray, SortedLayerArray, SelectionCount, SelectedLayerIndex, SelectedPrecompIndex) } // Rect mode - if (State->Interact_Modifier == 1) { + if (State->ShapeMode == 0) { v2 *CompPoint = (v2 *)&State->Interact_Offset[0]; for (int i = 0; i < 4; i++) { bezier_point PointData = { 1, { CompPoint[i], V2(0, 0), V2(0, 0) }, interpolation_type_linear, 0 }; @@ -857,7 +860,23 @@ Project_ShapeLayer_New(project_data *File, project_state *State, memory *Memory) CompPoint[i] = {0}; } Shape->IsClosed = true; - State->Interact_Modifier = 0; + } else if (State->ShapeMode == 1) { + v2 Radius = *((v2 *)&State->Interact_Offset + 0); + v2 Center = *((v2 *)&State->Interact_Offset + 1); + real32 cx = Center.x; + real32 cy = Center.y; + real32 rx = Radius.x; + real32 ry = Radius.y; + v2 Points[12] = { V2(cx-rx, cy), V2(0, ry*KAPPA), V2(0, -ry*KAPPA), + V2(cx, cy+ry), V2(+rx*KAPPA, 0), V2(-rx*KAPPA, 0), + V2(cx+rx, cy), V2(0, -ry*KAPPA), V2(0, ry*KAPPA), + V2(cx, cy-ry), V2(-rx*KAPPA, 0), V2(+rx*KAPPA, 0) }; + for (int i = 0; i < 4; i++) { + bezier_point PointData = { 1, { Points[i*3+0], Points[i*3+1], Points[i*3+2] }, interpolation_type_bezier, 0 }; + Bezier_Add(Memory, F_File, Shape->Block_Bezier_Index, &Shape->Block_Bezier_Count, &Shape->Point_Count, PointData); + } + + // Shape->IsClosed = true; } shape_options ShapeOpt = File->UI.ShapeOpt; @@ -866,14 +885,16 @@ Project_ShapeLayer_New(project_data *File, project_state *State, memory *Memory) v2 Min = {}, Max = {}; void *Data = Memory_PushScratch(Memory, sizeof(nvg_point) * 128); layer_transforms T = {}; - NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data, State, T, 0, 0, 0, 0, 0, &Min, &Max); + bool32 IsConvex = 0; + NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data, State, T, 0, 0, 0, 0, 0, &Min, &Max, &IsConvex); Memory_PopScratch(Memory, sizeof(nvg_point) * 128); Shape->Width = Max.x - Min.x; Shape->Height = Max.y - Min.y; for (int i = 0; i < Shape->Point_Count; i++) { bezier_point *Point = Bezier_LookupAddress(Memory, Shape->Block_Bezier_Index, i, 1); for (int a = 0; a < 3; a++) { - Point->Pos[a] = (Point->Pos[a] - Min) / V2(Shape->Width, Shape->Height); + v2 Sub = (a == 0) ? Min : V2(0, 0); + Point->Pos[a] = (Point->Pos[a] - Sub) / V2(Shape->Width, Shape->Height); } } |