processing / p5.js-editor

Deprecated desktop editor for p5.js
https://p5js.org
MIT License
338 stars 91 forks source link

SVG image positioning and scaling #204

Open lmccart opened 8 years ago

lmccart commented 8 years ago

repost from @geoffalday on p5.js repo https://github.com/processing/p5.js/issues/1179#issuecomment-174550741

I tested this on chrome, safari, and firefox and all look fine, it's just in the p5 editor when not run in browser that there seems to be an issue.


When loading an SVG image, the positioning and scaling doesn't render as expected. Note the two images used in this example were saved from the same file with the same dimensions.

var alien_png;
var alien_svg;

function preload() {
  alien_png = loadImage("data/alien.png");
  alien_svg = loadImage("data/alien.svg");
}

function setup() {
  createCanvas(400, 400);
  fill(0);

}

function draw() {
  background(255);

  image(alien_png, 10, 10);
  image(alien_svg, 10, 10);
}

This is what is rendered with that code: svg_bug_1

If I remove the viewBox attribute from the SVG... alien_svg

alien_svg_viewbox_removed

... it renders as expected (at least how I would expect it to): svg_bug_2

Thanks!