Skip to content

Commit

Permalink
butterbur: Fixes for Dot
Browse files Browse the repository at this point in the history
- Fixed broken round dot
- Default dot to size 10, round cap
- Also fixed seeing dot with size of 1 or 0
  • Loading branch information
jerstlouis committed Jan 26, 2022
1 parent ad6ce26 commit 414480b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions butterbur/src/GraphicalElement.ec
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ public class Arc : Shape

shpType = arc;
innerRadius = 0;
stroke.cap = round;
stroke.width = 10;

public:
property Pointf center
Expand Down
9 changes: 5 additions & 4 deletions butterbur/src/tesselation/shapesTesselation.ec
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ struct TesselatedShape
bool partialSector = false, fullSector = false;
uint count = 0;
Array<Array<Pointf>> inner = null;
Stroke stroke = shp.stroke;
LineCap cap = stroke.cap;

switch(shp.shpType)
{
Expand All @@ -67,6 +69,7 @@ struct TesselatedShape
nodes = tmpNodes.array;
nodes[0] = dot.point;
count = 1;
if(cap == flat) cap = square;
break;
}
case ShapeType::path:
Expand Down Expand Up @@ -196,8 +199,6 @@ struct TesselatedShape
}

{
Stroke stroke = shp.stroke;
LineCap cap = stroke.cap;
LineJoin join = stroke.join;
uint i, tc = count;

Expand All @@ -221,6 +222,8 @@ struct TesselatedShape
int inc = flip ? -1 : 1;
uint ni = flip ? tc-1 : 0;

if(tc == 1 && lineWidth < 2) lineWidth = 2;

vCount = closed ? (tc * (rCount+1)) : (2*(capCount+1) + ((tc > 2) ? (tc-2) * (rCount+1) : 0));
points = this.points = renew this.points Pointf[vCount];

Expand Down Expand Up @@ -251,8 +254,6 @@ struct TesselatedShape

if(i == tc + (tc == 1) - 1)
end = true;
if(i == tc)
i = 0;

{
bool thisFlip = false, isCap = false;
Expand Down
7 changes: 5 additions & 2 deletions butterbur/tests/graphics/butterbur.ec
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,11 @@ class ButterburTest : Window
Dot dot
{
//mge,
point = { 300, 300 };
stroke = { black, width = 20, cap = square };
point = { 250, 300 };
stroke = { black, width = 20,
cap = round
//cap = square
};
};
GraphicalPresentation dotPresentation {/*gSurface*/ scene, graphic = dot };

Expand Down

0 comments on commit 414480b

Please sign in to comment.