Coder Social home page Coder Social logo

bwflowers's Introduction

A simple library for generating random pictograms in the browser.

Using

Example:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Demo of bwflowers</title>
    <script src="js/underscore.js"></script>
    <script src="js/jquery.js"></script>
    <script src="js/mersenne_twister.js"></script>
    <script src="js/bwflowers-bundle.js"></script>
    <style>
        .bwflowers-basic {
            width: 80px;
            height: 80px;
            background-color: #11292a;
            color: white;
            margin: 5px;
        }
    </style>
</head>
<body>
    <div class="bwflowers-basic" data-contents-to-hash="variation-asfx"></div>
    <div class="bwflowers-basic" data-contents-to-hash="variation-ffsa"></div>
    <div class="bwflowers-basic" data-contents-to-hash="variation-dfaf"></div>
    <div class="bwflowers-basic" data-contents-to-hash="variation-34as"></div>
    <script>
        $(document).ready(function(){
            bwflowers.assimilate('.bwflowers-basic');
        })
    </script>
</body>
</html>

Here is a list of steps that you need to take:

  1. Add the dependencies. Those are underscore.js, jquery, and mersenne_twister.js. They are present in this repository, but chances are that your project is already using some of them.
  2. Add the library bundle. You can find it at bundle/bwflowers-bundle.js
  3. Create and style a few elements. This library uses the computed css color and computed css background color of the elements. In the example above, the divs with the class "bwflowers-basic" are given a fixed width and height.
  4. Add a 'data-contents-to-hash' attribute with a string. A hash of this string will be used to initialize the random number generator, so that you get exactly the same pictogram for the same string.
  5. Invoke bwflowers.assimilate and pass a css selector string for the elements where you want to draw pictograms.

Build

This is not a npm package yet, but you npm is used to create a basic environment:

$ npm install

and then do

$ ./compile.sh

The resulting javascript bundle will be found at bundle/bwflowers-bundle.js

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.