Coder Social home page Coder Social logo

Stroke wrong display about thorvg HOT 2 CLOSED

thorvg avatar thorvg commented on May 17, 2024
Stroke wrong display

from thorvg.

Comments (2)

mgrudzinska avatar mgrudzinska commented on May 17, 2024

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));

from thorvg.

JSUYA avatar JSUYA commented on May 17, 2024

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

from thorvg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.