Skip to content

Commit

Permalink
Merge pull request #527 from theosanderson/layerspecs
Browse files Browse the repository at this point in the history
Fix hollow shapes for illustrator import in svg
  • Loading branch information
theosanderson authored Sep 14, 2023
2 parents dafe7a0 + e175828 commit 3d99253
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions taxonium_component/src/utils/deckglToSvg.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,22 @@ const getSVGfunction = (layers, viewState) => {
let color;
if (!accessor) {
// make color transparent
color = [0, 0, 0, 0];
color = "none";
} else {
color = accessOrConstant(accessor, point).join(",");
const initColor = accessOrConstant(accessor, point);
// if rgba
if (initColor.length === 4) {
color = `rgba(${initColor.join(",")})`;
if (initColor[3] === 0) {
color = "none";
}
}
// if rgb
else if (initColor.length === 3) {
color = `rgb(${initColor.join(",")})`;
} else {
console.warn("Unsupported color format");
}
}
// check if stroked
let strokeColor, strokeWidth;
Expand All @@ -62,7 +75,7 @@ const getSVGfunction = (layers, viewState) => {

// if getRadius is a fn call it otherwise assume it's a value
const radius = accessOrConstant(layer.getRadius, point);
svgContent += `<circle cx="${x}" cy="${y}" r="${radius}" fill="rgb(${color})"
svgContent += `<circle cx="${x}" cy="${y}" r="${radius}" fill="${color}"
${
layer.stroked
? `stroke="rgb(${strokeColor})" stroke-width="${strokeWidth}"`
Expand Down

1 comment on commit 3d99253

@vercel
Copy link

@vercel vercel bot commented on 3d99253 Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.