Skip to content

Commit

Permalink
add alpha to line color, fix sort for cross-browser...
Browse files Browse the repository at this point in the history
  • Loading branch information
dnanto committed Oct 6, 2024
1 parent 363a6a9 commit 351f07a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions js/democapsid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ function draw_net(PARAMS) {
lat_cfg.lattice.forEach((e) => e.forEach((f) => f.remove()));

if (PARAMS.facet_toggle) {
g.style.strokeColor = PARAMS.line_color;
g.style.strokeColor = PARAMS.line_color + PARAMS.line_alpha;
g.style.strokeWidth = PARAMS.line_size;
return g;
}
Expand Down Expand Up @@ -1145,7 +1145,7 @@ function draw_capsid(PARAMS) {
results = results.concat(fibers).concat(knobs);

// painter's algorithm
results.sort((a, b) => a.data.centroid[2] < b.data.centroid[2]);
results.sort((a, b) => a.data.centroid[2] - b.data.centroid[2]);
const g = new paper.Group({
children: results,
position: paper.view.center,
Expand All @@ -1169,7 +1169,7 @@ function draw_capsid(PARAMS) {
g.children
.filter((e) => e.data.type === "facet")
.forEach((e) => {
e.style.strokeColor = PARAMS.line_color;
e.style.strokeColor = PARAMS.line_color + PARAMS.line_alpha;
e.style.strokeWidth = PARAMS.line_size;
});
return g;
Expand All @@ -1181,7 +1181,10 @@ function draw_capsid(PARAMS) {
e.children.map((e) => {
const points = e.segments.map((e) => e.point);
const border = new paper.Group(
e.data.strokes.map((f) => new paper.Path({ segments: f.map((i) => points[i]), closed: false, style: { strokeColor: PARAMS.line_color, strokeWidth: PARAMS.line_size } }))
e.data.strokes.map(
(f) =>
new paper.Path({ segments: f.map((i) => points[i]), closed: false, style: { strokeColor: PARAMS.line_color + PARAMS.line_alpha, strokeWidth: PARAMS.line_size } })
)
);
return new paper.Group([e.clone(), border]);
})
Expand Down

0 comments on commit 351f07a

Please sign in to comment.