|
| 1 | +/** |
| 2 | + * @author Richard Davey <rich@photonstorm.com> |
| 3 | + * @copyright 2020 Photon Storm Ltd. |
| 4 | + * @license {@link https://opensource.org/licenses/MIT|MIT License} |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * Renders one character of the Bitmap Text to the WebGL Pipeline. |
| 9 | + * |
| 10 | + * @function BatchChar |
| 11 | + * @since 3.50.0 |
| 12 | + * @private |
| 13 | + * |
| 14 | + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The BitmapText Game Object. |
| 15 | + * @param {Phaser.GameObjects.BitmapText} src - The BitmapText Game Object. |
| 16 | + * @param {Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter} char - The character to render. |
| 17 | + * @param {Phaser.Types.GameObjects.BitmapText.BitmapFontCharacterData} glyph - The character glyph. |
| 18 | + * @param {number} offsetX - The x offset. |
| 19 | + * @param {number} offsetY - The y offset. |
| 20 | + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix. |
| 21 | + * @param {boolean} roundPixels - Round the transform values or not? |
| 22 | + * @param {number} tintTL - Top-left tint value. |
| 23 | + * @param {number} tintTR - Top-right tint value. |
| 24 | + * @param {number} tintBL - Bottom-left tint value. |
| 25 | + * @param {number} tintBR - Bottom-right tint value. |
| 26 | + * @param {number} tintEffect - The tint effect mode. |
| 27 | + * @param {WebGLTexture} texture - The WebGL texture. |
| 28 | + * @param {number} textureUnit - The texture unit. |
| 29 | + */ |
| 30 | +var BatchChar = function (pipeline, src, char, glyph, offsetX, offsetY, calcMatrix, roundPixels, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit) |
| 31 | +{ |
| 32 | + var x = (char.x - src.displayOriginX) + offsetX; |
| 33 | + var y = (char.y - src.displayOriginY) + offsetY; |
| 34 | + |
| 35 | + var xw = x + char.w; |
| 36 | + var yh = y + char.h; |
| 37 | + |
| 38 | + var tx0 = calcMatrix.getXRound(x, y, roundPixels); |
| 39 | + var ty0 = calcMatrix.getYRound(x, y, roundPixels); |
| 40 | + |
| 41 | + var tx1 = calcMatrix.getXRound(x, yh, roundPixels); |
| 42 | + var ty1 = calcMatrix.getYRound(x, yh, roundPixels); |
| 43 | + |
| 44 | + var tx2 = calcMatrix.getXRound(xw, yh, roundPixels); |
| 45 | + var ty2 = calcMatrix.getYRound(xw, yh, roundPixels); |
| 46 | + |
| 47 | + var tx3 = calcMatrix.getXRound(xw, y, roundPixels); |
| 48 | + var ty3 = calcMatrix.getYRound(xw, y, roundPixels); |
| 49 | + |
| 50 | + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, glyph.u0, glyph.v0, glyph.u1, glyph.v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit); |
| 51 | +}; |
| 52 | + |
| 53 | +module.exports = BatchChar; |
0 commit comments