fredericlam Posted February 25, 2015 Share Posted February 25, 2015 Hi all I have got an issue on printing my canvas.My web application is a simple tool to build "drawings" with backgrounds and items.Each item can be turned (rotate) and scaled separately. When I try to print the canvas, it appears that some of the positions and properties of each items are not kept.My javascript code for printing is simple : // currengBg is the backgroundvar bmd = game.add.bitmapData(currentBg.width, currentBg.height);// frameSprite is my group of itemsbmd.drawGroup(frameSprite,0,0);var bmdCanvas = bmd.canvas;var bmdDataUrl = bmdCanvas.toDataURL();// function that open a news window for printingprintCanvas(bmdDataUrl);Here is the result (see attached file) :- on the left, you can see my canvas + background and sprites- on the right, result of drawGroup + toDataUrl() function (which is opened in a new window) Edit :I'm giving some details to understand the context. - rotate and scale are applied to items, relative to my html document- while drawGroup "translates" rotation and scale relative to the game world Am i understanding correctly the phaser drawGroup() function ? Please does anyone faced this problem ? Thanks Link to comment Share on other sites More sharing options...
utkiupe Posted February 27, 2015 Share Posted February 27, 2015 I have digged into phaser codehttp://docs.phaser.io/BitmapData.js.html#sunlight-1-line-957So it happens to the copy method in BitmapData, but I can't see anything special therethe scaling is done before de rotation, so I guess it should be copied correctlyThen everything is sent to the javascript drawImage function. I guess this is how the draw image handles rotation that cause the problem.Maybe there coule be a trick so that we sort of "freeze" the changes on the sprite before so that even the transformations on the sprite become the default scale and rotation... just an idea Link to comment Share on other sites More sharing options...
Recommended Posts