Closed gurushida closed 1 year ago
The rationale for this modification is to allow using this project to create svg images offline from command line tools.
Usage:
const man = {"fatness":0.97,"teamColors":["#89bfd3","#7a1319","#07364f"],"hairBg":{"id":"none"},"body":{"id":"body4","color":"#b1bfd9","size":1},"jersey":{"id":"hockey"},"ear":{"id":"ear1","size":1.04},"head":{"id":"head5","shave":"rgba(0,0,0,0)"},"eyeLine":{"id":"line6"},"smileLine":{"id":"line1","size":0.33},"miscLine":{"id":"forehead5"},"facialHair":{"id":"neckbeardSB2"},"eye":{"id":"eye19","angle":15},"eyebrow":{"id":"eyebrow17","angle":-2},"hair":{"id":"afro2","color":"#0f0902","flip":false},"mouth":{"id":"smile","flip":false},"nose":{"id":"nose6","flip":false,"size":0.7},"glasses":{"id":"none"},"accessories":{"id":"none"}}; const face = generate(man, {}); const xml = display('export as svg string', face, {}); console.log(xml); /* Prints: <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="100%" height="100%" viewBox="0 0 400 600" preserveAspectRatio="xMinYMin meet"> <g transform="scale(1 1) translate(0 0)"> <path fill="#b1bfd9" stroke="#000" stroke-width="6" d="M20 600s-5-60 40-70c15 0 45-15 90-35l50-195 50 195c45 20 75 35 90 35 45 10 45 70 45 70" class="body"/> </g> <g transform="scale(1 1) translate(0 0)"> <g stroke="#000"><path fill="#89bfd3" stroke-width="6" d="M120 505c0 20 50 15 80 35 30-20 80-15 80-35 0 0 50-5 80 5 0 0 20 10 30 40s10 60 10 60H0s0-30 10-60 30-40 30-40c30-10 80-5 80-5Z" class="hockeyPrimary"/><path fill="#07364f" d="M4.5 577.03S10 580 20 580c30-15 110-20 180-20 90 0 150 5 180 20 10 0 17-2.97 17-2.97l1 12.97s-8 5-18 5c-40-20-110-22.48-180-22.48-80 0-150 2.48-180 22.48-10 0-18-5-18-5l2.5-12.97Z" class="stripeAccent"/><path fill="#7a1319" stroke-width="2" d="M172.5 545.53c-110-4.5-152 22.5-152 22.5s-9 1-14.5-5c15-48 34-53.03 34-53.03s50-5 80-5c0 20 52.5 40.53 52.5 40.53Zm55 0c110-4.5 152 22.5 152 22.5s9 1 14.5-5c-15-48-34-53.03-34-53.03s-50-5-80-5c0 20-52.5 40.53-52.5 40.53Z" class="shoulderSecondary"/><path fill="#07364f" stroke-width="2" d="M120 505c0 20 50 15 80 30 30-15 80-10 80-30l15-1c0 41-40 21-95 56-55-35-95-15-95-56l15 1Z" class="collarAccent"/><path fill="none" stroke-width="6" d="M120 505c0 20 50 15 80 35 30-20 80-15 80-35 0 0 50-5 80 5 0 0 20 10 30 40s10 60 10 60H0s0-30 10-60 30-40 30-40c30-10 80-5 80-5Z" class="hockeyStroke"/><path fill="#7a1319" stroke-width="2" d="M180 528.21h40l10 17.05L200 564l-30-18.74 10-17.05Z" class="shieldSecondary"/></g> </g> <g transform="translate(-145 25) scale(1.04 1.04) translate(-7.692307692307699 -11.538461538461549) translate(0.9300000000000008 0)"> <path fill="#b1bfd9" stroke="#000" stroke-width="6" d="M43 13S23 3 13 3 3 23 3 33s3 20 13 30 27-10 27-10V13Z"/> </g> <g transform="translate(145 25) scale(-1.04 1.04) translate(-392.3076923076923 -11.538461538461549) translate(0.9300000000000008 0)"> <path fill="#b1bfd9" stroke="#000" stroke-width="6" d="M43 13S23 3 13 3 3 23 3 33s3 20 13 30 27-10 27-10V13Z"/> </g> <g transform="scale(0.994 1) translate(1.2072434607645885 0)"> <path fill="#b1bfd9" stroke="#000" stroke-width="6" d="M200 100c100 0 150 60 150 200 0 50-.51 71.54-10 100-10 30-80 70-90 80s-20 20-50 20-40-10-50-20-80-50-90-80c-9.49-28.46-10-50-10-100 0-140 50-200 150-200Z" class="head"/><path fill="rgba(0,0,0,0)" d="M200 410c30 0 50 10 50 10 30 0 90-15 90-120h10c0 50-.51 71.54-10 100-10 30-80 70-90 80s-20 20-50 20-40-10-50-20-80-50-90-80c-9.49-28.46-10-50-10-100h10c0 105 60 120 90 120 0 0 20-10 50-10Z" class="faceShave"/><path fill="rgba(0,0,0,0)" d="M60 300H50c0-140 50-200 150-200s150 60 150 200h-10v-10c0-5-10-20-15-25s-5-55-15-65c-40-40-60 0-110 0s-70-40-110 0c-10 10-10 60-15 65s-15 20-15 25v10Z" class="headShave"/> </g> <g> <path fill="none" stroke="#000" stroke-width="2" d="M235 285s10-10 45-10m-115 10s-10-10-45-10" class="eyeline6"/> </g> <g transform="translate(-50 135) scale(0.33 0.33) translate(406.06060606060606 609.090909090909)"> <path fill="none" stroke="#000" stroke-width="2" d="M9 2s-12.5 8.95-4 34" class="shp0"/> </g> <g transform="translate(50 135) scale(-0.33 0.33) translate(-806.060606060606 609.090909090909)"> <path fill="none" stroke="#000" stroke-width="2" d="M9 2s-12.5 8.95-4 34" class="shp0"/> </g> <g> <path fill="none" stroke="#000" stroke-width="2" d="M200 270v-15l5-5-5 5-5-5m-25-15s15 0 30 5c15-5 30-5 30-5m-75-15s35 0 45 5c10-5 45-5 45-5"/> </g> <g transform="scale(0.994 1) translate(1.2072434607645885 0)"> <path fill="#0f0902" stroke="#000" d="M200 450c20 0 10 30 20 30s35-5 45-15c20-20 30-30 40-30 0 70-65 80-105 80S95 505 95 435c10 0 20 10 40 30 10 10 35 15 45 15s0-30 20-30Z" class="shp0"/><path fill="#0f0902" fill-rule="evenodd" stroke="#000" d="M60 300H50s-8.85 85.38 20 95c15 5 0-34.1 0-34.1S65 355 60 300Zm279 0h10s8.85 85.38-20 95c-15 5 0-34.1 0-34.1s5-5.9 10-60.9Z" class="shp0"/> </g> <g transform="translate(-60 10) rotate(15 200 300)"> <path d="M10 35 5 20s15-5 30-5 35 10 35 10l-5 10H10Z" style="fill:#f5f3ee"/><path d="M37.93 32.78c-4.53 0-8.2-3.66-8.2-8.2 0-4.53 3.67-8.19 8.2-8.19 4.53 0 8.19 3.66 8.19 8.19 0 4.54-3.66 8.2-8.19 8.2Z" style="fill:#000"/><path d="M10 35 5 20.72S25 15 35 15s35 10 35 10l-5 10" style="fill:none;stroke:#000;stroke-width:6"/> </g> <g transform="translate(60 10) rotate(-15 200 300) scale(-1 1) translate(-400 0)"> <path d="M10 35 5 20s15-5 30-5 35 10 35 10l-5 10H10Z" style="fill:#f5f3ee"/><path d="M37.93 32.78c-4.53 0-8.2-3.66-8.2-8.2 0-4.53 3.67-8.19 8.2-8.19 4.53 0 8.19 3.66 8.19 8.19 0 4.54-3.66 8.2-8.19 8.2Z" style="fill:#000"/><path d="M10 35 5 20.72S25 15 35 15s35 10 35 10l-5 10" style="fill:none;stroke:#000;stroke-width:6"/> </g> <g transform="translate(-60 -30) rotate(-2 200 300)"> <path fill="#0f0902" stroke="#000" d="M22.1 6.48c-.96.74-2.71 2.33-3.9 3.5-1.23 1.17-2.47 2.63-2.7 3.13-.23.52-.26.96-.05.96.2 0 3.06-1.05 6.01-1.65 2.72-.11 6.42.27 8.3.66 1.87.43 6.07 1.67 9.35 2.77 3.39 1.08 7.94 2.5 10.06 3.19 2.23.61 5.3 1.02 6.7.99 1.43-.06 3.53-.35 4.62-.61 1.68-.41 1.9-.62 1.72-1.65-.12-.91-.85-1.63-2.76-2.9-1.36-1-4.3-2.66-6.56-3.72-2.26-1.13-6.33-3.1-9.03-4.35-2.71-1.31-7.02-3.02-9.57-3.73-3.6-.81-5.24-.65-7.53.51-1.61.77-3.71 2.09-4.66 2.9Z"/><path d="M0 10h5v5H0v-5Z" style="fill:none"/> </g> <g transform="translate(60 -30) rotate(2 200 300) scale(-1 1) translate(-400 0)"> <path fill="#0f0902" stroke="#000" d="M22.1 6.48c-.96.74-2.71 2.33-3.9 3.5-1.23 1.17-2.47 2.63-2.7 3.13-.23.52-.26.96-.05.96.2 0 3.06-1.05 6.01-1.65 2.72-.11 6.42.27 8.3.66 1.87.43 6.07 1.67 9.35 2.77 3.39 1.08 7.94 2.5 10.06 3.19 2.23.61 5.3 1.02 6.7.99 1.43-.06 3.53-.35 4.62-.61 1.68-.41 1.9-.62 1.72-1.65-.12-.91-.85-1.63-2.76-2.9-1.36-1-4.3-2.66-6.56-3.72-2.26-1.13-6.33-3.1-9.03-4.35-2.71-1.31-7.02-3.02-9.57-3.73-3.6-.81-5.24-.65-7.53.51-1.61.77-3.71 2.09-4.66 2.9Z"/><path d="M0 10h5v5H0v-5Z" style="fill:none"/> </g> <g transform="translate(0 140)"> <path d="M170 430s10 20 30 20 30-20 30-20h-60Z" style="fill:#fff;stroke:#000;stroke-width:5"/> </g> <g transform="translate(0 70) scale(0.7 0.7) translate(85.71428571428574 128.5714285714286)"> <path fill="#b1bfd9" stroke="#000" stroke-width="5" d="M190 325s-5 20-5 45c-20-5-15 15-15 20 20 0 15 10 30 10s10-10 30-10c0-5 5-25-15-20 0-25-5-45-5-45" class="nose"/> </g> <g transform="scale(0.994 1) translate(1.2080683744485203 0)"> <path fill="#0f0902" stroke="#000" stroke-width="4" d="M198.27 56.61c-1 1.31-1.41 3.32-1.35 6.68.06 3.65.66 5.87 2.56 9.35 1.37 2.51 2.24 4.75 1.93 4.98-.3.23-1.51.41-2.69.39-1.18-.01-3.36-.95-4.84-2.08-1.48-1.12-3.16-1.79-3.73-1.48-.57.31-2.46 1.71-4.2 3.11-2.67 2.14-3.29 2.34-3.93 1.29-.42-.68-.77-2.45-.78-3.94l-.01-2.69c-10.31-1.17-11.31-1.58-12.79-3.62-.95-1.3-3.22-3.13-5.04-4.07-1.83-.94-4.35-2.49-5.61-3.45l-2.29-1.74c-9.11 4.5-12.09 6.27-12.51 6.84-.51.7 1.65 5.32 6.71 14.31 4.1 7.31 7.27 13.47 7.04 13.7-.23.22-4.24-1.78-8.91-4.46-4.68-2.68-10-5.33-11.82-5.89-1.83-.56-3.79-.79-4.36-.53-.57.27-1.05.96-1.06 1.53-.02.57 1.28 2.71 2.89 4.77 1.61 2.05 2.92 3.92 2.93 4.15 0 .23-4.01.41-8.91.41-8.24-.01-9.4.2-15.15 2.69-3.42 1.48-6.97 2.7-7.88 2.7-.91 0-2.86.47-4.33 1.03-2.39.92-2.94.83-5.18-.84-1.39-1.03-3.17-1.85-3.97-1.84-.8.02-3.51 1.82-6.02 4.01-2.51 2.18-5.03 4.21-5.6 4.52-.57.31-4.21-.57-8.09-1.94-3.87-1.37-8.35-2.49-9.95-2.49-1.6 0-2.9.18-2.9.41 0 .23.58 1.82 1.29 3.53.72 1.71 3.69 6.29 6.61 10.17 2.91 3.88 5.31 7.7 5.33 8.5.02 1.29-.93 1.45-8.69 1.45l-8.71-.01c-26.05 13.64-35.66 18.9-38.17 20.49-2.51 1.59-5.6 3.88-6.87 5.09-1.26 1.2-2.29 2.47-2.28 2.81.01.34 1.23.61 2.71.59 1.49-.01 5.5-1.12 8.92-2.45 3.43-1.33 6.3-2.35 6.4-2.25.09.1-1.69 2.88-3.95 6.19-2.26 3.31-4.12 6.67-4.12 7.47-.01 1.31.62 1.39 6.63.83 3.66-.34 6.67-.34 6.68 0 .02.35-1.56 2.13-3.52 3.97-1.96 1.84-7.3 5.91-11.87 9.05-4.56 3.14-9.88 6.95-11.82 8.47-2.26 1.77-3.54 3.43-3.55 4.63-.02 1.02.82 2.7 1.86 3.71 1.04 1.02 2.54 1.86 3.34 1.87.8.01 4.06-1.66 7.26-3.71s5.98-3.63 6.19-3.52c.2.11.62 1.33.92 2.7.53 2.43.33 2.62-9.72 8.85-5.64 3.49-11.85 7.5-13.79 8.91-2.79 2.02-3.52 3.06-3.52 5.03-.01 1.75.67 3 2.27 4.21 1.26.94 3.12 1.87 4.15 2.07 1.03.2 2.71.55 3.73.79 1.03.23 3.08 1.53 4.57 2.9l2.69 2.49c-4.18 3.48-7.16 6.19-9.31 8.26-2.89 2.78-3.93 4.41-3.97 6.25-.04 1.37.7 3.52 1.62 4.77.97 1.3 2.49 2.29 3.56 2.3 1.02.01 2.35.29 2.95.62.8.46.26 1.68-2.14 4.76-1.78 2.28-3.67 4.98-4.2 6.01-.54 1.03-.98 2.43-.98 3.11 0 .99 1.2 1.25 5.81 1.25 3.19 0 5.79.28 5.78.62-.02.35-.75 2.68-1.64 5.19-.88 2.51-1.62 5.21-1.63 6.01-.02.8.9 1.83 2.04 2.29 1.14.45 2.08 1.11 2.09 1.45 0 .34-.55 2.49-1.24 4.77-.69 2.28-1.25 4.8-1.26 5.6-.01.85.61 1.45 1.48 1.45.83 0 1.95-.47 2.51-1.04.8-.82 1-.69.96.63-.02.91.72 2.68 1.65 3.94.96 1.3 2.49 2.29 3.55 2.3 1.03 0 2.35.28 2.95.62.81.45.26 1.67-2.14 4.76-1.78 2.28-3.67 4.98-4.2 6.01-.54 1.02-.97 2.42-.97 3.11-.01.99 1.24 1.24 6.22 1.25h6.22l-3.33 9.54c3.54 3.57 5.12 4.59 5.81 4.58.68-.01 4.98-3.71 9.54-8.21 5.21-5.13 9.39-8.53 11.21-9.12 1.6-.52 4.68-.94 6.85-.93l3.94.01c-.03-22.79-.03-22.82 2.87-28.62 1.59-3.19 5.03-8.6 7.64-12.02 2.61-3.42 5.26-7.71 5.9-9.54.63-1.82 2.07-9.85 3.2-17.83 1.12-7.99 2.98-18.25 4.12-22.82 1.14-4.56 2.91-9.95 3.93-11.98 1.02-2.03 2.97-4.36 4.34-5.18 1.37-.81 5.29-2.11 8.72-2.89 5.66-1.28 14.65-1.4 99.97-1.34 71.98.05 95.09.31 99.55 1.12 3.2.58 7.28 1.86 9.08 2.85 2.14 1.18 3.92 3.09 5.18 5.54 1.06 2.05 2.84 7.47 3.97 12.03 1.12 4.56 2.96 14.83 4.07 22.82 1.12 7.98 2.55 16.01 3.18 17.84.63 1.82 3.28 6.12 5.88 9.54 2.61 3.43 6.04 8.84 7.63 12.04 2.89 5.8 2.9 5.82 2.87 17.21l-.03 11.41c7.07 0 9.96.44 10.99.97 1.03.53 5.78 4.64 10.57 9.13 4.79 4.49 9.36 8.17 10.16 8.17.8 0 2.42-.84 3.61-1.86l2.15-1.87c-2.06-7.07-2.65-9.41-2.65-9.75.01-.34 2.62-.62 5.82-.62 4.61.01 5.81-.25 5.81-1.24 0-.68-.44-2.08-.97-3.11-.54-1.03-2.42-3.73-4.2-6.02-2.39-3.08-2.94-4.3-2.13-4.76.59-.33 1.92-.61 2.95-.62 1.06 0 2.59-.99 3.56-2.29.92-1.25 1.67-2.75 1.66-3.32-.02-.74.69-.85 2.48-.41 2.16.54 2.5.4 2.48-1.03-.02-.92-.55-3.53-1.18-5.81-.63-2.28-.9-4.55-.61-5.04.3-.49 1.19-1.14 1.99-1.45.8-.31 1.46-1.22 1.47-2.01 0-.8-.75-3.7-1.67-6.44-.93-2.73-1.68-5.07-1.67-5.18.01-.12 2.63-.21 5.82-.21 4.61.01 5.81-.25 5.81-1.24 0-.68-.44-2.08-.97-3.11-.53-1.02-2.42-3.73-4.19-6.01-2.4-3.09-2.95-4.31-2.14-4.76.6-.34 1.93-.62 2.95-.62 1.07-.01 2.6-1 3.56-2.3.93-1.25 1.68-3.12 1.66-4.14-.01-1.03-.4-2.62-.86-3.53-.45-.91-3.44-3.9-6.63-6.64l-5.8-4.98c5.56-4.61 7.93-5.82 9.13-5.8 1.14.02 3.38-.82 4.98-1.87 2.19-1.45 2.95-2.57 3.11-4.59.18-2.29-.29-3.03-3.32-5.22-1.93-1.4-8.13-5.42-13.77-8.93-10.05-6.24-10.25-6.42-9.71-8.86.3-1.37.72-2.58.93-2.69.21-.12 2.99 1.47 6.18 3.53 3.19 2.05 6.46 3.74 7.26 3.76.8.01 2.28-.83 3.3-1.87s1.86-2.73 1.87-3.75c.01-1.22-1.2-2.82-3.51-4.63-1.94-1.52-7.25-5.34-11.81-8.49-4.57-3.14-9.9-7.22-11.86-9.06-1.95-1.85-3.54-3.63-3.52-3.97.02-.35 3.03-.34 6.68 0 6.01.57 6.64.49 6.64-.83-.01-.79-1.87-4.25-4.15-7.67l-4.15-6.23c10.29 3.87 14.39 4.99 15.76 4.99 1.37 0 2.51-.28 2.53-.62.02-.34-1.38-1.95-3.11-3.57-1.73-1.61-5.76-4.42-8.95-6.22-3.19-1.81-11.96-6.48-19.49-10.37-12.53-6.49-13.66-7.26-13.43-9.14.14-1.12 2.63-5.22 5.55-9.1 2.91-3.87 5.88-8.44 6.6-10.15.71-1.71 1.3-3.3 1.3-3.53 0-.23-1.31-.41-2.91-.42-1.59 0-6.07 1.12-9.95 2.49-3.88 1.36-7.52 2.23-8.09 1.92-.57-.3-3.09-2.34-5.6-4.53-2.51-2.18-5.21-3.99-6.01-4.01-.8-.02-2.6.81-4.01 1.83-1.55 1.14-3.59 1.81-5.19 1.72-1.44-.07-5.43-1.45-8.85-3.04-3.42-1.6-8.08-3.37-10.36-3.94-2.66-.66-6.46-.83-10.58-.49-3.54.3-6.43.26-6.42-.08 0-.34 1.33-2.3 2.94-4.36 1.62-2.05 2.82-4.29 2.67-4.97-.15-.73-1.12-1.21-2.32-1.17-1.13.04-3.08.32-4.33.62-2.04.48-2.24.34-1.92-1.32.21-1.03.58-3.27.84-4.98.32-2.18.15-3.12-.58-3.13-.57-.01-2.02 1.02-3.22 2.28-1.2 1.26-2.74 3.42-3.41 4.79-.68 1.36-1.75 2.71-2.38 2.98-.64.28-3.77-.12-6.96-.88l-5.81-1.37c-18.65 6.17-24.72 7.96-25.51 7.96-.81-.01-3.3-2.41-5.6-5.4-3.47-4.52-4.55-5.4-6.63-5.4-1.37 0-3.33-.38-4.36-.85-1.03-.46-3.36-2.78-5.18-5.15-1.82-2.38-4.99-7.48-7.05-11.35-2.05-3.87-4.14-7.17-4.66-7.34-.51-.16-1.57.55-2.36 1.59Z" class="afro2"/> </g> </svg> */
Thanks, this is nice!
I made a few changes while merging:
It's released in version 4
The rationale for this modification is to allow using this project to create svg images offline from command line tools.
Usage: