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

Stroke wrong display #123

Closed
JSUYA opened this issue Oct 29, 2020 · 2 comments
Closed

Stroke wrong display #123

JSUYA opened this issue Oct 29, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@JSUYA
Copy link
Member

JSUYA commented Oct 29, 2020

test code

--- a/src/examples/Opacity.cpp
+++ b/src/examples/Opacity.cpp
@@ -52,6 +52,9 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape3->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
     shape3->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
     shape3->fill(255, 0, 0, 255);
+
+    shape3->stroke(100);
+    shape3->stroke(255, 0, 0, 255);
     scene->push(move(shape3));

image

There is a problem with the top of red circle.

@JSUYA JSUYA added the bug Something isn't working label Oct 29, 2020
@mgrudzinska
Copy link
Collaborator

mgrudzinska commented Oct 29, 2020

I think this is the expected behavior.

The fill itself draws correctly. After adding a stroke the 'problem' appears because we don't close it. If you add shape3->close(), the beginning and the end of the stroke will be joined together and you will get a smooth vertex.

Below I have drawn 4 separate cubics - as you can see the fill connects smoothly, while the strokes with the default cap do not connect.
If you change the stroke cap to Butt (shape->stroke(tvg::StrokeCap::Butt)) you will get a stroke that looks like one whole.

Default cap:
notIssue

Butt cap:
notIssueButt

The code:

shape3a->moveTo(cx, cy - radius);
shape3a->cubicTo(cx + halfRadius, cy - radius, cx + radius, cy - halfRadius, cx + radius, cy);

shape3b->moveTo(cx + radius, cy);
shape3b->cubicTo(cx + radius, cy + halfRadius, cx + halfRadius, cy + radius, cx, cy+ radius);

shape3c->moveTo(cx, cy + radius);
shape3c->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);

shape3d->moveTo(cx - radius, cy);
shape3d->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);

shape3a->fill(255, 0, 0, 255);
shape3b->fill(0, 255, 0, 255);
shape3c->fill(0, 0, 255, 255);
shape3d->fill(255, 0, 255, 255);

shape3a->stroke(255, 0, 0, 255);
shape3b->stroke(0, 255, 0, 255);
shape3c->stroke(0, 0, 255, 255);
shape3d->stroke(255, 0, 255, 255);

shape3a->stroke(100);
shape3b->stroke(100);
shape3c->stroke(100);
shape3d->stroke(100);

shape3a->stroke(tvg::StrokeCap::Butt);
shape3b->stroke(tvg::StrokeCap::Butt);
shape3c->stroke(tvg::StrokeCap::Butt);
shape3d->stroke(tvg::StrokeCap::Butt);

scene->push(move(shape3a));
scene->push(move(shape3b));
scene->push(move(shape3c));
scene->push(move(shape3d));

@JSUYA
Copy link
Member Author

JSUYA commented Oct 30, 2020

@mgrudzinska
Thank you for your kind explanation. I have checked there are no problems. I will close this issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants