GithubHelp home page GithubHelp logo

danmaku-js's Introduction

Danmaku.js

使用

示例

<div id="wrapper" style="font-size: 20px; width: 100%; height:100%;"></div>
<script src="Danmaku.js"></script>
<script>
    // 新建画板
    var danmakuPainter = new DanmakuPainter(document.getElementById('wrapper'));
    // 窗口调整大小的时候调整大小
    (window.onresize = function () {
        document.body.style.height = window.innerHeight + 'px';
        danmakuPainter.resize.bind(danmakuPainter)();
    })();

    // 新建div
    var div = document.createElement('div');
    // 设置文字
    div.textContent = 'Hello world!';
    // 设置文字颜色
    div.style.color = 'blue';
    // 新建顶端的(代码为1)时长为5秒弹幕并立即发射
    danmakuPainter.launch(new Danmaku(div, 1, 5), 0);
</script>

说明

  • 发射语句danmakuPainter.launch(new Danmaku(div, position, duration), delay);中的四个参数说明
参数 说明 取值
div div元素 HTMLDivElement
position 弹幕位置 0: 普通, 1: 顶端, 2: 底端
duration 弹幕时长 正实数,以秒为单位
delay 延迟发射 实数,以秒为单位,正数表示延时发射,负数同理
  • 只要被div包围即可,内容可以是任何类型,可以是图片、文本等

Author

Ganlv

LICENSE

Apache 2.0

danmaku-js's People

Contributors

ganlvtech avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.