3Dmol.js icon indicating copy to clipboard operation
3Dmol.js copied to clipboard

Allow colorschemes in colorfunc

Open duerrsimon opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. It is a bit counterintuitive that colorfunc only allows to return colors and not the normal colorschemes

Describe the solution you'd like

let colorFixedSidechain = function(atom){
      if (selectedResidues.includes(atom.resi)){
          return "red"
      }else{
          return "WhiteCarbon"
      }
  }

Describe alternatives you've considered

let colorFixedSidechain = function(atom){
      if (selectedResidues.includes(atom.resi)){
          return "red"
      }else if (atom.elem == "O"){
          return "red"
      }else if (atom.elem == "N"){
          return "blue"
      }else if (atom.elem == "S"){
          return "yellow"
      }else{
          return "lightgray"
      }
  }

duerrsimon avatar Jun 29 '22 09:06 duerrsimon

@duerrsimon I want to contribute to this issue can you assign this to me?

0xClint avatar Jan 28 '23 12:01 0xClint

I really think the right solution is to implement colorfunc using getColorFromStyle:

let colorFixedSidechain = function(atom){
      if (selectedResidues.includes(atom.resi)){
          return "red"
      }else{
          return $3Dmol.getColorFromStyle(atom, {colorscheme: "whiteCarbon"});
      }
  }

@Omkar0803 If you'd like to get started contributed to the codebase, a nice easy first step to best resolve this issue is:

  1. Modify getColorFromStyle so it's comment is parsed as a jsdoc comment and it shows up in the documentation (it is missing an *).
  2. Modify getColorFromStyle os it can accept a string as well as a style object that will be assumed to be a color scheme name (so the above can be written more succinctly)
  3. Add a test that evaluates this functionality.
  4. Submit a pull request with the result that references this issue.

dkoes avatar Jan 28 '23 22:01 dkoes

Hey @dkoes , is their any starter guide to setup the github repo, getting some error in setting the project.

0xClint avatar Jan 29 '23 07:01 0xClint

Clone the repo and then run npm install

dkoes avatar Jan 29 '23 14:01 dkoes