Weird Write

Turns out write works by appending the size into "px monospace", which allows you to use css properties. You can also use a slash, which allows you to have arbitrary units, including vw and vh. The viewport (the entire one, not just the stage) can be measured by writing something with size "100vh/1px monospace", where the size after the slash is the line spacing. Since snap only allows one line, it does nothing.

I think that these text features (but not measure viewport) should be implemented into the main block, or a JS based library. This css injection should be removed, despite being limited to mostly reasonable results.

Thank you, helpfull block !

only one comment, you should save the "pen down?" status before and restore it after

where's the code for the write block in the source? i want to look into this more but i can't find anything with "px monospace" or what function is actually called by the write block

EDIT: found it here Snap/objects.js at master · jmoenig/Snap · GitHub

"bold" and "underline" are not CSS elements.

the "browser is in full screen" block shouldn't be relied on, i've had screens with heights of 768, 1050, and 1024, and there are also many other common things such as 900, 864, 1152, 1536

when also considering phones and other portable displays it becomes impossible to detect anything. someone might even just have the browser the same height as a smaller resolution by accident.

"css elements" aren't a thing. the css font type does have bold. the underline is drawn with pen in the project.

but it never works for me when im using it for text in my website?

you're almost definitely doing something wrong, the projet here works fine and isn't your website, or a website at all. creating snap projects and creating websites don't have much in common.
i'd just suggest reading the mdn docs and your code more closely.

This is very cute. Good hack.

We're eventually going to get around to a good formatted text facility.

By the way, when I set the size to 12em, the text always seems to be to the right of center (i.e. positive x value). How come?

It starts in a random position, and then writes the text to the right of that. If you want to center the text, you need to know how wide it is, which I don't check. This block just adds a few features to the original.

But what I'm saying is that the position isn't random for 12em text; it's always x>0.

The position used is the bottom left corner of the text, and it is random. Sometimes is on the left.

Okay. Not important anyway.


Sorry for late post...

By the way, you can now set custom fonts like this:
untitled script pic (1)

Add the ", " after the font name.

To know, the CSS applied when doing this is...
24px cursive, px monospace

"px monospace" font :joy:

What font name is allowed?

It can be anything

browser font, windows font ?

can you give me some examples plz

Like this one:

write [Hello!] size (join [ 24px cursive, ] ◂▸ :: operators) :: pen

Anything that you can access in dev tools (inspect element). If you want, you can import a font-face which allows you to use any font.