1.0.0 • Published 4 years ago

phaser3-plugin-mosaicview v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Phaser 3 Plugin - MosaicView

This is a phaser 3 plugin for a customizable mosaic view. Use it to draw mosaic, with full control over tile size and color as well as color deviation including alpha. See usage for more information.

npm.io

Usage

import 'phaser';
import MosaicViewPlugin from 'phaser3-plugin-mosiacview';

const game = new Phaser.Game({
  width: 1024,
  height: 768,
  backgroundColor: 0xffffff,
  scale: {
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH
  },
  scene: {
    create: create,
  },
  plugins: {
    global: [{
      key: 'MosaicViewPlugin',
      plugin: MosaicViewPlugin,
      start: true
    }]
  }
});

function create() {
  this.add.mosaicView(0, 0, 200, 200, {
      tileWidth: 5,
      tileHeight: 5,
      padding: 1,
      startWithPadding: true,
      backgroundColor: 0x000000,
      color: 0xec844e,
      minColorDeviation: 0.1,
      maxColorDeviation: 0.2,
      minAlpha: 0.8,
      maxAlpha: 1
    });
}

API

// initialize plugin ...
// this.add.mosaicView(x, y, width, height, options)
const mosaicView = this.add.mosaicView(0, 0, 200, 200, {});

Options can be as follows:

NameExplanationExampleDefault
tileWidthThe width of a mosaic tile1010
tileHeightThe height of a mosaic tile1010
paddingThe padding between mosaic tiles22
colorThe base color of a mosaic tile. Must be a hex value0xff00000x0000ff
backgroundColorThe background color of the view, where mosiac tiles are placed on0x0000000x000000
startWithPaddingA flag indicating whether a padding should be drawn first. If set the first item drawn is a padding. If set to false a tile is drawn firsttruefalse
minColorDeviationA value between 0 and 1 indicating how strong the minimum color deviation is. For each mosaic tile a color devation is calculated between minColorDeviation and maxColorDeviation00
maxColorDeviationA value between 0 and 1 indicating how strong the maximum color deviation is. For each mosaic tile a color devation is calculated between minColorDeviation and maxColorDeviation10
minAlphaA value between 0 and 1 indicating the minimum alpha value for a mosaic tile. For each mosaic tile an alpha value between minAlpha and maxAlpha is calculated0.751
maxAlphaA value between 0 and 1 indicating the maximum alpha value for a mosaic tile. For each mosaic tile an alpha value between minAlpha and maxAlpha is calculated0.751

Installation

npm i phaser3-plugin-mosaicview

Alternatively you can grab the latest distributed version directly from github via: https://raw.githubusercontent.com/dasheck0/phaser3-plugin-mosaicview/master/dist/MosaicViewPlugin.js

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dasheck0/phaser3-plugin-mosaicview/pulls. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

MIT License

Copyright (c) 2020 Stefan Neidig

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.