Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
v1.4.1: customized font; text shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesliu96 committed May 16, 2015
1 parent 8be3b1d commit 401fb5f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Damoo [![Gitter chat](https://badges.gitter.im/jamesliu96/Damoo.svg)](https://gitter.im/jamesliu96/Damoo)
Damoo [![Join Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jamesliu96/Damoo)
======

An HTML5 Danmaku Engine.
Expand Down Expand Up @@ -28,6 +28,12 @@ Initiate the engine by writing this.
var damoo = Damoo('dm-screen', 'dm-canvas', 20);
```

Or use your own font instead of "sans-serif".

```javascript
var damoo = Damoo('dm-screen', 'dm-canvas', 20, "Arial");
```

And run it.

```javascript
Expand All @@ -41,6 +47,18 @@ Danmaku can be emitted by calling `emit` method.
damoo.emit({ text: "Damoo is awesome!", color: "#f49" });
```

Enable shadow below the text.

```javascript
damoo.emit({ text: "I got a shadow!", color: "#000", shadow: true });
```

Color the shadow.

```javascript
damoo.emit({ text: "Hooray!", color: "#f00", shadow: { color: "#f49" } });
```

Clear the screen.

```javascript
Expand All @@ -57,23 +75,4 @@ Damoo is yet not a finished product so please just fork, and do whatever you wan
License
------

The MIT License (MIT)

Copyright (c) 2015 James Liu <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[![MIT License](https://img.shields.io/github/license/jamesliu96/Damoo.svg)](https://github.com/jamesliu96/Damoo/blob/master/LICENSE)
28 changes: 16 additions & 12 deletions damoo.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*!
* Damoo - HTML5 Danmaku Engine v1.4.0
* Damoo - HTML5 Danmaku Engine v1.4.1
* https://github.com/jamesliu96/Damoo
*
* Copyright (c) 2015 James Liu
* Released under the MIT license
*/
;(function(window) {
var Damoo = function(m, n, r) {
var Damoo = function(m, n, r, t) {
if (!(this instanceof Damoo)) {
return new Damoo(m, n, r);
return new Damoo(m, n, r, t);
}
this.canvas = new Canvas(m, n, r);
this.canvas = new Canvas(m, n, r, t);
this.thread = new Thread(r);
};

Damoo.version = "v1.4.0";
Damoo.version = "v1.4.1";

Damoo.dom = window.document;

Expand All @@ -24,10 +24,14 @@
cvs.width = f.size * d.text.length * 1.2;
cvs.height = f.size * 1.2;
ctx.font = f.value;
ctx.fillStyle = "#fff";
ctx.fillStyle = d.color;
ctx.textAlign = "start";
ctx.textBaseline = "top";
ctx.fillStyle = "#fff";
if (d.shadow) {
ctx.fillStyle = d.shadow.color;
ctx.fillText(d.text, 1, 1);
}
ctx.fillStyle = d.color;
ctx.fillText(d.text, 0, 0);
return cvs;
};
Expand Down Expand Up @@ -83,7 +87,7 @@
}(this));
};

var Canvas = function(m, n, r) {
var Canvas = function(m, n, r, t) {
this.parent = Damoo.dom.getElementById(m);
this.parent.style.position = "relative";
this.id = n;
Expand All @@ -93,15 +97,15 @@
}
this.width = this.parent.offsetWidth;
this.height = this.parent.offsetHeight;
this.font = new Font(this.height / this.rows, "sans-serif");
this.font = new Font(this.height / this.rows, t || "sans-serif");
this.layer = Damoo.dom.createElement('canvas');
this.context = this.layer.getContext('2d');
this.layer.id = this.id;
this.layer.width = this.width;
this.layer.height = this.height;
this.layer.style.display = 'block';
this.layer.style.backgroundColor = 'transparent';
this.layer.style.position = 'absolute';
this.layer.style.display = "block";
this.layer.style.backgroundColor = "transparent";
this.layer.style.position = "absolute";
this.layer.style.left = 0;
this.layer.style.top = 0;
this.layer.style.zIndex = 99999;
Expand Down
14 changes: 7 additions & 7 deletions damoo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 401fb5f

Please sign in to comment.