- This topic has 39 replies, 2 voices, and was last updated 5 years, 1 month ago by Yuri Kovelenov.
-
AuthorPosts
-
2019-09-11 at 3:46 pm #18599ManuelCustomer
Hi
I want to add a button to save the current view of a object to a jpg file
Is it possible?
Thanks
2019-09-12 at 7:27 am #18604Yuri KovelenovStaffHi,
You can use the take screenshot puzzle for that (also need to enable screenshots with configure app puzzle). It only generates the image though. To be able to download it, you can use the following JavaScript snippet
app.ExternalInterface.downloadScreenshot = function(image) { var link = document.createElement('a'); link.setAttribute('download', 'myImage.png'); link.setAttribute('href', image); link.click(); }
and call it from Puzzles as described here.
Attached an example project.
Attachments:
You must be logged in to view attached files.2019-09-12 at 7:35 am #18609Yuri KovelenovStaffUpdate:
make it
app.ExternalInterface.downloadScreenshot = function(image) { var link = document.createElement('a'); document.body.appendChild(link); link.setAttribute('download', 'myImage.png'); link.setAttribute('href', image); link.click(); }
to work on Firefox.
2019-09-12 at 9:31 am #18614ManuelCustomerThanks a lot
The only problem now, is that i get a black image :-S
Any idea that can be?
Thanks
2019-09-12 at 9:38 am #18615Yuri KovelenovStaffalso need to enable screenshots with configure app puzzle)
:)
2019-09-12 at 9:39 am #18616ManuelCustomerFixed!
Sorry, i hadn’t checked the option in initialization panel ^^
Thanks
2019-09-12 at 9:44 am #18618ManuelCustomerNow i see that, another question…
Is there any possibility to change the background automatically or make it transparent when you save the pic?
Thks again ^^
2019-09-12 at 9:46 am #18620Yuri KovelenovStaffTry the transparent background option in the same puzzle: https://www.soft8soft.com/docs/manual/en/puzzles/Initialization.html#configure_application
2019-09-12 at 10:12 am #18623ManuelCustomerTry the transparent background option in the same puzzle: https://www.soft8soft.com/docs/manual/en/puzzles/Initialization.html#configure_application
As i have a sphere background, i solve it like this (look attached file)
Is there any cleaner form to do it?
Because here, i depend of cpu speed, i suppose isn’t it?
2019-09-12 at 10:18 am #18625Yuri KovelenovStaff2019-09-12 at 10:30 am #18628ManuelCustomerYep, you can use 0 second time to make it lapse only 1 rendering frame.
I tested it, but i doesn’t work :-S
2019-09-12 at 10:56 am #18634Yuri KovelenovStaff2019-09-12 at 11:42 am #18636ManuelCustomerWhat does it produce? non-transparent background?
Correct!
It seems that with “0” value, there’s no time to grab the transparent backgroud.
2019-09-12 at 12:56 pm #18637Yuri KovelenovStaff2019-09-13 at 2:40 pm #18698ManuelCustomeryou can try another approach – using the every frame puzzle with a counter to wait for 1 or 2 rendering frames.
I don’t know how to use it, as i can’t puzzle it into my “click” function :-S
-
AuthorPosts
- You must be logged in to reply to this topic.