![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
g2-svg is an SVG addon for g2. Maybe you want to learn more about g2, a 2D graphics command queue library.
<canvas id="c" width="200" height="100"></canvas> <!-- draw canvas graphics here -->
<span id="svg" data-width="200" data-height="100"></span> <!-- embed svg markup here -->
<script src='g2.js'></script>
<script src='g2.svg.js'></script> <!-- SVG addon for g2 -->
<script>
g2().rec(40,30,120,40,{ls:"green",fs:"orange",lw:3}) // create g2 object, add rectangle with style.
.exe(document.getElementById("c").getContext("2d")) // render to canvas.
.exe(document.getElementById("svg")); // render as svg to 'span' element.
</script>
In order to create SVG output g2's exe
command can be used. exe
's first argument must always be a
suitable rendering context. For providing such a rendering context we have two possibilities:
SVG Container | Example | Comment |
---|---|---|
Any HTML container element | <div data-width="200" data-height="100"></div> | data-width and data-height attributes have to be provided in order to specify the viewport size. The SVG markup will be inserted into that element then via innerHTML . So previous content gets overwritten. |
Any Javascript object | { width:200, height:100 } | An arbitrary javascript object providing at least both a width and a height property. The SVG markup will be written as a string to a new or existing svg property of that object. |
The Javascript object or HTML container element has to provide viewport size values.
The SVG output of the example above reads:
<svg width="200" height="100" fill="transparent" stroke="black"
font-family="serif" font-style="normal" font-size="12" font-weight="normal">
<g stroke="green" fill="orange" stroke-width="3">
<rect x="40" y="30" width="120" height="40"/>
</g>
</svg>
node.js
var fs = require('fs'),
g2 = require('./g2.js'), // load 'g2'.
x = require('./g2.svg.js'), // load 'g2.svg'.
ctx = {width:200,height:100}, // provide context including viewport size.
g = g2().style({ls:"green",fs:"orange",lw:3}) // create g2 object and add style.
.rec(40,30,120,40) // add rectangle.
.exe(ctx); // render as svg.
fs.writeFile("./rec.svg", ctx.svg, function(err) { if(err) return console.log(err); });
See this growing table of test cases with canvas and svg output side by side.
Use the link https://gitcdn.xyz/repo/goessner/g2-svg/master/g2.svg.min.js for getting the latest commit as a raw file.
In HTML use ...
<script src="https://gitcdn.xyz/repo/goessner/g2-svg/master/g2.svg.min.js"></script>
g2.svg
is licensed under the terms of the MIT License.
#Change Log
earc
elliptical arc command added.use
command execution simplified.g2.prototype.use
removed.g2.spline
performing 'centripetal Catmull-Rom' interpolation.g2.State.hatch
fill style removed.style
argument for elements lin
,rec
,cir
,arc
,ply
.style
as first argument for stroke
,fill
and drw
, optionally followed by a svg path definition string.CHANGELOG.md @goessner.
FAQs
g2-svg - SVG addon for g2
We found that g2d-svg 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.