How to use the svgdom.document function in svgdom

To help you get started, we’ve selected a few svgdom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github itsezc / CycloneIO / packages / imager / tile / index.js View on Github external
// 		this._leftBorder = leftBorder
// 		this._bottomBorder = bottomBorder

// 		var draw = SVG('drawing').size(100, 100)
// 		this.value = draw.rect(100, 100).fill('#f06')
// 	}

// 	static requestHandler(request: Hapi.Request, h: any)
// 	{
// 		const instance = new Tile(1, true, true)
// 		return instance.value
// 	}
// }

import window from 'svgdom'
const document = window.document

import { SVG, registerWindow } from '@svgdotjs/svg.js'

registerWindow(window , document)

export default class Tile
{

	constructor(thickness, leftBorder, bottomBorder) 
	{ 
		this._thickness = thickness
		this._leftBorder = leftBorder
		this._bottomBorder = bottomBorder

		const canvas = SVG(document.documentElement)
		canvas.attr({
github mattkelly / cats-as-a-service / server.js View on Github external
'use strict';

const express = require('express');
const port = process.env.PORT || 3000;

const window = require('svgdom');
const SVG = require('svg.js')(window);
require('svg.path.js');
const doc = window.document;
const draw = SVG(doc.documentElement);

const svg2png = require('svg2png');

require('./cat.js');

function getCatSvg() {
    // Put everything in a viewbox
    draw.viewbox(0, 0, 100, 120);

    // Create a background
    //draw.rect(1000, 1000).move(-500, -500).fill('yellow');

    // Draw the cat
    draw.cat();
github gka / d3-jetpack / test / test-translate-selection.js View on Github external
tape('translate can take an array and set transform attr on svg element', function(test) {
  var svg = svgdom.document.documentElement;
  d3.select(svg).translate([10, 10]);
  test.equal(svg.getAttribute('transform'), 'translate(10,10)');
  test.end();
});
github gka / d3-jetpack / test / test-translate-selection.js View on Github external
tape('translate can take an array and set transform attr on svg element', function(test) {
  var svg = svgdom.document.documentElement;
  d3.select(svg).translate(function(){ return [10, 10]; });
  test.equal(svg.getAttribute('transform'), 'translate(10,10)');
  test.end();
});
github svgdotjs / svg.js / spec / spec / helper.js View on Github external
parserInDoc = false

if(typeof exports === 'object'){
  window = require('svgdom')
  SVG = require('../../dist/svg.js')
  document = window.document
  drawing = document.documentElement
  imageUrl = 'spec/fixtures/pixel.png'
  parserInDoc = true

  function tag(name, attrs, children) {
    var el = document.createElement(name)
    for(var i in attrs){
      el.setAttribute(i, attrs[i])
    }

    for(var i in children){
      if(typeof children[i] == 'string')
        children[i] = document.createTextNode(children[i])

      el.appendChild(children[i])
    }

svgdom

Straightforward DOM implementation for SVG, HTML and XML

MIT
Latest version published 6 months ago

Package Health Score

64 / 100
Full package analysis