Giter Club home page Giter Club logo

ttt's Introduction

Tiny Texture Tumbler

A small JS library to create textures. Mainly useful for file size restricted competitions.

Editor

https://phoboslab.org/ttt/

Usage

Include the ttt.min.js into your project.

The ttt() function takes an array of texture definitions and returns an array of canvas elements. You can use the canvas element as the source for ctx.drawImage(), to create WebGL textures with gl.texImage2D() or to just add them to your HTML.

// Example texture 32x32 pixels with a pink background
ttt([[32, 32, 0xf0ff]]).map(canvas => document.body.appendChild(canvas));

Notes

  • Colors are saved as 16bit values. Each nibble (that is each 4 bit value or each character in hex) correspondes to an r,g,b,a value.
  • The library currently has very few different drawing operations. Don't be afraid to extend those to whatever else you need. But keep in mind that you can draw circles and many shapes with the text function and a single letter or emoji :^)
  • The rectangle function actually draws 3 rectangles with different colors at 1px offsets. This is useful to create insets or bumps. You can set the alpha of the top/bottom to 0 if you don't need it.
  • You can draw a texture onto itself. If you modify the x/y position and the alpha value, you can get some cool effects.

License

The MIT License(MIT)

ttt's People

Contributors

phoboslab avatar lerc avatar

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.