Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evy: Add canvas text builtins #124

Merged
merged 1 commit into from
Apr 24, 2023
Merged

evy: Add canvas text builtins #124

merged 1 commit into from
Apr 24, 2023

Conversation

juliaogris
Copy link
Member

Add canvas text builtins text, textsize, fontfamily, and font.
Add new example #text. These new primitives are only concerned with
text and text styles on the evy output canvas.

@juliaogris juliaogris requested a review from camh- April 23, 2023 10:19
@github-actions
Copy link

github-actions bot commented Apr 23, 2023

firebase-deployment: https://evy-lang--124-48m7ji2d.web.app (67bdff1)

text "all 🖖"

move 10 40
fontfamily "Luminari, fantasy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont have this font. Is this a mac thing? Perhaps you should stick to common web fonts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantasy is the fallback. I searched for "common web fantasy fonts" and this is what came up, e.g.: https://blog.hubspot.com/website/web-safe-html-css-fonts or https://www.w3.org/Style/Examples/007/fonts.en.html

What does it display for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see the font changing at all. Just the same as the previous line (although it's a bit hard to tell for sure because the previous line is just "all", which is not much to compare with).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's kinda sad.
This is what it looks like for me:
Screenshot 2023-04-24 at 1 02 22 PM


move 10 35
fill "grey"
font "italic max(2rem, 2vh) \"Comic Sans MS\", cursive"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍍 I dont understand this max(2rem, 2vh) thing - I know it's from the canvas or web or something, but i feel whatever it is is going against the simplicity you're going for with evy (I thought the same with the colour definitions too, but I know you felt differently - still feel I need to say it though).

I've always though of font sizes in points - that is the sizing that is pretty much universal when it comes to text. px, rem, vh, etc all seem to be webby things and I dont know what they mean. Should you be expecting leaning programmers to know?

Copy link
Member Author

@juliaogris juliaogris Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you have point.
For me all the recent additions are "advanced".

A lot of things can be done with move, line, rect, text, textsize.
However, if there is more nuance desired this is what you can use.
Maybe that's a mistake, maybe I will get rid of it again.
I have noticed however, that sometimes for Mali at least it is nice to consolidate knowledge without learning "hard" new things. So if she can draw circles it might be fun to challenge her with an ellipse, without requiring abstraction / higher order data structures or even the understanding of functions (breadth first vs depth first).

Maybe all of this is a mistake. Not sure. I think most text things can be done with text, textsize and fontfamily (I added this separately because of your suggestion even though it is a little hacky). However, if you want to do bold and/or cursive, font on canvas is the way.

Maybe I should add a comment on where to read up on it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's again: make easy things easy but hard stuff possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also to more properly answer: I believe there are layers of progression to evy - we have discussed this before. Start with simple drawing / printing to given an intuition on how code is executed sequentially. Add basic variables, while loops, reading input, if's. once that understanding is solid: functions, arrays. Lastly functions with parameters and return values, maps, recursion, list trees etc.

My feeling is, giving enough drawing primitives to write games is desirable, e.g.: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes#making_combinations

Imo that includes curves and flexible fonts but I reserve the rights to change my mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last max(2rem, 2vh) is a CSS thing. it is literally the maximum of 2rem and 2vh (2root element size; by default a rem is 16px in most browser vs. 2viewport height - viewport height is the browser window height).
This are things to be read up on at

Add canvas text builtins `text`, `textsize`, `fontfamily`, and `font`.
Add new example #text. These new primitives are only concerned with
text and text styles on the evy output canvas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants