0

I am working on svg editor, specifically the Method draw implementantion.

I want on loading the editor to load an image instead of a background rectangle. Currently the javascript file includes this command to create a background rectangle within the editor.

var createBackground = function(fill) {
    svgCanvas.createLayer("background")
        cur_shape = svgCanvas.addSvgElementFromJson({
            "element": "rect",
            "attr": {

                "x": -1,
                "y": -1,
                "width": res.w+2,
                "height": res.h+2,
                "stroke": "none",
                "id": "canvas_background",
                "opacity": 1,
                "fill":  '#ffffff',
                "style": "pointer-events:none"

I want to create an image instead of a rectangle.

Is this possible?

nicholaswmin
  • 21,686
  • 15
  • 91
  • 167

1 Answers1

0

You could change the function like this:

var createBackground = function(fill) {
    svgCanvas.createLayer("background")
        cur_shape = svgCanvas.addSvgElementFromJson({
            "element": "image",
            "attr": {
                "x": -1,
                "y": -1,
                "width": res.w+2,
                "height": res.h+2,
                "xlink:href": "/images/whatever.png" //this path should be changed
                "id": "canvas_background",
                "opacity": 1,
                "style": "pointer-events:none"
methodofaction
  • 70,885
  • 21
  • 151
  • 164
  • thanks mark! ive sent you an email 2 weeks ago but i guess you are too busy! thanks a lot man appreciate it. I got it to work yesterday on my own. Problem is when you coded the application with the create rectabgle background i was able to get a "reference" rectangle so that i know when my users draw outside their viewbox since i was able to get the rectangle background throught the output. Now with the image because i dont get it in the output(its not embedded with the drawing) i dont have something to show me the workarea that my user selected. Any ideas? – nicholaswmin Feb 12 '13 at 12:36