Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
canvas2svg-conradirwin
Advanced tools
This library turns your Canvas into SVG using javascript. In other words, this library lets you build an SVG document using the canvas api. Why use it?
http://gliffy.github.io/canvas2svg/
We create a mock 2d canvas context. Use the canvas context like you would on a normal canvas. As you call methods, we build up a scene graph in SVG. Yay!
//Create a new mock canvas context. Pass in your desired width and height for your svg document.
var ctx = new C2S(500,500);
//draw your canvas like you would normally
ctx.fillStyle="red";
ctx.fillRect(100,100,100,100);
//etc...
//serialize your SVG
var mySerializedSVG = ctx.getSerializedSvg(); //true here, if you need to convert named to numbered entities.
//If you really need to you can access the shadow inline SVG created by calling:
var svg = ctx.getSvg();
To run tests:
npm install
npm test
To run tests against Chrome and Firefox, call karma directly. This is not the default npm test due to the limited browser selection in travis.
npm install karma-cli -g
karma start
Play with canvas2svg in the provided test/playground.html or run test locally in your browser in test/testrunner.html
Add a test file to the test/example folder. In your file make sure to add the drawing function to the global C2S_EXAMPLES
,
with your filename as a key. For example test\example\linewidth.js
should look something like:
window.C2S_EXAMPLES['linewidth'] = function(ctx) {
for (var i = 0; i < 10; i++){
ctx.lineWidth = 1+i;
ctx.beginPath();
ctx.moveTo(5+i*14,5);
ctx.lineTo(5+i*14,140);
ctx.stroke();
}
};
install gulp globally if you haven't done so already
npm install -g gulp
Then run the following to update playground.html and testrunner.html
gulp
You should now be able to select your new example from playground.html or see it run in testrunner.html
If you find a bug, or want to add functionality, please add a new test case and include it with your pull request.
Some canvas 2d context methods are not implemented yet. Watch out for setTransform and arcTo.
This library is licensed under the MIT license.
FAQs
My unofficial version of canvas2svg
We found that canvas2svg-conradirwin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.