-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Text to model docs #7595
base: dev-2.0
Are you sure you want to change the base?
Text to model docs #7595
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @perminder-17 thanks, it looks good, I just added a small comment about notation and a need for a small clarification, let me know your thoughts.
CC: @davepagurek @limzykenneth
* 'vec4 getFinalColor': `(vec4 _c) { | ||
* float x = vPos.x * 0.005; | ||
* float a = floor(fract(x) * numColors); | ||
* float b = a == numColors - 1. ? 0. : a + 1.; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this was adressed before, but having the notation -1.
might not be clear for all users, thinking that why not use just -1
or -1.0
I understand that we might need to explicitly cast it like this to indicate its a float to WEBGL but it might I think it would be useful to add a note as to why we choose to notate it like this. A brief comment would be good enough I believe
src/type/p5.Font.js
Outdated
* | ||
* let prevWords = ''; | ||
* let prevFont = ''; | ||
* let prevExtrude = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example, why in the other cases we need an explicit float and not here? It might be confusing for some users.
src/type/p5.Font.js
Outdated
* let prevExtrude = -1; | ||
* | ||
* function draw() { | ||
* if (words !== prevWords || prevFont !== font || prevExtrude !== extrude) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a leftover from when the input and font were editable? We can probably remove this if statement and the prev*
variables, and just create the geometry in setup
.
src/type/p5.Font.js
Outdated
* createCanvas(200, 200, WEBGL); | ||
* fonts = { | ||
* Anton: await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'), | ||
* Montserrat: await loadFont('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Ew-Y3tcoqK5.ttf'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can change this from being an object to just a single font variable since the example doesn't let people switch fonts interactively as the sketch runs. Maybe we can list the other URLs just in comments if users want to try different ones and rerun?
src/type/p5.Font.js
Outdated
* async function setup() { | ||
* createCanvas(200, 200, WEBGL); | ||
* fonts = { | ||
* Anton: await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here about the fonts object
src/type/p5.Font.js
Outdated
* } | ||
* | ||
* function draw() { | ||
* if (geom) freeGeometry(geom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this will free and remake the geometry every frame. We can take this out for the example and reuse the initial geometry
src/type/p5.Font.js
Outdated
* function draw() { | ||
* if (geom) freeGeometry(geom); | ||
* | ||
* geom = fonts[font].textToModel(words, 0, 50, { sampleFactor: 2, extrude }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block can be moved to setup() since we won't need to remake the geometry while the example is running
No description provided.