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

Problems with changing opacity by atom #104

Closed
stared opened this issue Jun 23, 2015 · 2 comments
Closed

Problems with changing opacity by atom #104

stared opened this issue Jun 23, 2015 · 2 comments

Comments

@stared
Copy link

stared commented Jun 23, 2015

I wrote:

function highlightFrom(start) {
    return new pv.color.ColorOp(function(atom, out, index) {
      if (atom.index() > start) {
        out[index+0] = 1.0; // R
        out[index+1] = 0.0; // G
        out[index+2] = 0.0; // B
        out[index+3] = 1.0; // A
      } else {
        out[index+0] = 0.0;
        out[index+1] = 1.0;
        out[index+2] = 0.0;
        out[index+3] = 0.5;
      }
    });
  }

  viewer.forEach(function(go) {
    go.colorBy(highlightFrom(50));
  });

(As a side note, convention out[index+1] is begging for some description in docs; it wasn't intuitive for me and it took me some time guessing; at least comments (this // R // G // B // A) would be really nice.)

However, opacity does not work as intended: (i.e. it rather mixes with white than makes thing semi-transparent):

screen shot 2015-06-23 at 14 04 00

Is there way to make parts of a structure transparent or semi-transparent (either with colorBy or something like setOpacity)? (Setting opacity would be even nicer, as I don't intend to change a color.)

@biasmv
Copy link
Owner

biasmv commented Jun 23, 2015

Hi,

I believe you are experiencing the problems outlined here: #55. The part of the geometry you are highlighting (N-term) is always rendered before the rest of the protein. It would work correctly for the C-term.

I've started implementing a special highlighting pass in a local branch a while ago (see screenshot) It essentially abuses the alpha color channel for implementing a glow around the selected part. If there is interest, I can spend some time to get it ready for prime-time.

glowing

I agree, the docs are not very clear on what the indices mean. I'll update them to make it clearer.

@biasmv
Copy link
Owner

biasmv commented Jun 23, 2015

@biasmv biasmv closed this as completed Jun 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants