Ejecta
Ejecta copied to clipboard
A example : Take a screenshot & Share the screenshot
All code in index.js of this example:
//=======================================
// Initialize the screen canvas
//=======================================
var width = window.innerWidth;
var height = window.innerHeight;
var canvas = document.getElementById('canvas');
canvas.width = width;
canvas.height = height;
canvas.retinaResolutionEnabled = true;
var context = canvas.getContext("2d");
context.fillStyle = "#000000";
context.fillRect(0, 0, width, height);
//=======================================
// Draw something on screen canvas
//=======================================
context.fillStyle = "#ff6600";
context.font = "60px Arial";
context.fillText("Test", 30, 100);
context.fillRect(0, height >> 1, width, 20);
context.fillRect(width >> 1, 0, 20, height);
//=======================================
// Take a screenshot.
//=======================================
var appUtils = new Ejecta.AppUtils();
// In fact, saveImage() is a synchronous method.
// You could also use a offscreen canvas that you created via document.createElement().
appUtils.saveImage(canvas, "${Documents}/test.png", function(filePath) {
console.log(filePath);
});
//=======================================
// Share the screenshot that you took.
//=======================================
var social = new Ejecta.Social();
// Why setTimeout :
// You can't open social dialog as soon as app starts
// You must wait a moment for initialization of SocialSDK
setTimeout(function() {
social.showPostDialog('twitter', 'test message', "http://google.com", '${Documents}/test.png');
}, 1200);
@matrixreal , I'v tried the best of my ability for helping you.
@matrixreal , there is a full example https://github.com/phoboslab/Ejecta/issues/540
and Could you Star my fork version of Ejecta ?
@matrixreal , you asked :
can i take screen shoot and save it on app folder ? not in the document? thanks i already stars your best fork :dancer:
Sorry , We can't do it . iOS does not allow us do that.
@matrixreal , you can use ${Documents}, ${Library}, ${Caches}, ${tmp} . I think that's enough.
social.showPostDialog seem not access to document folder the png file is there but when call the showpostdialog with that image not apear
@matrixreal , Could you test https://github.com/phoboslab/Ejecta/issues/540 ? I am very sure that social.showPostDialog could access Documents folder .
ok
just copy what your link and paste it to index.js
i got crash (ios7)
@matrixreal , thanks . I don't have iOS 7.
Now update my fork version , I changed some codes.
Please Test again, thanks
same error
@matrixreal , thanks .
Please Update and test again .
this could explain why showpostdialog can't access to documents ? no ? right ?
No. Crash because the queue was lost.
@matrixreal , Are there same errors ?
same error but i see that you change something just now so i will download again and test
can you pleas check again if showpostdialog can access to documents ?
I am very sure that social.showPostDialog could access Documents folder .
Now , I download iOS 7.1 SDK , and Test in simulator. That's OK. Please update and test again
still same here ios 7.1.2 iphone 4s
what's same? no image or crash ?
@finscn now it work perfectly , some times crash but good better than nothing.... wow after 2 days of searching i could never done it without you thanks a lot ... if you want promote your app just write me
@finscn
last question
when i use var context = canvas.getContext("2d"); (to make apputils saveimage work)
i got screencanvas created 6 times ? do you have an idea ?
"some times crash" in device or simulator ? or both ? Could you get the error message ?
"created 6 times " : I don't know , In my test case , there is no this problem .
crash in device .... i don't use simulator since there are a lot of restrictions etc ... so i prefer real device ok i will post the log error as soon as it crash
@finscn hahaaa now apputils is become good features than before
@finscn is there a way to share an image like in showpostdialog but in openshare?
~~No. the iOS API doesn't allow we do that.~~
@finscn are you sure ? i have an app in my phone that share the snapshoot using openshare dialog
@matrixreal , please update . now it could add image.
see
https://github.com/finscn/Ejecta/blob/master/App-Example/example/e-download-snapshot-share.js#L73
works perfectly thanks
hi,
i found that construct 2 (the tool i use to make html5 games) is using the line below to create canvas
var ctx = canvas.getContext("2d");
and the appUtils.saveImage call need the canvas initialize by var context = canvas.getContext("2d");
how can i modify it ? to use the ctx and not context ?
thanks