Jump to content

How to write wrapped text in a color other than white


Borjan
 Share

Recommended Posts

I can write texts on "billboard style" mashes in any combination of text and background colors. However, I cannot figure out how to do it when wrapping text.

For text wrapping I've used a code I've seen on this forum and on Stackoverflow and it works fine. However, it uses direct functions of WebGL and that apparently collides with the usage of BABYLON.JS objects (not surprising as it goes underneath the Babylon layer).

So, I can draw text In white, but not in black. I'm sure it can be done, but I'm fighting it the whole morning without succes,  Please have a look into this playground example (I've isolated it from the rest of my application). To see the meshes, double click on the canvas.

https://www.babylonjs-playground.com/index.html#MBENKS

Thanks very much in advance.

Link to comment
Share on other sites

6 hours ago, adam said:

I was unable to view your PG because it isn't working on my iPhone.

You should probably be using GUI:

http://doc.babylonjs.com/overviews/gui

Hi Adam,

I'm using GUI in this particular application prototype already, but it seems not to be meant for this particular purpose. Maybe I'm wrong. 

BTW, I've  also tried to open playground on my windows phone from the link provided by html5devs and it also fails (goes to default PG scene). However, typing of the last part of the url opens the PG without problems. Probably a glitch in the forum software.

Link to comment
Share on other sites

On 8/30/2017 at 0:52 AM, Deltakosh said:

you can leverage this then perhaps:

https://www.babylonjs-playground.com/#ZI9AK7#1

Hi Deltakosh,

I've read the documentation more thoroughly again and have checked this PG (I've set the button in the billboard mode, see: https://www.babylonjs-playground.com/#ZI9AK7#115 - you need to zoom in ...). In essence, it would likely be the future direction, thanks!  

However, there could be more work to do. For example, I do not know how display the button text in a color other than white.

Yesterday, I've completed the functionality in a somewhat hard way and it is now complete - will post it on the Playground next week. Because it is a (full functioning) prototype, I will stop improving it for a time being and will first check with the users am I on the right track all together. If it all goes fine, I would look for a BABYLON developer to write the functionality in a more professional way. I have programmed neatly, but my knowledge of javascript, WebGL and BABYLON.JS is by far insufficient to make a good product.

 

 

Link to comment
Share on other sites

Hi guys!

Oh, simpleButton.color is broken, it seems.

https://www.babylonjs-playground.com/#ZI9AK7#116

No yellow text.

Red text is working HERE, but this is a textBlock and not a simpleButton.

I'll get fresh coffee and start investigating it, even though it takes me hours to discover... what others discover in minutes.

Possible BJS BugZapper award coming for Borjan... and that means a WOOT PARTY!  Stay tuned.

Link to comment
Share on other sites

WOOT PARTY for BugZapper Borjan!  Yay!  And thanks DK!  Alright!

And and and... now that we're familiar with that code... wouldn't it be cool if GUI.anytext.color could be an array of strings?  {"red", "green", "blue"}

(The .ts coders really LOVE type = ANY)  :D

And... if the textWrap is true, and we create lots of ._lines of text (let's pretend 20 _lines of text with a textBlock, or with a wordy textWrapping simpleButton.)...

...it would sequence thru that color "strip" array, each  _line displayed in a different color!  WOW!  (and loop-back to start-of array if/when index > .color.length)

And then... what if...  ahh nevermind... we won't think about character-by-character rainbow text, yet.  :)

But then... if we had char-by-char fontSize and fontFamily... then we could do ransom notes:o

Let's not go there.  heh.  But _line by _line fontSize and fontFamily sequences... could be fun.  Just make .fontSize and .fontFamily accept arrays, too.  And then write a half ton of angry code.... to deal-with these new features.  :)  Easy.  (ahem)

I heard a rumor... that it is difficult to get an accurate context2d.measureText()... without first setting a fontSize and fontFamily.  Could be trouble for our dreamed-of features.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...