Giter Club home page Giter Club logo

Comments (12)

detrothe avatar detrothe commented on May 24, 2024 1

I found following Link: https://stackoverflow.com/questions/6042550/svg-fill-color-transparency-alpha
Is there a way to specify fill-opacity directly in code via a member function for two.Path?
Part of the link:
image

from two.js.

jonobr1 avatar jonobr1 commented on May 24, 2024

Have you tried curve.fill = "none";?

from two.js.

detrothe avatar detrothe commented on May 24, 2024

from two.js.

jonobr1 avatar jonobr1 commented on May 24, 2024

Unfortunately different browsers have different implementations of "none", so it's not a great option for Two.js.

Have you tried curve.fill = "rgba(0, 0, 0, 0);"?

from two.js.

detrothe avatar detrothe commented on May 24, 2024

from two.js.

jonobr1 avatar jonobr1 commented on May 24, 2024

Got it. That makes sense. If this is a static image (not animating) and you are using the SVG Renderer then you can always access the underlying SVG element in code like this. But, be sure to call two.update(); or have the renderer render at least once beforehand so that the elements are created:

// Given your curve code
two.add(curve);
two.update();

const elem = curve.renderer.domElement;
elem.setAttribute('fill-opacity', 0);

from two.js.

detrothe avatar detrothe commented on May 24, 2024

It is a static image. The image is created after a finite element calculation, and two.update() is always called. Your suggestion with curve.fill="none" serves me fine. I don't have to care about old browsers, because my students have current hardware, usually newer than mine.
But two.makeArrow still has black background, see my first comment, (picture in the middle). Other users of your lib might have that problem too and .nofill() will not work as expected . Or am I wrong?

from two.js.

jonobr1 avatar jonobr1 commented on May 24, 2024

Got it. I'll have to re-run tests to see if all the browsers support curve.fill = "none". At the time of writing, which was a long time ago, both Firefox and Safari did not support "none". This is why noFill yields transparent. They may now and if so then I'll replace it.

Easy fix.

from two.js.

jonobr1 avatar jonobr1 commented on May 24, 2024

No, because fill-opacity is not available in all renderers. That is why it's recommended to use:

curve.renderer.domElement.setAttribute('fill-opacity', 0);

from two.js.

detrothe avatar detrothe commented on May 24, 2024

ok

from two.js.

jonobr1 avatar jonobr1 commented on May 24, 2024

v8.12 will have noFill and noStroke execute CSS commands "none" instead of "transparent"

from two.js.

detrothe avatar detrothe commented on May 24, 2024

from two.js.

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.