gliffy / canvas2svg

Translates HTML5 Canvas draw commands to SVG
MIT License
683 stars 155 forks source link

Handling Decimal RGB values #85

Open swaroopg92 opened 2 years ago

swaroopg92 commented 2 years ago

I was getting constant errors until I realized that the code cannot handle decimal RGB values. In general, most places its integers but in applications with Color Picker where it has more precision, it can be decimal. Here is the regex command to allow decimal RGB. I hope it helps others.

regex = /rgba\(\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi;