question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Masking with text

See original GitHub issue

We want to use text as a mask for an image. Something like this:

image

As I understand it, PIXI renders text to an image but we need a PIXI.Graphics object to do a mask. Is that correct? If so, does anyone know how I could turn text into a Graphics?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ivanpopelyshevcommented, Mar 1, 2018

Pixi masks use alpha and red channels. Your text is black, so its 0 by red => no mask.

https://jsfiddle.net/Hackerham/s7hh0590/3/ - it works for White text just fine.

1reaction
Cpin0312commented, Feb 28, 2018

Can i join here? i have read @jhollingworth code and try to do it by my way. however my code like this var app = new PIXI.Application(800, 600, { transparent: true }); document.getElementById('container').appendChild(app.view); PIXI.loader .add('godzilla','https://i.kinja-img.com/gawker-media/image/upload/s--fbE5h4t0--/c_scale,fl_progressive,q_80,w_800/1501840081290294050.jpg') .load(setup_B); var style = new PIXI.TextStyle({ fontFamily: 'Arial', fontSize: 200, fontWeight: 'bold', });

function setup_A() { var texture = PIXI.loader.resources.godzilla.texture; var godzilla = new PIXI.Sprite(texture); var text = new PIXI.Text('Godzilla', style); text.x = 0 text.y = 100 godzilla.width = 800; godzilla.height = 449; godzilla.mask = text app.stage.addChild(godzilla); text.updateText(); }

function setup_B() { var texture = PIXI.loader.resources.godzilla.texture; var godzilla = new PIXI.Sprite(texture); var text = new PIXI.Text('Godzilla', style); text.x = 0 text.y = 100 godzilla.width = 800; godzilla.height = 449; text.mask = godzilla app.stage.addChild(text); text.updateText(); }

in setup_A, window show nothing , in setup_B, text.mask just show mono,not color. Have missing understanding something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

2 Ways Mask with Text in Photoshop - From Beginner to ...
Mask 2 – · 1.We have an image and a text layer. Move the text layer below the image layer. · 2. Hold...
Read more >
7 Beautiful Text Masks - How to WOW with Images in Text - Easil
How to Create Images in Text with 'Text Masks' · #1 Create an image in text over a flat background color · #2...
Read more >
Make a Text Mask | How to Fill Your Image With ... - PicMonkey
Learn how to easily make text masks in PicMonkey, and fill your text with images, video, textures, and more. Start designing for free...
Read more >
How to Create a Text Mask in Canva - Blogging Guide
Text masking (also known as “knockout text”) is a technique allowing designers to display images, gradients, patterns, and even videos ...
Read more >
Learn How To Add A Layer Mask To Text In Adobe Photoshop
Applying Layer Masks in Adobe Photoshop can have many great benefits, especially when working with typography. Bring an image to life by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found