Discuss Scratch

Jonathan50
Scratcher
1000+ posts

Snap! user discussion

Yay I made a text engine



The canvas thing is inspired by @djdolphin's web browser

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

Snap! user discussion

Jonathan50 wrote:

Yay I made a text engine
-snip-

The canvas thing is inspired by @djdolphin's web browser
What about the label block in the tools library?

Cool though. Nice using a canvas

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

Snap! user discussion

liam48D wrote:

Jonathan50 wrote:

Yay I made a text engine
-snip-

The canvas thing is inspired by @djdolphin's web browser
What about the label block in the tools library?

Cool though. Nice using a canvas
Oh I didn't even now about that
var stage = this.parentThatIsA(StageMorph),
    context = stage.penTrails().getContext('2d'),
    rotation = radians(this.direction() - 90),
    trans = new Point(
      this.center().x - stage.left(),
      this.center().y - stage.top()
    ),
    isWarped = this.Warped,
    len,
    pos;
if (isWarped) {endWarp(); }
context.save();
context.font = size + 'px monospace';
context.textAlign = 'left';
context.textBaseline = 'alphabetic';
context.fillStyle = this.color.toString();
len = context.measureText(text).width;
trans = trans.multiplyBy(1 / stage.scale);
context.translate(trans.x, trans.y);
context.rotate(rotation);
context.fillText(text, 0, 0);
context.translate(-trans.x, -trans.y);
context.restore();
pos = new Point(
  len * Math.sin(radians(this.direction())),
  len * Math.cos(radians(this.direction())));
pos = pos.add(new Point(this.xPosition(), this.yPosition()));
this.gotoXY(pos.x, pos.y, false);
this.changed();
if (isWarped) {this.startWarp(); }
stage.changed();
Ok so the pen trails is a canvas!
(djdolphin's browser should use that)

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

Snap! user discussion

Jonathan50 wrote:

a URL like blob:http://snap.berkeley.edu/db223ceb-86cc-44f2-9299-d2312b986345
occasionally I regret my username

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

Snap! user discussion

Jonathan50 wrote:

Yay I made a text engine
Cool!

On my list for Snap! is a kind of sprite called a text box (or maybe it should be a kind of costume, but sprites are easy to send messages to) that are editable both directly onstage by the user and programmatically, and can be read programmatically too. It could be pretty featureful, e.g., plain text mode vs. rich text mode, Emacs keyboard bindings, stuff like that.

Probably this should wait until the generalized object system in 4.1.

PS Carriage return is 13, not 10.

djdolphin
Scratcher
1000+ posts

Snap! user discussion

Jonathan50 wrote:

Ok so the pen trails is a canvas!
(djdolphin's browser should use that)
Nah, I like my way. It lets the browser's rendering engine do most of the work, and it will be easier to add a back button if I feel like it.

!
liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

Probably this should wait until the generalized object system in 4.1.
Speaking of which…

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

Snap! user discussion

bharvey wrote:

Emacs keyboard bindings
Vi master race
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

djdolphin wrote:

Jonathan50 wrote:

Ok so the pen trails is a canvas!
(djdolphin's browser should use that)
Nah, I like my way. It lets the browser's rendering engine do most of the work, and it will be easier to add a back button if I feel like it.
No I meant it should add the SVG directly to the pen canvas instead of making a costume

bharvey wrote:

PS Carriage return is 13, not 10.
Oops! That's what I meant.

ChocolatePi wrote:

bharvey wrote:

Emacs keyboard bindings
Vi master race
Lol I'm making a vi/ex clone in Snap!.
That's why I made the text engine (but anyone can use it if they like)

Can you call a Snap! lambda from a JS function? I need this because I'm using JS to detect if colon is being pressed.

Last edited by Jonathan50 (Jan. 19, 2016 22:53:39)


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

Snap! user discussion

Jonathan50 wrote:

Can you call a Snap! lambda from a JS function? I need this because I'm using JS to detect if colon is being pressed.
Yes, kind of. In threads.js is a function invoke() that does it. But, quoting from that file:
    // This is highly experimental.
// Caution: Kids, do not try this at home!
// Use ThreadManager::startProcess with a callback instead
EDIT: The problem with invoke() is that it effectively turns off the rest of Snap!, including display updating and sensing user input, while calling the procedure. So you get in trouble if the procedure runs for a long time.

Last edited by bharvey (Jan. 19, 2016 23:59:50)


liam48D
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

Jonathan50 wrote:

Can you call a Snap! lambda from a JS function? I need this because I'm using JS to detect if colon is being pressed.
Yes, kind of. In threads.js is a function invoke() that does it. But, quoting from that file:
    // This is highly experimental.
// Caution: Kids, do not try this at home!
// Use ThreadManager::startProcess with a callback instead
EDIT: The problem with invoke() is that it effectively turns off the rest of Snap!, including display updating and sensing user input, while calling the procedure. So you get in trouble if the procedure runs for a long time.
I always use wait-until hacks if I want to call a lambda from a JS function. Eventually I'll make a proper function to run a block with a callback

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

Snap! user discussion

bharvey wrote:

Jonathan50 wrote:

Can you call a Snap! lambda from a JS function? I need this because I'm using JS to detect if colon is being pressed.
Yes, kind of. In threads.js is a function invoke() that does it. But, quoting from that file:
    // This is highly experimental.
// Caution: Kids, do not try this at home!
// Use ThreadManager::startProcess with a callback instead
EDIT: The problem with invoke() is that it effectively turns off the rest of Snap!, including display updating and sensing user input, while calling the procedure. So you get in trouble if the procedure runs for a long time.
Thanks!
So do I make a new ThreadManager instance and call startProcess or is there an existing instance I need to use?

Not yet a Knight of the Mu Calculus.
cycomachead
Scratcher
100+ posts

Snap! user discussion

Jonathan50 wrote:

bharvey wrote:

Jonathan50 wrote:

Thanks but I don't seem to be able to save it in Firefox
Could you be more specific about the problem? (I can't run Snap! in my Firefox at all, for reasons I don't understand, even in safe mode. )
If I click on script pic a tab opens with a URL like blob:http://snap.berkeley.edu/db223ceb-86cc-44f2-9299-d2312b986345.
If I right click and click “Save Image As…” then nothing happens.


Hmm, this is weird. That is supposed to work. I'm pretty sure this is a firefox bug because the menu item is labeled like it _should_ work (i.e. It's not grey), and when testing this I definitely used to be able to use it…

For now, it's a bit annoying but you can use the File menu and select “Save Page As” (or Cmd-S / Ctrl-S), which will do the same thing as Save Image As.
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

cycomachead wrote:

Jonathan50 wrote:

bharvey wrote:

Jonathan50 wrote:

Thanks but I don't seem to be able to save it in Firefox
Could you be more specific about the problem? (I can't run Snap! in my Firefox at all, for reasons I don't understand, even in safe mode. )
If I click on script pic a tab opens with a URL like blob:http://snap.berkeley.edu/db223ceb-86cc-44f2-9299-d2312b986345.
If I right click and click “Save Image As…” then nothing happens.


Hmm, this is weird. That is supposed to work. I'm pretty sure this is a firefox bug because the menu item is labeled like it _should_ work (i.e. It's not grey), and when testing this I definitely used to be able to use it…

For now, it's a bit annoying but you can use the File menu and select “Save Page As” (or Cmd-S / Ctrl-S), which will do the same thing as Save Image As.
Well, the blob:http://snap.berkeley.edu/db223ceb-86cc-44f2-9299-d2312b986345 URL doesn't have the image and is only temporary, so if you copy it and try to open it an a new tab it won't work…

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

Snap! user discussion

Jonathan50 wrote:

djdolphin wrote:

Jonathan50 wrote:

Ok so the pen trails is a canvas!
(djdolphin's browser should use that)
Nah, I like my way. It lets the browser's rendering engine do most of the work, and it will be easier to add a back button if I feel like it.
No I meant it should add the SVG directly to the pen canvas instead of making a costume
But having it make costumes is what makes it easier to add a back button. You can just change the costume.

!
bharvey
Scratcher
1000+ posts

Snap! user discussion

Jonathan50 wrote:

So do I make a new ThreadManager instance and call startProcess or is there an existing instance I need to use?
Look at the JS-native map implementation inside Snap!. (It's one of the dev-mode-only blocks.)

cycomachead
Scratcher
100+ posts

Snap! user discussion

Jonathan50 wrote:

cycomachead wrote:

Jonathan50 wrote:

bharvey wrote:

Jonathan50 wrote:

Thanks but I don't seem to be able to save it in Firefox
Could you be more specific about the problem? (I can't run Snap! in my Firefox at all, for reasons I don't understand, even in safe mode. )
If I click on script pic a tab opens with a URL like blob:http://snap.berkeley.edu/db223ceb-86cc-44f2-9299-d2312b986345.
If I right click and click “Save Image As…” then nothing happens.


Hmm, this is weird. That is supposed to work. I'm pretty sure this is a firefox bug because the menu item is labeled like it _should_ work (i.e. It's not grey), and when testing this I definitely used to be able to use it…

For now, it's a bit annoying but you can use the File menu and select “Save Page As” (or Cmd-S / Ctrl-S), which will do the same thing as Save Image As.
Well, the blob:http://snap.berkeley.edu/db223ceb-86cc-44f2-9299-d2312b986345 URL doesn't have the image and is only temporary, so if you copy it and try to open it an a new tab it won't work…

Oh yeah, I understand that part, but the “Save Image As” button is supposed to work in Firefox still… I'm fairly certain it worked 1-2 months ago… However, the “Save Page As” command in the file menu does still work. The context menu button in FF just seems broken, so I don't know if there's anything we can do. (Well, we could disable blob URLs, but then we can't export images at large enough sizes, or we risk crashing browsers, which is pretty terrible.)
cycomachead
Scratcher
100+ posts

Snap! user discussion

For calling Snap<em>!</em> blocks from a JS function, look at this project:
http://snap.berkeley.edu/snapsource/snap.html#present:Username=cycomachead&ProjectName=Async%20JS%20Call
BookOwl
Scratcher
1000+ posts

Snap! user discussion

Is there anyway for me to change my Snap! password?

Last edited by BookOwl (Jan. 21, 2016 19:42:04)


who needs signatures
bharvey
Scratcher
1000+ posts

Snap! user discussion

BookOwl wrote:

Is there anyway for me to change my Snap! password?
Yes. In Snap!, click on the cloud icon in the toolbar at the top of the window. If you're logged in, one of the options will be “change password.” If you're not logged in, because you forgot your password, one of the options will be “reset password,” which will send a new password to the email address you gave when you signed up.

Powered by DjangoBB