summaryrefslogtreecommitdiff
path: root/paint.cpp
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2022-12-16 20:16:43 -0500
committerFox Caminiti <fox@foxcam.net>2022-12-16 20:16:43 -0500
commitbedd6906eabdd513042d6a178d4dc56a3a41d1d3 (patch)
tree2bcbd3e46ae61e583707a2ccc5b3f5cfeacb61a8 /paint.cpp
parentcdb9e1f7240cb0716b7d99df5e1fd7c3fc3407a8 (diff)
v3, file/build organization
Diffstat (limited to 'paint.cpp')
-rw-r--r--paint.cpp103
1 files changed, 0 insertions, 103 deletions
diff --git a/paint.cpp b/paint.cpp
deleted file mode 100644
index f3170e5..0000000
--- a/paint.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-
-static void
-SlidingBrush(pixel_buffer *Buffer, v2i Pos, brush_tool Brush)
-{
- v2i Min = {0,0};
- v2i Max = Min + (int16)Brush.Size;
-
- v2 Center = {(real32)Max.x / 2.0f, (real32)Max.y / 2.0f};
- real32 MaxLength = sqrt(LengthSq(Center));
-
- v2i LayerMin = Pos - (Brush.Size / 2);
- v2i LayerMax = Pos + (Brush.Size / 2);
-
- rectangle LayerBounds = {0, 0, Buffer->Width, Buffer->Height};
- rectangle Paint = ClipRectangle({LayerMin, LayerMax}, LayerBounds);
-
- uint8 *Row = ((uint8 *)Buffer->OriginalBuffer + Buffer->Pitch*Paint.Min.y);
- for(int Y = Paint.Min.y;
- Y < Paint.Max.y;
- ++Y)
- {
- uint32 *Pixel = (uint32 *)(Row + Paint.Min.x*sizeof(uint32));
- for(int X = Paint.Min.x;
- X < Paint.Max.x;
- ++X)
- {
- v2 Pos = V2(abs(Center.x - (X - Paint.Min.x)), abs(Center.y - (Y - Paint.Min.y)));
- real32 L = sqrt(LengthSq(Pos)) + Center.x;
- real32 Gradient = pow(Ceil(L, MaxLength) / MaxLength, Brush.Hardness);
- RenderAlpha(Pixel, ColToUint32({1.0f, 0.0f, 0.0f, 1.0f - Gradient}));
- Pixel++;
- }
- Row += Buffer->Pitch;
- }
-}
-
-/*
-static void
-Paint(sdl_input Input, project_layer *Layer, brush_tool Brush)
-{
- int16 X = Input.Mouse.x - UI.CompX; // convert to comp space
- int16 Y = Input.Mouse.y - UI.CompY;
-
- real32 Rad = (Layer->rotation.CurrentValue.f * (PI / 180));
- real32 s = Layer->scale.CurrentValue.f;
- v2 Scale = {Layer->Raster.Width * s, Layer->Raster.Height * s};
-
- v2 XAxis = (Layer->Raster.Width * s)*V2(cos(Rad), sin(Rad));
- v2 YAxis = (Layer->Raster.Height * -s)*V2(sin(Rad), -cos(Rad));
-
- real32 AnchorX = Layer->ax.CurrentValue.f;
- real32 AnchorY = Layer->ay.CurrentValue.f;
-
- v2 Pos = {Layer->x.CurrentValue.f, Layer->y.CurrentValue.f};
- v2 Origin = Pos - (XAxis * AnchorX) - (YAxis * AnchorY);
-
- real32 XLengthSq = 1.0f / LengthSq(XAxis);
- real32 YLengthSq = 1.0f / LengthSq(YAxis);
-
- v2 CurrentPixel = V2(X, Y);
- v2 StartVector = CurrentPixel - Origin;
-
- real32 U = XLengthSq*Inner(StartVector, XAxis);
- real32 V = YLengthSq*Inner(StartVector, YAxis);
-
- v2i TexelCoord = {};
- TexelCoord.x = 1.0f + ((U*(real32)(Layer->Raster.Width - 1)) + 0.5f);
- TexelCoord.y = 1.0f + ((V*(real32)(Layer->Raster.Height - 1)) + 0.5f);
-
- v2i Min = {0,0};
- v2i Max = Min + (int16)Brush.Size;
-
- v2 Center = {(real32)Max.x / 2.0f, (real32)Max.y / 2.0f};
- real32 MaxLength = sqrt(LengthSq(Center));
-
- v2i LayerMin = TexelCoord - (Brush.Size / 2);
- v2i LayerMax = TexelCoord + (Brush.Size / 2);
-
- rectangle LayerBounds = {0, 0, Layer->Raster.Width, Layer->Raster.Height};
- rectangle Paint = {LayerMin, LayerMax};
-
- uint8 *Row = ((uint8 *)Layer->Raster.OriginalBuffer + Layer->Raster.Pitch*Paint.Min.y);
- for(int Y = Paint.Min.y;
- Y < Paint.Max.y;
- ++Y)
- {
- uint32 *Pixel = (uint32 *)(Row + Paint.Min.x*sizeof(uint32));
- for(int X = Paint.Min.x;
- X < Paint.Max.x;
- ++X)
- {
- if (X < Layer->Raster.Width && X > 0) {
- v2 Pos = V2(abs(Center.x - (X - Paint.Min.x)), abs(Center.y - (Y - Paint.Min.y)));
- real32 L = sqrt(LengthSq(Pos)) + Center.x;
- real32 Gradient = pow(Ceil(L, MaxLength) / MaxLength, Brush.Hardness);
- RenderAlpha(Pixel, ColToUint32({1.0f, 1.0f, 1.0f, 1.0f - Gradient}));
- }
- Pixel++;
- }
- Row += Layer->Raster.Pitch;
- }
-}
-*/