Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
6d077678
Commit
6d077678
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added 'illustrative' color theme
parent
ae285940
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-theme/color.ts
+2
-0
2 additions, 0 deletions
src/mol-theme/color.ts
src/mol-theme/color/illustrative.ts
+80
-0
80 additions, 0 deletions
src/mol-theme/color/illustrative.ts
with
82 additions
and
0 deletions
src/mol-theme/color.ts
+
2
−
0
View file @
6d077678
...
...
@@ -27,6 +27,7 @@ import { UnitIndexColorThemeProvider } from './color/unit-index';
import
{
ScaleLegend
}
from
'
mol-util/color/scale
'
;
import
{
TableLegend
}
from
'
mol-util/color/tables
'
;
import
{
UncertaintyColorThemeProvider
}
from
'
./color/uncertainty
'
;
import
{
IllustrativeColorThemeProvider
}
from
'
./color/illustrative
'
;
export
type
LocationColor
=
(
location
:
Location
,
isSecondary
:
boolean
)
=>
Color
...
...
@@ -73,6 +74,7 @@ export const BuiltInColorThemes = {
'
cross-link
'
:
CrossLinkColorThemeProvider
,
'
element-index
'
:
ElementIndexColorThemeProvider
,
'
element-symbol
'
:
ElementSymbolColorThemeProvider
,
'
illustrative
'
:
IllustrativeColorThemeProvider
,
'
molecule-type
'
:
MoleculeTypeColorThemeProvider
,
'
polymer-id
'
:
PolymerIdColorThemeProvider
,
'
polymer-index
'
:
PolymerIndexColorThemeProvider
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-theme/color/illustrative.ts
0 → 100644
+
80
−
0
View file @
6d077678
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
ElementSymbol
,
isNucleic
,
isProtein
,
MoleculeType
}
from
'
mol-model/structure/model/types
'
;
import
{
Color
}
from
'
mol-util/color
'
;
import
{
StructureElement
,
Unit
,
Link
}
from
'
mol-model/structure
'
;
import
{
Location
}
from
'
mol-model/location
'
;
import
{
ColorTheme
}
from
'
../color
'
;
import
{
ParamDefinition
as
PD
}
from
'
mol-util/param-definition
'
import
{
ThemeDataContext
}
from
'
../theme
'
;
import
{
elementSymbolColor
}
from
'
./element-symbol
'
;
const
DefaultIllustrativeColor
=
Color
(
0xFFFFFF
)
const
Description
=
`Assigns an illustrative color similar to David Goodsell's Molecule of the Month style.`
export
const
IllustrativeColorThemeParams
=
{}
export
type
IllustrativeColorThemeParams
=
typeof
IllustrativeColorThemeParams
export
function
getIllustrativeColorThemeParams
(
ctx
:
ThemeDataContext
)
{
return
IllustrativeColorThemeParams
// TODO return copy
}
function
illustrativeColor
(
typeSymbol
:
ElementSymbol
,
moleculeType
:
MoleculeType
)
{
if
(
isNucleic
(
moleculeType
))
{
if
(
typeSymbol
===
'
O
'
)
{
return
Color
(
0xFF8C8C
)
}
else
if
(
typeSymbol
===
'
P
'
)
{
return
Color
(
0xFF7D7D
)
}
else
{
return
Color
(
0xFFA6A6
)
}
}
else
if
(
isProtein
(
moleculeType
))
{
if
(
typeSymbol
===
'
C
'
)
{
return
Color
(
0x7FB2FF
)
}
else
{
return
Color
(
0x6699FF
)
}
}
else
{
return
elementSymbolColor
(
typeSymbol
)
}
}
export
function
IllustrativeColorTheme
(
ctx
:
ThemeDataContext
,
props
:
PD
.
Values
<
IllustrativeColorThemeParams
>
):
ColorTheme
<
IllustrativeColorThemeParams
>
{
function
color
(
location
:
Location
):
Color
{
if
(
StructureElement
.
isLocation
(
location
))
{
if
(
Unit
.
isAtomic
(
location
.
unit
))
{
const
moleculeType
=
location
.
unit
.
model
.
atomicHierarchy
.
derived
.
residue
.
moleculeType
[
location
.
unit
.
residueIndex
[
location
.
element
]]
const
typeSymbol
=
location
.
unit
.
model
.
atomicHierarchy
.
atoms
.
type_symbol
.
value
(
location
.
element
)
return
illustrativeColor
(
typeSymbol
,
moleculeType
)
}
}
else
if
(
Link
.
isLocation
(
location
))
{
if
(
Unit
.
isAtomic
(
location
.
aUnit
))
{
const
elementIndex
=
location
.
aUnit
.
elements
[
location
.
aIndex
]
const
moleculeType
=
location
.
aUnit
.
model
.
atomicHierarchy
.
derived
.
residue
.
moleculeType
[
location
.
aUnit
.
residueIndex
[
elementIndex
]]
const
typeSymbol
=
location
.
aUnit
.
model
.
atomicHierarchy
.
atoms
.
type_symbol
.
value
(
elementIndex
)
return
illustrativeColor
(
typeSymbol
,
moleculeType
)
}
}
return
DefaultIllustrativeColor
}
return
{
factory
:
IllustrativeColorTheme
,
granularity
:
'
group
'
,
color
,
props
,
description
:
Description
,
// TODO add legend
}
}
export
const
IllustrativeColorThemeProvider
:
ColorTheme
.
Provider
<
IllustrativeColorThemeParams
>
=
{
label
:
'
Illustrative
'
,
factory
:
IllustrativeColorTheme
,
getParams
:
getIllustrativeColorThemeParams
,
defaultValues
:
PD
.
getDefaultValues
(
IllustrativeColorThemeParams
),
isApplicable
:
(
ctx
:
ThemeDataContext
)
=>
!!
ctx
.
structure
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment