Jump to content

How to draw multiline text with proper background?


link
 Share

Recommended Posts

Pixi.js is a great lib and it did help me a lot in building webgl-based apps. 

But when I try to render text with background, I run into some problem:

  1.  PIXI.Text has no straight way to fill a text with background

ok.I tried to search the forum and find some methods like, I can use PIXI.Grahpics to draw a Rect or RoundedRect , then combine the text and the rounded shape into a container so it looks like the text has a background;

In single line text, it appears so good but is this a right way?

  2. I can't find a way to build 'tight' background with multi line text;

What do I mean a 'tight' background? See the pic below:

image.png.4e9e756ea8259929b4deff35ed752e11.png

 

(the pic comes from https://css-tricks.com/multi-line-padded-text/ and if u read the article u can learn some tricks to make these special background in css)

Well, come back to PIXI.js. I know that the text sprite is certainly a Rectangle by default, so when I add a 'background sprite' it's also a Rectangle:)

And I find some useful filters like OutlineFilter but it can't use to outline a text , and I'm not an expert in writing gl shaders.

Has anyone met the situation before(render multiline text with background) or can give me some advice? Thanks very much.

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...