Discuss Scratch

liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

DrKat123 wrote:

What if i used the javascript block and the http://() to display pages?
(That would work like a browser, cool )
That would be an excellent project! Except you probably can't do it in a Morphic window if you're talking about running other people's JS code; you'd have to start by opening another window to run DOM code in.
epic leet browser:

open(prompt())

202e-202e-202e-202e-202e UNI-CODE~~~~~
djdolphin
Scratcher
1000+ posts

Snap! user discussion

My web browser sort of works. Now I need to fix images and some randomly broken sites and figure out how to make it interactive. I'm not going to add JS support though.

Last edited by djdolphin (Dec. 30, 2015 04:39:53)


!
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

djdolphin wrote:

My web browser sort of works. Now I need to fix images and some randomly broken sites and figure out how to make it interactive. I'm not going to add JS support though.
Wow. I never new you could add costumes and backgrounds.
Is there an API reference?

Not yet a Knight of the Mu Calculus.
djdolphin
Scratcher
1000+ posts

Snap! user discussion

Jonathan50 wrote:

djdolphin wrote:

My web browser sort of works. Now I need to fix images and some randomly broken sites and figure out how to make it interactive. I'm not going to add JS support though.
Wow. I never new you could add costumes and backgrounds.
Is there an API reference?
Not really. My projects uses a mess of JavaScript function blocks to grab a webpage, grab all the CSS and put it in the in body tag, embed the body tag in an SVG, convert the SVG to a data URI, load an image from the data URI, draw the image in a canvas, and create a costume from the canvas.

!
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

djdolphin wrote:

Jonathan50 wrote:

djdolphin wrote:

My web browser sort of works. Now I need to fix images and some randomly broken sites and figure out how to make it interactive. I'm not going to add JS support though.
Wow. I never new you could add costumes and backgrounds.
Is there an API reference?
Not really. My projects uses a mess of JavaScript function blocks to grab a webpage, grab all the CSS and put it in the in body tag, embed the body tag in an SVG, convert the SVG to a data URI, load an image from the data URI, draw the image in a canvas, and create a costume from the canvas.
I meant I never knew (not new) you could add ocstumes and backgrounds using JavaScript. (I saw how it was done.)

Not yet a Knight of the Mu Calculus.
bharvey
Scratcher
1000+ posts

Snap! user discussion

djdolphin wrote:

My projects uses a mess of JavaScript function blocks to grab a webpage, grab all the CSS and put it in the in body tag, embed the body tag in an SVG, convert the SVG to a data URI, load an image from the data URI, draw the image in a canvas, and create a costume from the canvas.
Scary.

comp09
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

djdolphin wrote:

My projects uses a mess of JavaScript function blocks to grab a webpage, grab all the CSS and put it in the in body tag, embed the body tag in an SVG, convert the SVG to a data URI, load an image from the data URI, draw the image in a canvas, and create a costume from the canvas.
Scary.
Why not https://html2canvas.hertzen.com/


Visit the website of Andrew Sun!


djdolphin
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

Scary.
Surprisingly it didn't take too long to code. Mostly because it's terribly hacky.

comp09 wrote:

Why not https://html2canvas.hertzen.com/
Because this tutorial from MDN was the first one I found.

Last edited by djdolphin (Dec. 30, 2015 15:58:36)


!
dynamicmetaflow
New to Scratch
2 posts

Snap! user discussion

Greetings Snap! Community!,

Thank you for Snap! and thanks to all of the contributes.

I intend to use Snap! to teach fundamental concepts related to programming. I am also trying to transition into incorporating teaching Javascript and Ruby. I know there is a codification example project in Snap!

Could someone provide some clarification of how I could convert a Snap! project and show how the code would look like in Ruby and Javascript?

Thanks in advance!
bharvey
Scratcher
1000+ posts

Snap! user discussion

dynamicmetaflow wrote:

Could someone provide some clarification of how I could convert a Snap! project and show how the code would look like in Ruby and Javascript?
Welcome!

If you look inside the Codification project (File>Open>Examples>Codification), you'll see a few very long procedure definitions like this one:

As you can see, you have to provide translations for each language element. So you'll have to do the same for Ruby. (You'll also see that some translations are pretty kludgy, like the one for SAY into C.) For custom blocks, you have to provide translations both for the definition and for the invocation(s).

Dragonboy105
Scratcher
53 posts

Snap! user discussion

How do you make lists in the blocks?
define my question
ask [How do you make lists work?] and wait 1 week // category=sensing

Last edited by Dragonboy105 (Jan. 3, 2016 11:56:11)


I exist. :: hat
I am [very v] sure I exist :: operators
To [prove v] that I exist, I have written [this.] :: motion cap
dynamicmetaflow
New to Scratch
2 posts

Snap! user discussion

bharvey wrote:

dynamicmetaflow wrote:

Could someone provide some clarification of how I could convert a Snap! project and show how the code would look like in Ruby and Javascript?
Welcome!

If you look inside the Codification project, As you can see, you have to provide translations for each language element. So you'll have to do the same for Ruby. (You'll also see that some translations are pretty kludgy, like the one for SAY into C.) For custom blocks, you have to provide translations both for the definition and for the invocation(s).

Thank you for the explanation, I'll attempt to do it myself and also ask some people I know to help out with this. I will make this publicly available and announce it on this thread.
xly
Scratcher
100+ posts

Snap! user discussion

Dragonboy105 wrote:

How do you make lists in the blocks?
define my question
ask [How do you make lists work?] and wait 1 week // category=sensing

One possible solution is to define your list as a long formatted string “www”,“yyyy”,“zzzz” SET to a SCRIPT VARIABLE in your block-list
Then Snap! has all the necessary tools to process this string and report it as a “true” LIST.
This block-list can be saved, exported and re-imported like a block.
I suggest to load the reimported list into a local list to avoid the long decoding process each time you need to explore it.
bharvey
Scratcher
1000+ posts

Snap! user discussion

Dragonboy105 wrote:

How do you make lists in the blocks?
I'm not sure I understand the question. You make a list with the LIST reporter, which takes any number of inputs and makes a list of those values. That list is itself a value, so you can assign it to a variable, or put it in a list, or whatever you want.

ChocolatePi
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

Dragonboy105 wrote:

How do you make lists in the blocks?
I'm not sure I understand the question. You make a list with the LIST reporter, which takes any number of inputs and makes a list of those values. That list is itself a value, so you can assign it to a variable, or put it in a list, or whatever you want.
You can make lists of blocks as well
liam48D
Scratcher
1000+ posts

Snap! user discussion

ChocolatePi wrote:

bharvey wrote:

Dragonboy105 wrote:

How do you make lists in the blocks?
I'm not sure I understand the question. You make a list with the LIST reporter, which takes any number of inputs and makes a list of those values. That list is itself a value, so you can assign it to a variable, or put it in a list, or whatever you want.
You can make lists of blocks as well
Keep in mind this..
(list [1] [2] ((3) + (4)) :: list)
..will actually result in [1, 2, 7]. If you want to store the block..
(list [1] [2] (((3) + (4)) :: grey ring) :: list)
you'd have to do that.

(blob, since you're totally reading this, the target for ring inputs is something along the lines of .ring .input when it should be .ring > .input, which is probably why we have a weird shaped 3+4 block above!)

Last edited by liam48D (Jan. 3, 2016 17:42:49)


202e-202e-202e-202e-202e UNI-CODE~~~~~
bharvey
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

..will actually result in . If you want to store the block..
… result in [1, 2, 7]. I get caught by that all the time.
(list [1] [2] (((3) + (4)) :: grey ring) :: list)
Wow, we snuck grey rings into scratchblocks? Awesome! Do we have variadic arrowheads too?

liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

liam48D wrote:

..will actually result in . If you want to store the block..
… result in [1, 2, 7]. I get caught by that all the time.
(list [1] [2] (((3) + (4)) :: grey ring) :: list)
Wow, we snuck grey rings into scratchblocks? Awesome! Do we have variadic arrowheads too?
Ahaha. Happened to me again. Oops!

Not that I know of. Probably use a special unicode symbol for that.

202e-202e-202e-202e-202e UNI-CODE~~~~~
blob8108
Scratcher
1000+ posts

Snap! user discussion

liam48D wrote:

blob, since you're totally reading this
How did you know?!

If there's a bug in scratchblocks, send me a pull request. Thanks!

bharvey wrote:

Wow, we snuck grey rings into scratchblocks? Awesome! Do we have variadic arrowheads too?
Yes Brian, I told you this!

Scimonster documented it on the wiki:
run ({create clone :: control} ▶ :: grey ring) :: control

<() ▶ :: grey ring>

say (http:// [snap.berkeley.edu] :: sensing)

((6) × (7) :: operators)

(join [hello ] [world] ◀ ▶ :: operators)

script variables ((foo) :: grey) ((bar) :: grey) ◀ ▶ :: grey

(all but first of (list) :: list)

warp :: grey cstart
move (10) steps
end

report [Done!] :: control cap

tosh · slowly becoming a grown-up adult and very confused about it
bharvey
Scratcher
1000+ posts

Snap! user discussion

blob8108 wrote:

(join [hello ] [world] ◀ ▶ :: operators)
That's terrific! I must be getting forgetful in my old age.

But why is the left arrowhead smaller than the right one? Or is that only in my browser?

Powered by DjangoBB