(p5, fn)
| 5 | import { Font, arrayCommandsToObjects } from '../type/p5.Font'; |
| 6 | |
| 7 | function text(p5, fn) { |
| 8 | Renderer3D.prototype.maxCachedGlyphs = function() { |
| 9 | // TODO: use more than vibes to find a good value for this |
| 10 | return 200; |
| 11 | }; |
| 12 | |
| 13 | Font.prototype._getFontInfo = function(axs) { |
| 14 | // For WebGL, a cache of font data to use on the GPU. |
| 15 | this._fontInfos = this._fontInfos || {}; |
| 16 | |
| 17 | const key = JSON.stringify(axs); |
| 18 | if (this._fontInfos[key]) { |
| 19 | const val = this._fontInfos[key]; |
| 20 | return val; |
| 21 | } else { |
| 22 | const val = new FontInfo(this, { axs }); |
| 23 | this._fontInfos[key] = val; |
| 24 | return val; |
| 25 | } |
| 26 | }; |
| 27 | |
| 28 | // rendering constants |
| 29 | |
| 30 | // the number of rows/columns dividing each glyph |
| 31 | const charGridWidth = 9; |
| 32 | const charGridHeight = charGridWidth; |
| 33 | |
| 34 | // size of the image holding the bezier stroke info |
| 35 | const strokeImageWidth = 64; |
| 36 | const strokeImageHeight = 64; |
| 37 | |
| 38 | // size of the image holding the stroke indices for each row/col |
| 39 | const gridImageWidth = 64; |
| 40 | const gridImageHeight = 64; |
| 41 | |
| 42 | // size of the image holding the offset/length of each row/col stripe |
| 43 | const cellImageWidth = 64; |
| 44 | const cellImageHeight = 64; |
| 45 | |
| 46 | /** |
| 47 | * @private |
| 48 | * @class ImageInfos |
| 49 | * @param {Integer} width |
| 50 | * @param {Integer} height |
| 51 | * |
| 52 | * the ImageInfos class holds a list of ImageDatas of a given size. |
| 53 | */ |
| 54 | class ImageInfos { |
| 55 | constructor(width, height) { |
| 56 | this.width = width; |
| 57 | this.height = height; |
| 58 | this.infos = []; // the list of images |
| 59 | } |
| 60 | /** |
| 61 | * |
| 62 | * @param {Integer} space |
| 63 | * @return {Object} contains the ImageData, and pixel index into that |
| 64 | * ImageData where the free space was allocated. |
no test coverage detected