GithubHelp home page GithubHelp logo

sirknightdragoon / pixi-multistyle-text Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tleunen/pixi-multistyle-text

0.0 1.0 1.0 153 KB

Multi-Style Text for pixi.js

License: MIT License

JavaScript 79.98% HTML 20.02%

pixi-multistyle-text's Introduction

pixi-multistyle-text

NPM

Add a MultiStyleText object inside pixi.js to easily create text using different styles.

Example

In the example below, we are defining 4 text styles. def is the default style for the text, and the others matches the tags inside the text.

var textSample = new PIXI.MultiStyleText("<pixi>Pixi.js</pixi> can has <multiline>multiline</multiline>\nand <multistyle>multi-styles</multistyle> text!",
    {
        def: { font: "35px Snippet", fill: "white" },
        multiline: { font: "35px Snippet", fill: "blue" },
        pixi: { font: "35px Snippet", fill: "#D90057" },
        multistyle: { font: "35px Snippet", fill: "red" }
    }
);

Usage

text = new PIXI.MultiStyleText(text, textStyles [,lineStyle])

Creates a new Multi-Styles Text with the given options

textStyles

Type: [String:Object]

Each key of this dictionary should match with a tag in the text. Use the key def for the default style.

The style object can have these properties:

  • font {string} The style and size of the font. Default bold 20pt Arial.
  • fill {object} A canvas fillstyle that will be used on the text. Can be a color, a gradient, or a pattern. Default black.
  • stroke {object} A canvas fillstyle that will be used on the text stroke. Can be a color, a gradient, or a pattern. Default black.
  • strokeThickness {number} A number that represents the thickness of the stroke. Default 0.
  • dropShadow {boolean} Set a drop shadow for the text. Default false.
  • dropShadowColor {object} A fill style to be used on the dropshadow. Can be a color, a gradient, or a pattern. Default black.
  • dropShadowAngle {number} Set a angle of the drop shadow. Default Math.PI/4.
  • dropShadowDistance {number} Set a distance of the drop shadow. Default 5.
  • valign {string} Vertical alignment for multi font-size text ('top', 'middle', 'bottom'). Default 'top'.

lineStyle

Type: [Object]

  • align {string} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text. Default left.
  • wordWrap {boolean} Indicates if word wrap should be used. Default false.
  • wordWrapWidth {Number} The width at which text will wrap. Default 100.

demo

  • Open demo/index.html in a browser and you should see something like this:

img

License

MIT, see LICENSE.md for details.

pixi-multistyle-text's People

Contributors

sirknightdragoon avatar tleunen avatar

Watchers

 avatar

Forkers

dsge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.