Paint game - Can I really do it with the C2?

Discussion and feedback on Construct 2

Post » Thu Dec 01, 2016 4:53 pm

RBuster wrote:Is it possible to save 20 snapshots on disk, load them after into a tilemap and so get a snapshot from this and print or save as image?


You could use the Canvas or Paster plugins to composite all of the snapshots and then save the results to a single file.
B
84
S
46
G
25
Posts: 530
Reputation: 21,570

Post » Thu Dec 01, 2016 4:59 pm

RBuster wrote:Is it possible to save 20 snapshots on disk, load them after into a tilemap and so get a snapshot from this and print or save as image?



its possible if you dont want to use paster plugin or other complicated thing, you just create a global sprite, and create a instance of it everytime a drawing is made, save the snapshot url to a frame inside the sprite, then when the user wants to print it, use an positioning in screen for x and for y loopindex array kind of thing, then canvassnapshot again, and invoke the browser.execute javascript call .print to print the newly canvassnapshoturl its going to take a while for you to implement it but its the easiest way of doing it and without non-default plugins.

when you call the print in javascript you use the same javascript you call the print from a html5 website ("javascript:window.print('canvassnapshoturl') ") just you need to change the scripts brackets to single ones ex: "myjavascript code { something 'blob code ,etc' } "
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005

Post » Thu Dec 01, 2016 5:26 pm

digitalsoapbox wrote:
RBuster wrote:Is it possible to save 20 snapshots on disk, load them after into a tilemap and so get a snapshot from this and print or save as image?


You could use the Canvas or Paster plugins to composite all of the snapshots and then save the results to a single file.


It seems promising. Can I find any example about of how to composite images with Canvas or even Paster (though I have never used this plugin)? Do you have one?
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Thu Dec 01, 2016 5:37 pm

gamecorpstudio wrote:
RBuster wrote:Is it possible to save 20 snapshots on disk, load them after into a tilemap and so get a snapshot from this and print or save as image?



its possible if you dont want to use paster plugin or other complicated thing, you just create a global sprite, and create a instance of it everytime a drawing is made, save the snapshot url to a frame inside the sprite, then when the user wants to print it, use an positioning in screen for x and for y loopindex array kind of thing, then canvassnapshot again, and invoke the browser.execute javascript call .print to print the newly canvassnapshoturl its going to take a while for you to implement it but its the easiest way of doing it and without non-default plugins.

when you call the print in javascript you use the same javascript you call the print from a html5 website ("javascript:window.print('canvassnapshoturl') ") just you need to change the scripts brackets to single ones ex: "myjavascript code { something 'blob code ,etc' } "


Could you make a simple example of this?
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Thu Dec 01, 2016 5:42 pm

You can load url's for sprites, tilemaps and tiledbackgrounds, for example.

Image

The canvas plugin is very similar to tilemaps, but works with any uploaded image without the need of these additional steps.
Canvas Plugin: viewtopic.php?t=64239&start=0

-----

You don't need to worry about arrays for this simple task, because a simple math is enough.

The size of each image will be previous know? Do you know how much images you want place on the canvas?

Imagine the canvas divided by slots and give each slot an ID, you'll know each position by its ID and you will be able to place them on the right position. Store the id and position with instance variables.

If you hate math, you can use an invisible tilemap on the background with previous size determined (but you'll be able to change it at runtime if necessary), so, use the tiletopositionX(tileID) and tiletopositionY(tileID) to place you image on the desired tile.
Last edited by TELLES0808 on Fri Dec 02, 2016 10:46 am, edited 1 time in total.
Image
B
108
S
24
G
18
Posts: 1,373
Reputation: 22,824

Post » Thu Dec 01, 2016 6:51 pm

RBuster wrote:
digitalsoapbox wrote:
RBuster wrote:Is it possible to save 20 snapshots on disk, load them after into a tilemap and so get a snapshot from this and print or save as image?


You could use the Canvas or Paster plugins to composite all of the snapshots and then save the results to a single file.


It seems promising. Can I find any example about of how to composite images with Canvas or even Paster (though I have never used this plugin)? Do you have one?


You just need to move each image to a different x/y position and paste into the Canvas/Paster object. They need to be on-screen and visible to paste, so you could write a function to put all required images side by side, then create a Canvas/Paster object and set the size/resolution large enough to cover all of the images, set the viewport to the same size, paste, then save the file.
B
84
S
46
G
25
Posts: 530
Reputation: 21,570

Post » Thu Dec 01, 2016 7:18 pm

digitalsoapbox wrote:You just need to move each image to a different x/y position and paste into the Canvas/Paster object. They need to be on-screen and visible to paste, so you could write a function to put all required images side by side, then create a Canvas/Paster object and set the size/resolution large enough to cover all of the images, set the viewport to the same size, paste, then save the file.


When you say "move each image" you mean: move each sprite with the image loaded? I can use Canvas "or" Paster, right? This function uses array? I don't know how to use array to manager positions. Wiil I need to use a new layout to prepare this huge composition? My current layout has only 640x480. This is very hard for me.
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Fri Dec 02, 2016 10:32 am

So, I am doing this:

Layout 1 (with drawing):
On Left button clicked > Take snapshot of canvas
On canvas snapshot > LocalStorage set item snapshot1 to CanvasSnapshot
On item "snapshot1" set > Go to Layout2

Layout2 (with another drawing):
On Left button clicked > Take snapshot of canvas
On canvas snapshot > LocalStorage set item snapshot2 to CanvasSnapshot
On item "snapshot2" set > Go to Layout3

Layout 3 (with sprites used to load the snapshots):
On start of layout > LocalStorage | Check item "snapshot1" exists
On start of layout > LocalStorage | Check item "snapshot2" exists
On item "snapshot1" exists > sprite1 | Load image from LocalStorage.ItemValue
On item "snapshot2" exists > sprite2 | Load image from LocalStorage.ItemValue



I don't know if this is the best solution but it works for me. I hope it helps some one.
B
74
S
13
G
4
Posts: 1,006
Reputation: 8,060

Post » Fri Dec 02, 2016 6:04 pm

RBuster wrote:So, I am doing this:

Layout 1 (with drawing):
On Left button clicked > Take snapshot of canvas
On canvas snapshot > LocalStorage set item snapshot1 to CanvasSnapshot
On item "snapshot1" set > Go to Layout2

Layout2 (with another drawing):
On Left button clicked > Take snapshot of canvas
On canvas snapshot > LocalStorage set item snapshot2 to CanvasSnapshot
On item "snapshot2" set > Go to Layout3

Layout 3 (with sprites used to load the snapshots):
On start of layout > LocalStorage | Check item "snapshot1" exists
On start of layout > LocalStorage | Check item "snapshot2" exists
On item "snapshot1" exists > sprite1 | Load image from LocalStorage.ItemValue
On item "snapshot2" exists > sprite2 | Load image from LocalStorage.ItemValue



I don't know if this is the best solution but it works for me. I hope it helps some one.



but if you can save the snapshot url in localstorage then you dont need to switch the layout, unless the canvasurl is direct influenced by the layout name or order... so by changing the layout you also change the canvasbloblurl... cause i tried to place my theory in a template and the url wold be the same at a point where i was thinking is a bug. but its not its just making sense being the same layout wold have same url and data no matter how many shots u have... its not like is automatically saved in localstorage.

im glad you fixed it il take a look at it.
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: radhaw and 11 guests