lemo's Recent Forum Activity

  • HURRAY

    NW.JS Write File > Browser.ExecJS("atob("""&tokenat(Sprite.ExtractImage.currentImage,1,",")&""")")

    This finally works, and saves a PNG file representation of the Sprite in the specified folder automatically

    I mentioned ExecJs + atob() a few posts above, and couldn't get the quotes right, then I dug out this post

    The link to the video tutorial that James linked is gone, I found it again

    Subscribe to Construct videos now

    thanks to the title

    For general screenshots on disk: Browser.ExecJS("atob(""" & tokenat(CanvasSnapshot, 1, ",") & """)")

    Now this method doesn't work (anymore?), and produces the same corrupted image I had in other tests

    I also had to edit the original NW.JS plugin, and exchange the Write File encoding from "utf8" to "binary"

    This now works, and here's the change below, with a UI mockup to hopefully have it for the official plugin

    Runtime.js

    	Acts.prototype.WriteFile = function (path_, contents_)
    	{
    		if (!isNWjs)
    			return;
    		
    		try {
    			fs["writeFileSync"](path_, contents_, {"encoding": "binary"});
    		}
    		catch (e)
    		{}
    	};[/code:1y0o2ik8]
    
    Suggestion
    [img="http://i.imgur.com/LiJ3EH3.png"]
    
    Also while I'm at it I added another suggested option to choose between Synchronous/Asynchronous
    Like rexrainbow [url=https://www.scirra.com/forum/request-nw-js-write-image-file_p1029199?#p1029199]mentioned[/url], it would be worth having to maybe improve performance in some cases
    Anyway, I think it's important to have a way to save live screenshots or batch of image on desktop apps
    
    @Ashley can you have a look at this suggestion for the nwjs plugin?
  • I dunno, that's sounds like a lot more complicated approach to me than storing each image directly

    Even if there's a lib, someone would still need to make a plugin to use it

    And I doubt adding an extra step for unzipping will help my loading times

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • newt

    The library is different for each user and each image has to be fetched one by one through an API

    (it's a movie app with film posters from IMDb)

  • Now, I'm trying to modify Pode original plugin to extract the sprite directly as a "blob" instead of a base64 string

    Luckily the HTMLCanvasElement.toBlob() is supported form Chrome 50+, which just made it into nw.js 14.0 ten days ago!

    Would that work to write that image "blob" with nw.js "write file" as a PNG on disk?

    But yeah I have no idea about javascript or how to write a plugin, so the modified plugin below doesn't work

    How do I return the "blob" out of that child function back into the "ret"?

    	// the example expression
    	exps.currentImage = function (ret)	// 'ret' must always be the first parameter - always return the expression's result through it!
    	{
    		this.canvasSprite.width = this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.width;
    		this.canvasSprite.height = this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.height;
    		this.ctxSprite.drawImage(this.inst.cur_animation.frames[this.inst.cur_frame].texture_img, 0, 0);
    		this.canvasSprite.toBlob(function(blob) {
    			ret.set_string(blob);
    		});
    	};[/code:2f17co95]
  • I found this nice plugin to decode base64 inside C2

    Combined with the other extract sprite to base 64 would that work?

    How about an ExecJS with atob()

    I seem to get some kind of "binary" data written, but it says the image is corrupted when I try to open it

    Can someone have a look at the NWautosave.capx, where I'm trying all that? with no success whatsoever

  • rexrainbow

    Well that sucks, yeah the player api docs don't seem to have that indeed

    Hey check out this other video, just playing around with the focus, before the video event load

    (same behavior when a video is playing anyway)

    -Click outside the player two separate times to loose focus

    -Subsequent clicks have no effects

    -Then a double-click OUTSIDE the player brings back focus to it

    Definitely something strange going on here o_O

    https://drive.google.com/file/d/0B6wXdu ... JwQ0E/view

  • rexrainbow

    Doh I'm starting to wonder if the quality of my written english is really that bad... let me try to explain again

    I am not trying to avoid the Youtube UI, on the contrary I do want it to show up on hover, so I'll really keep those to "Yes"

    Now, even when it's all setup as "Yes", the Youtube UI fails to show up on hover, after the "focus" is lost

    See the link below, I just made a video to show that more clearly

    https://drive.google.com/file/d/0B6wXdu ... VwNDg/view

    00:00 - 00:05: As you can see the player reacts on hover as the icon turns red

    00:12 - 00:22: The Youtube UI shows up fine after clicking PLAY, and when hovering the mouse

    I can scroll through the timeline thumbnail and change the volume on the go

    00:33 - 00:43: Focus is lost after another click and I can't see any controls while hovering

    I have to click the player, which pauses the video, then only I can control it

    00:43 - 00:59: The UI now shows up normally on hover

    And once again, in the case of my app, there's a few click before reaching the Play button,

    so the "focus" is already lost for the first play, making the control/pause situation a bit clumsy

  • Hey rexrainbow, thx for update, I know the video starts just fine, it's not my issue

    It's really about the "focus on hover" behavior, so that when you hover the video, the controls from the player show up

    Try to hover after pressing PLAY once, and try to hover again after pressing PLAY again

    And to see the youtube UI again, change the volume, or see the timeline thumbnails, you have to click (and pause!) the player

    I thought in the meantime it would be good to have no autoplay in my case, so the user grab the focus before without pausing it in middle

    Although another problem maybe with the bug fix? I was expecting to see the video thumbnail and a play arrow button

    But if I set a "load video" with "autoplay no", it indeed doesn't play yet, but shows the "loading dots" instead of a nice video thumbnail?

    The "autoplay no" does show a nice thumbnail though if you launch it with the VideoID already in the object properties

  • Thanks rexrainbow, hmm still no luck for me though

    Hey I did some tests with all the elements in my projects, and I finally found a way to replicate in a simple capx

    It just happens with the TOUCH, after I click another element... TWICE?

    Same exchanging with a MOUSE click anyway, but I don't really why it doesn't loose focus at first o_O

    Here is a capx: YouFocus.capx

    Don't ever click the youtube object but just hover it

    If you press PLAY once you can still have focus and have the controls reappear on hover

    Press PLAY again and focus is lost for good

    (In my app I don't even get focus the first time)

    Btw I'm also highlighting a bug in this capx, the autoplay is "no" on both the object and the "load" action, and yet plays

  • Nice work, I think the line and the block look nicer now

    Still not so sure about the moon, anyway here is some inspiration for you

    But yeah with not as much contrast as this illustration, otherwise you still won't be able to differentiate the foreground like Ryan said

  • Okay how about this example? Looks very binary to me

    http://stackoverflow.com/questions/7329 ... ng-node-js

    Maybe Ashley would be interested otherwise to add "Write Image File" in the official Nw.js plugin if it's possible?

    It could work with the base64 plugin we can use already, or any base64 input (like CanvasSnapshot)

    So basically Sprite > Load image from url > Extracct base64 > Write image file

  • Yeah I can confirm #1, I tried yesterday to load jpg versions of the same text files, and it was much faster

    Not to mention the filesizes, as one of the pic was only 100kb in jpg, and goes above 1mb in it's base64 equivalent :p

    I'm mostly concerned about loading times, as saving happens once, only each time there's a new entry

    While loading happens every time the app launches, for each of the entries

    But yeah to be able to load fast I need to save those in jpg first through the code

    And could be interesting to see the difference in saving times for synchronous events indeed

    Are you sure they're saving in base64 in the link I posted? <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    I can't fully understand the code, but what about the "binaryData", and correct "png" extension there?

    require("fs").writeFile("out.png", binaryData, "binary", function(err)[/code:104tt3eb]
    Ok maybe the first answer looks base64, but how about the second answer "full solution" on that page?
    I posted that link coz the docs only have a "utf8" encoding exemple, so it's hard to tell what's possible or not
    [url=https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback]https://nodejs.org/api/fs.html#fs_fs_wr ... s_callback[/url]
lemo's avatar

lemo

Member since 17 Dec, 2012

None one is following lemo yet!

Trophy Case

  • 12-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies