Giter VIP home page Giter VIP logo

bm.js's Introduction

BM.js

BM.js 是一个可绘制位图(bitmap)的展示插件。

安装

  1. 引入 css 文件
<link rel="stylesheet" href="dist/css/bm.css">
  1. 引入 js 文件,注意别忘了加载 jQuery 库
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="dist/js/bm.js" charset="utf-8"></script>
  1. 初始化位图画布
$('#bmArea').bmInit();

语法

  • 初始化
$('#bmArea').bmInit();

也可以指定画布的宽高格数,默认为 20 行 50 列

$('#bmArea').bmInit({
    row: 20,
    col: 50
});
  • 获取画布数据
//返回一串由 0 和 1 组成的字符串
var dataStr = $('#bmArea').bmGet();
  • 复原画布
// dataStr 为画布数据
$('#bmArea').bmSet(dataStr);
  • 清空画布
$('#bmArea').bmClear();
  • 画布只读
//设为只读
$('#bmArea').bmReadonly(true);
//取消只读
$('#bmArea').bmReadonly(false);
  • 位图动画,由多个画布组成的一组动画
// dataJSON 为 json 数据,callback 为动画执行完毕后触发
$('#bmArea').bmPlay(dataJSON, callback);

动画数据 json 格式

// data 为画布数据,duration 为持续时间(单位:毫秒)
[
    {
        "data": "000000",
        "duration": 10
    },
    {
        "data": "000000",
        "duration": 10
    },
    {
        "data": "000000",
        "duration": 10
    }
]
  • 链式调用
$('#bmArea').bmInit({
    row: 3,
    col: 3
}).bmSet('000111000');

bm.js's People

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.