From dabc0b906b3b61c74d82467a1ff67909923221cb Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 14 Nov 2024 17:14:10 +0000 Subject: [PATCH] Removed 'create' namespace and palettes --- src/create/GenerateTexture.js | 116 ------------------- src/create/index.js | 16 --- src/create/palettes/Arne16.js | 32 ----- src/create/palettes/C64.js | 32 ----- src/create/palettes/CGA.js | 32 ----- src/create/palettes/JMP.js | 32 ----- src/create/palettes/MSX.js | 32 ----- src/create/palettes/index.js | 19 --- src/create/typedefs/GenerateTextureConfig.js | 22 ---- src/create/typedefs/Palette.js | 21 ---- src/create/typedefs/index.js | 9 -- src/phaser-arcade-physics.js | 1 - src/phaser-esm.js | 1 - src/phaser.js | 1 - 14 files changed, 366 deletions(-) delete mode 100644 src/create/GenerateTexture.js delete mode 100644 src/create/index.js delete mode 100644 src/create/palettes/Arne16.js delete mode 100644 src/create/palettes/C64.js delete mode 100644 src/create/palettes/CGA.js delete mode 100644 src/create/palettes/JMP.js delete mode 100644 src/create/palettes/MSX.js delete mode 100644 src/create/palettes/index.js delete mode 100644 src/create/typedefs/GenerateTextureConfig.js delete mode 100644 src/create/typedefs/Palette.js delete mode 100644 src/create/typedefs/index.js diff --git a/src/create/GenerateTexture.js b/src/create/GenerateTexture.js deleted file mode 100644 index 3de1c89f0..000000000 --- a/src/create/GenerateTexture.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -var Arne16 = require('./palettes/Arne16'); -var CanvasPool = require('../display/canvas/CanvasPool'); -var GetValue = require('../utils/object/GetValue'); - -/** - * Generates a texture based on the given Create configuration object. - * - * The texture is drawn using a fixed-size indexed palette of 16 colors, where the hex value in the - * data cells map to a single color. For example, if the texture config looked like this: - * - * ```javascript - * var star = [ - * '.....828.....', - * '....72227....', - * '....82228....', - * '...7222227...', - * '2222222222222', - * '8222222222228', - * '.72222222227.', - * '..787777787..', - * '..877777778..', - * '.78778887787.', - * '.27887.78872.', - * '.787.....787.' - * ]; - * - * this.textures.generate('star', { data: star, pixelWidth: 4 }); - * ``` - * - * Then it would generate a texture that is 52 x 48 pixels in size, because each cell of the data array - * represents 1 pixel multiplied by the `pixelWidth` value. The cell values, such as `8`, maps to color - * number 8 in the palette. If a cell contains a period character `.` then it is transparent. - * - * The default palette is Arne16, but you can specify your own using the `palette` property. - * - * @function Phaser.Create.GenerateTexture - * @since 3.0.0 - * - * @param {Phaser.Types.Create.GenerateTextureConfig} config - The Generate Texture Configuration object. - * - * @return {HTMLCanvasElement} An HTMLCanvasElement which contains the generated texture drawn to it. - */ -var GenerateTexture = function (config) -{ - var data = GetValue(config, 'data', []); - var canvas = GetValue(config, 'canvas', null); - var palette = GetValue(config, 'palette', Arne16); - var pixelWidth = GetValue(config, 'pixelWidth', 1); - var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); - var resizeCanvas = GetValue(config, 'resizeCanvas', true); - var clearCanvas = GetValue(config, 'clearCanvas', true); - var preRender = GetValue(config, 'preRender', null); - var postRender = GetValue(config, 'postRender', null); - - var width = Math.floor(Math.abs(data[0].length * pixelWidth)); - var height = Math.floor(Math.abs(data.length * pixelHeight)); - - if (!canvas) - { - canvas = CanvasPool.create2D(this, width, height); - resizeCanvas = false; - clearCanvas = false; - } - - if (resizeCanvas) - { - canvas.width = width; - canvas.height = height; - } - - var ctx = canvas.getContext('2d', { willReadFrequently: true }); - - if (clearCanvas) - { - ctx.clearRect(0, 0, width, height); - } - - // preRender Callback? - if (preRender) - { - preRender(canvas, ctx); - } - - // Draw it - for (var y = 0; y < data.length; y++) - { - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var d = row[x]; - - if (d !== '.' && d !== ' ') - { - ctx.fillStyle = palette[d]; - ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); - } - } - } - - // postRender Callback? - if (postRender) - { - postRender(canvas, ctx); - } - - return canvas; -}; - -module.exports = GenerateTexture; diff --git a/src/create/index.js b/src/create/index.js deleted file mode 100644 index 7b3ac44a3..000000000 --- a/src/create/index.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * @namespace Phaser.Create - */ - -module.exports = { - - GenerateTexture: require('./GenerateTexture'), - Palettes: require('./palettes') - -}; diff --git a/src/create/palettes/Arne16.js b/src/create/palettes/Arne16.js deleted file mode 100644 index 05be8c2d8..000000000 --- a/src/create/palettes/Arne16.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.ARNE16 - * @since 3.0.0 - * - * @type {Phaser.Types.Create.Palette} - */ -module.exports = { - 0: '#000', - 1: '#9D9D9D', - 2: '#FFF', - 3: '#BE2633', - 4: '#E06F8B', - 5: '#493C2B', - 6: '#A46422', - 7: '#EB8931', - 8: '#F7E26B', - 9: '#2F484E', - A: '#44891A', - B: '#A3CE27', - C: '#1B2632', - D: '#005784', - E: '#31A2F2', - F: '#B2DCEF' -}; diff --git a/src/create/palettes/C64.js b/src/create/palettes/C64.js deleted file mode 100644 index d31b5e072..000000000 --- a/src/create/palettes/C64.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * A 16 color palette inspired by the Commodore 64. - * - * @name Phaser.Create.Palettes.C64 - * @since 3.0.0 - * - * @type {Phaser.Types.Create.Palette} - */ -module.exports = { - 0: '#000', - 1: '#fff', - 2: '#8b4131', - 3: '#7bbdc5', - 4: '#8b41ac', - 5: '#6aac41', - 6: '#3931a4', - 7: '#d5de73', - 8: '#945a20', - 9: '#5a4100', - A: '#bd736a', - B: '#525252', - C: '#838383', - D: '#acee8b', - E: '#7b73de', - F: '#acacac' -}; diff --git a/src/create/palettes/CGA.js b/src/create/palettes/CGA.js deleted file mode 100644 index b06298d25..000000000 --- a/src/create/palettes/CGA.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.CGA - * @since 3.0.0 - * - * @type {Phaser.Types.Create.Palette} - */ -module.exports = { - 0: '#000', - 1: '#2234d1', - 2: '#0c7e45', - 3: '#44aacc', - 4: '#8a3622', - 5: '#5c2e78', - 6: '#aa5c3d', - 7: '#b5b5b5', - 8: '#5e606e', - 9: '#4c81fb', - A: '#6cd947', - B: '#7be2f9', - C: '#eb8a60', - D: '#e23d69', - E: '#ffd93f', - F: '#fff' -}; diff --git a/src/create/palettes/JMP.js b/src/create/palettes/JMP.js deleted file mode 100644 index c66cf6ef1..000000000 --- a/src/create/palettes/JMP.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.JMP - * @since 3.0.0 - * - * @type {Phaser.Types.Create.Palette} - */ -module.exports = { - 0: '#000', - 1: '#191028', - 2: '#46af45', - 3: '#a1d685', - 4: '#453e78', - 5: '#7664fe', - 6: '#833129', - 7: '#9ec2e8', - 8: '#dc534b', - 9: '#e18d79', - A: '#d6b97b', - B: '#e9d8a1', - C: '#216c4b', - D: '#d365c8', - E: '#afaab9', - F: '#f5f4eb' -}; diff --git a/src/create/palettes/MSX.js b/src/create/palettes/MSX.js deleted file mode 100644 index c84881cb0..000000000 --- a/src/create/palettes/MSX.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * A 16 color palette inspired by Japanese computers like the MSX. - * - * @name Phaser.Create.Palettes.MSX - * @since 3.0.0 - * - * @type {Phaser.Types.Create.Palette} - */ -module.exports = { - 0: '#000', - 1: '#191028', - 2: '#46af45', - 3: '#a1d685', - 4: '#453e78', - 5: '#7664fe', - 6: '#833129', - 7: '#9ec2e8', - 8: '#dc534b', - 9: '#e18d79', - A: '#d6b97b', - B: '#e9d8a1', - C: '#216c4b', - D: '#d365c8', - E: '#afaab9', - F: '#fff' -}; diff --git a/src/create/palettes/index.js b/src/create/palettes/index.js deleted file mode 100644 index 6e9bff60c..000000000 --- a/src/create/palettes/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * @namespace Phaser.Create.Palettes - */ - -module.exports = { - - ARNE16: require('./Arne16'), - C64: require('./C64'), - CGA: require('./CGA'), - JMP: require('./JMP'), - MSX: require('./MSX') - -}; diff --git a/src/create/typedefs/GenerateTextureConfig.js b/src/create/typedefs/GenerateTextureConfig.js deleted file mode 100644 index a001a9bae..000000000 --- a/src/create/typedefs/GenerateTextureConfig.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @callback Phaser.Types.Create.GenerateTextureCallback - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The HTML Canvas element to operate on. - * @param {CanvasRenderingContext2D} context - The context of the HTML Canvas element. - */ - -/** - * @typedef {object} Phaser.Types.Create.GenerateTextureConfig - * @since 3.0.0 - * - * @property {array} [data=[]] - An array of data, where each row is a string of single values 0-9A-F, or the period character. - * @property {HTMLCanvasElement} [canvas=null] - The HTML Canvas to draw the texture to. - * @property {Phaser.Types.Create.Palette} [palette=Arne16] - The indexed palette that the data cell values map to. - * @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture. - * @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture. - * @property {boolean} [resizeCanvas=true] - Should the canvas be resized before the texture is drawn? - * @property {boolean} [clearCanvas=true] - Should the canvas be cleared before the texture is drawn? - * @property {Phaser.Types.Create.GenerateTextureCallback} [preRender] - A callback to send the canvas to prior to the texture being drawn. - * @property {Phaser.Types.Create.GenerateTextureCallback} [postRender] - A callback to send the canvas to after the texture has been drawn. - */ diff --git a/src/create/typedefs/Palette.js b/src/create/typedefs/Palette.js deleted file mode 100644 index a7f5bdb23..000000000 --- a/src/create/typedefs/Palette.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @typedef {object} Phaser.Types.Create.Palette - * @since 3.0.0 - * - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ diff --git a/src/create/typedefs/index.js b/src/create/typedefs/index.js deleted file mode 100644 index 256939e59..000000000 --- a/src/create/typedefs/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2013-2024 Phaser Studio Inc. - * @license {@link https://opensource.org/licenses/MIT|MIT License} - */ - -/** - * @namespace Phaser.Types.Create - */ diff --git a/src/phaser-arcade-physics.js b/src/phaser-arcade-physics.js index c1b031cc8..d598e5b59 100644 --- a/src/phaser-arcade-physics.js +++ b/src/phaser-arcade-physics.js @@ -22,7 +22,6 @@ var Phaser = { Cameras: require('./cameras'), Core: require('./core'), Class: require('./utils/Class'), - Create: require('./create'), Curves: require('./curves'), Data: require('./data'), Display: require('./display'), diff --git a/src/phaser-esm.js b/src/phaser-esm.js index 1c8f09856..c0f19f8b6 100644 --- a/src/phaser-esm.js +++ b/src/phaser-esm.js @@ -14,7 +14,6 @@ export const BlendModes = require('./renderer/BlendModes'); export const Cache = require('./cache'); export const Cameras = require('./cameras'); export const Core = require('./core'); -export const Create = require('./create'); export const Curves = require('./curves'); export const Data = require('./data'); export const Display = require('./display'); diff --git a/src/phaser.js b/src/phaser.js index ccfcb628b..955953573 100644 --- a/src/phaser.js +++ b/src/phaser.js @@ -22,7 +22,6 @@ var Phaser = { Cameras: require('./cameras'), Core: require('./core'), Class: require('./utils/Class'), - Create: require('./create'), Curves: require('./curves'), Data: require('./data'), Display: require('./display'),