How can I join a PHP variable for a Drag and Drop Canvas from Konva?

1

I'm doing a site where when I click on a radio button, its value (an id of a sql variable) will open next to a canvas, which will create an image. My idea is to use Drag and Drop Canvas from Konva:

<script>
    var width = window.innerWidth;
    var height = window.innerHeight;

    function drawImage(imageObj) {
        var stage = new Konva.Stage({
            container: 'container',
            width: width,
            height: height
        });

        var layer = new Konva.Layer();
        // darth vader
        var darthVaderImg = new Konva.Image({
            image: imageObj,
            x: stage.getWidth() / 2 - 200 / 2,
            y: stage.getHeight() / 2 - 137 / 2,
            width: 200,
            height: 137,
            draggable: true
        });

        // add cursor styling
        darthVaderImg.on('mouseover', function() {
            document.body.style.cursor = 'pointer';
        });
        darthVaderImg.on('mouseout', function() {
            document.body.style.cursor = 'default';
        });

        layer.add(darthVaderImg);
        stage.add(layer);
    }
    var imageObj = new Image();
    imageObj.onload = function() {
        drawImage(this);
    };
    imageObj.src = 'http://konvajs.github.io/assets/darth-vader.jpg';
</script>

I thought about using Ajax, but I do not know how it will work. What would be the best way?

    
asked by anonymous 18.05.2016 / 02:54

0 answers