Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nanosvgrast.h #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/nanosvgrast.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@ static void nsvg__flattenCubicBez(NSVGrasterizer* r,
float x3, float y3, float x4, float y4,
int level, int type)
{
const int max_level = 10;
float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
float dx,dy,d2,d3;

if (level > 10) return;
if (level > max_level) return;

x12 = (x1+x2)*0.5f;
y12 = (y1+y2)*0.5f;
Expand All @@ -358,14 +359,16 @@ static void nsvg__flattenCubicBez(NSVGrasterizer* r,
nsvg__addPathPoint(r, x4, y4, type);
return;
}

++level;
if (level > max_level) return;

x234 = (x23+x34)*0.5f;
y234 = (y23+y34)*0.5f;
x1234 = (x123+x234)*0.5f;
y1234 = (y123+y234)*0.5f;

nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level, 0);
nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level, type);
}

static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
Expand Down