Discuss Scratch

EPICPIKAGUY
Scratcher
100+ posts

Scratch to Javascript converter

oleg-bronzhaiev wrote:

Excuse me guys,

but if Scratch 3.0 is powered by Javascript mostly. It doesn't necessarily mean it'll support blocks <-> JS convertion. I didn't find such feature officially claimed.

It probably doesn't. Just wishful thinking on our parts.
dtswg
Scratcher
31 posts

Scratch to Javascript converter

Sheep_maker wrote:

You can't convert a costume into Javascript, I believe.
In the scratch api, theres a url for EVERY SINGLE PICTURE. So, the converter can simply use the scratch api urls to get the costumes.

Hope that cleared that up for ya.

If a thing goes the speed of light, it's mass turns to infinity.

When a photon goes the speed of light, it's mass stays to nothing.

So… A photon is not a thing?
Don't worry, it is a particle (thing)
Botcho_Otkho
Scratcher
1000+ posts

Scratch to Javascript converter

dtswg wrote:

Sheep_maker wrote:

You can't convert a costume into Javascript, I believe.
In the scratch api, theres a url for EVERY SINGLE PICTURE. So, the converter can simply use the scratch api urls to get the costumes.

Hope that cleared that up for ya.
There's an URL for every single picture because they're drawn by the ST, not by the Scratchers in the editor, and so it will have to save EVERY SINGLE PIXEL of a costume, convert it into data and create an URL for it.

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
jokebookservice1
Scratcher
1000+ posts

Scratch to Javascript converter

Botcho_Otkho wrote:

dtswg wrote:

Sheep_maker wrote:

You can't convert a costume into Javascript, I believe.
In the scratch api, theres a url for EVERY SINGLE PICTURE. So, the converter can simply use the scratch api urls to get the costumes.

Hope that cleared that up for ya.
There's an URL for every single picture because they're drawn by the ST, not by the Scratchers in the editor, and so it will have to save EVERY SINGLE PIXEL of a costume, convert it into data and create an URL for it.
Not quite. Scratch has to save images, where else would they be stored? The URL is the hash digest of the image data, not every pixel. The image itself is stored in a database.

It would, of course, be possible, to generate a data URL – and that wouldn't be the end of the world either
WackyNerdz
Scratcher
77 posts

Scratch to Javascript converter

I AGREE
Just make a
convert [scratch blocks input here] to .js :: grey
block.

3.14159265358979…

I know 84 digits of pi
Botcho_Otkho
Scratcher
1000+ posts

Scratch to Javascript converter

WackyNerdz wrote:

I AGREE
Just make a
convert [scratch blocks input here] to .js :: grey
block.
The user's not suggesting a block, they're suggesting a feature.

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
Parker_Savage
Scratcher
10 posts

Scratch to Javascript converter

If you want to convert scratch files to app form, it's not all that hard. It's not always the highest quality, especially recently, as a new update filled it with bugs, but there is a program called phosphorus, a simple site made in github, but it's worth a try. It's a tiny bit complicated.Simply go to phosphorus.github.io and paste in the little code at the top of your screen (On scratch). For example, if you went to your project and looked at the URL, it would say something like https://scratch.mit.edu/projects/244487679/. type the numbers that you see (After projects) into phosphrus. after that, configure the settings you want and press the “Package” Button. Then after that it will take you to a page where you can play your game. Copy the link of that page. You will need it later. If you dont know how to obtain the link, simply find it in the address bar. After you copy the link, go to appsgeyser.com and click create app. Then click “website” and paste the link you copied earlier into the box. After that just follow the it gives you and you will be good to go! Please subscribe to me on youtube. My name is Parkee05. Thanks, and I hope I solved the problem!

Last edited by Parker_Savage (Sept. 6, 2018 22:08:10)

Parker_Savage
Scratcher
10 posts

Scratch to Javascript converter

EPICPIKAGUY wrote:

christophert9015 wrote:

Scratch is operated primarily with the costumes, backdrops, and sounds, which mainly come from the library. This may not seem like a big difference from regular code, ike js, but it is. In order for it to work, you have to have every single one of the files on the scratch cloud on the subject of any specific project you want to view downloaded to the computer you are using, otherwise, the project would only show pen elements, and not the kind in the editor, but the pen scripts.
(These Kinds:)
pen down
pen up
set pen color to [#74c086]
change pen color by (10)
set pen color to (1001)
And you can only show the proper images, if you download all of the project files, which could easily take up a terabyte of data on your computer, and that's why you can't convert scratch to js and back. Anyone trying to show you a converter that works, is a liar, or just has millions of terabytes of storage on their computer.

What do you mean “millions of terabytes of data”? A single scratch project should only take up a few megabytes of data.

If you’re trying to suggest that the entire costume library, you’re wrong. You don’t need every single image in the library, you only need the ones scratch uses. And even if you somehow needed the entire library, that’s not a big deal, because the library shouldn’t take up more than a couple hundred megabytes, max.

If you’re trying to suggest that you would need every single image that represents every combination of pen drawings because JS can’t support an equivalent pen blocks, you’re wrong. CanvasRenderingContext2D, which is natively supported in javascript, has methods for rendering images AND drawing lines on the screen.

If you’re trying to suggest that anyone claiming to have made a converter is a liar, you’re wrong. Phosphorus is a scratch-to-js converter that works on any project you give it. Note that, if converting really required “hundreds of terrabytes,” the webpage would crash due to insufficient space. But it doesn’t. Because you don’t need that much space.

Also, scratch 3.0 is being developed in javascript. It has the ability to load in .sb2 projects. It’s completely open source, so you can check out the code if you really believe they’re somehow pulling your leg.

I’m not trying to be mean, but I’m just saying: Scratch-to-js is possible, and has already been done. In fact, once scratch 3.0 comes out, javascript will be the norm.

It may seem crazy, but i know how to do it. I have already made apps on scratch. I promise you the will not be high quality, and any special fonts used may not work, but you can make apps with scratch. I have already made a post on how to do this, so check it out! (Its somewhere in this discussion) Also, I don't appreciate the term “Liar” as I have done it and it is possible.
goldfish33
Scratcher
2 posts

Scratch to Javascript converter

I would recommend using Phosphorus A Site which will convert your game into HTML. Copy the Embed code and paste into your text editor/code editor (then put it inside body tags, if you know HTML) then at the top of you txt editor (Line one) Write: <!DOCTYPE html>
under that, on line two write <body>. then under that (on line three) put in the embed code. The after that on the next line Write </body>. Then save it a a dot HTML file. (ScratchToJS.html). Open your file in CHROME (Ctrl+O), then select you file. You will see your scratch project. Then inspect the page (ctrl+shift+i or right click and select inspect). It will be pretty empty. then select the drop-down triangle and click on the link. If you cant click on the the link click three time and you go into edit mode. Copy the link and paste it into a new tab. Again go in to inspect and then copy all the code and put in a new dot html file. Save it and open in in a new tab. Your game should show up. If you want other people to see your game or publish your game on the web go to 000webhost which allows you to put your own html into a free subdomain. Share it with all your Friends.

Hope this helps
Daniel_Wilson
New to Scratch
26 posts

Scratch to Javascript converter

goldfish33 wrote:

I would recommend using Phosphorus A Site which will convert your game into HTML. Copy the Embed code and paste into your text editor/code editor (then put it inside body tags, if you know HTML) then at the top of you txt editor (Line one) Write: <!DOCTYPE html>
under that, on line two write <body>. then under that (on line three) put in the embed code. The after that on the next line Write </body>. Then save it a a dot HTML file. (ScratchToJS.html). Open your file in CHROME (Ctrl+O), then select you file. You will see your scratch project. Then inspect the page (ctrl+shift+i or right click and select inspect). It will be pretty empty. then select the drop-down triangle and click on the link. If you cant click on the the link click three time and you go into edit mode. Copy the link and paste it into a new tab. Again go in to inspect and then copy all the code and put in a new dot html file. Save it and open in in a new tab. Your game should show up. If you want other people to see your game or publish your game on the web go to 000webhost which allows you to put your own html into a free subdomain. Share it with all your Friends.

Hope this helps
looks like very helpful will try this and 000webhost is a lifetime giving free?

Sprak Design
SickBoi2000
New to Scratch
5 posts

Scratch to Javascript converter

Semi-Support.
You can make a .JS/pen scratch project at Griffpatch's Scratch Pen Emulator.
SickBoi2000
New to Scratch
5 posts

Scratch to Javascript converter

goldfish33 wrote:

I would recommend using Phosphorus A Site which will convert your game into HTML. Copy the Embed code and paste into your text editor/code editor (then put it inside body tags, if you know HTML) then at the top of you txt editor (Line one) Write: <!DOCTYPE html>
under that, on line two write <body>. then under that (on line three) put in the embed code. The after that on the next line Write </body>. Then save it a a dot HTML file. (ScratchToJS.html). Open your file in CHROME (Ctrl+O), then select you file. You will see your scratch project. Then inspect the page (ctrl+shift+i or right click and select inspect). It will be pretty empty. then select the drop-down triangle and click on the link. If you cant click on the the link click three time and you go into edit mode. Copy the link and paste it into a new tab. Again go in to inspect and then copy all the code and put in a new dot html file. Save it and open in in a new tab. Your game should show up. If you want other people to see your game or publish your game on the web go to 000webhost which allows you to put your own html into a free subdomain. Share it with all your Friends.

Hope this helps
She was looking for JS,not HTML
dude_my_dude
Scratcher
2 posts

Scratch to Javascript converter

phosphorus
https://phosphorus.github.io/
phosphorus runs your Scratch projects really fast by compiling them to JavaScript. Try it out by pasting a URL or project ID into the field below or choosing an …
Dah_Scratch_panda06
Scratcher
3 posts

Scratch to Javascript converter

Sigton wrote:

The problem is Scratch doesn't function the same way as any other languages, and is often extremely difficult to represent Scratch code as text. For example, what would a sprite be in javascript? The backdrop, costumes, sounds and so on and so forth.

Sigton



Scratch is written in javascript lol.
jokebookservice1
Scratcher
1000+ posts

Scratch to Javascript converter

Dah_Scratch_panda06 wrote:

Sigton wrote:

The problem is Scratch doesn't function the same way as any other languages, and is often extremely difficult to represent Scratch code as text. For example, what would a sprite be in javascript? The backdrop, costumes, sounds and so on and so forth.

Sigton



Scratch is written in javascript lol.
Scratch 2.0 (current as of writing) is written in ECMAScript, but not JavaScript, it's written in ActionScript.

While it's true Scratch 3.0 (in beta as of writing) is written in JavaScript, it has a bunch of boilerplate to deal with rendering of sprites, handling threads, layering, etc.

Compiling a Scratch project into JavaScript would not create educational code.

In fact, Scratch is Turing-complete. It can, therefore, be compiled into any other Turing complete language with similar I/O facilities. That doesn't mean it should.

Last edited by jokebookservice1 (Oct. 14, 2018 16:27:29)

FieryJoker236
Scratcher
1 post

Scratch to Javascript converter

kittycat841 wrote:

Oh, hello!
I'm here to discuss a new feature that should be added to Scratch: A Scratch to Javascript converter!
Now, you may be thinking, how would this be useful?
I'll tell you why.
There are other applications out there, and most of them use JavaScript. JavaScript can be hard to learn, so why not make a converter? Then, Scratchers can take their project and put it into another application. This would make things a lot easier for scratchers.

Well?
I'm not keeping track of Supporters this time, so PLEASE give reasons why it should or shouldn't be added into Scratch.
Thanks for reading this.
you can probably just use Sulfurous and export it (even though it comes out as html, its fairly easy to add html in applications too so)

Last edited by FieryJoker236 (Dec. 7, 2018 02:38:12)

Sheep_maker
Scratcher
1000+ posts

Scratch to Javascript converter

I don't think they should encourage users to write JavaScript by converting from Scratch; they should learn JavaScript directly. Converted Scratch code wouldn't be best practice in JavaScript.

For example, in order for a Scratch project to work in JavaScript, the _ = _ block would probably have to be translated to a helper function `equals(a, b)` in order to deal with case insensitivity and other quirks; however, normally you would use the === operator. Not useful for learning JavaScript.

- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
mattlamite
Scratcher
1 post

Scratch to Javascript converter

when backdrop switches to [ v][b][b][/b][/b]
LetsGetMyMotherProud
Scratcher
2 posts

Scratch to Javascript converter

when green flag clicked
say [good idea!] for (2) secs
play sound [cheers v]
stop [all v]
:D
alexmiao
Scratcher
5 posts

Scratch to Javascript converter

Wut about a Scratch to html5 WebGL thing?

Powered by DjangoBB