You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-10Lines changed: 15 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,49 +63,54 @@ And the resulting `/build/two.js` and `/build/two.min.js` will be updated to you
63
63
64
64
### Running in Headless Environments
65
65
66
-
As of version `v0.7.x` Two.js can also run in a headless environment, namely running on the server with the help of a library called [Node Canvas](https://github.com/Automattic/node-canvas). We don't add Node Canvas to dependencies of Two.js because it's _not necessary_ to run it in the browser. However, it has all the hooks setup to run in a cloud environment. To get started follow the installation instructions on Automattic's readme. After you've done that run:
66
+
As of version `v0.7.x` Two.js can also run in a headless environment, namely running on the server with the help of a library called [Node Canvas](https://github.com/Automattic/node-canvas). We don't add Node Canvas to dependencies of Two.js because it's _not necessary_ to run it in the browser. However, it has all the hooks setup to run in a cloud environment. To get started follow the installation instructions on Automattic's [readme](https://github.com/Automattic/node-canvas#installation). After you've done that run:
67
67
68
68
```
69
69
npm install canvas
70
+
npm intsall two.js
70
71
```
71
72
72
73
Now in a JavaScript file setup your Two.js scenegraph and save out frames whenever you need to:
73
74
74
75
```javascript
75
-
varTwo =require('../build/two.js'); // Or from npm, `require('two.js');`
76
-
varCanvas=require('canvas');
77
-
var Image =Canvas.Image;
76
+
var{ createCanvas, Image } =require('canvas');
77
+
varTwo=require('two.js')
78
+
78
79
var fs =require('fs');
79
80
var path =require('path');
80
81
81
82
var width =800;
82
83
var height =600;
83
84
84
-
var canvas =Two.Utils.shim(Canvas);
85
+
var canvas =createCanvas(width, height);
86
+
Two.Utils.shim(canvas, Image);
85
87
86
88
var time =Date.now();
87
89
88
90
var two =newTwo({
89
-
type:Two.Types.canvas,
90
-
width:800,
91
-
height:600,
91
+
width: width,
92
+
height: height,
92
93
domElement: canvas
93
94
});
94
95
95
96
var rect =two.makeRectangle(width /2, height /2, 50, 50);
Copy file name to clipboardExpand all lines: build/two.js
+18-12Lines changed: 18 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -456,13 +456,13 @@ SOFTWARE.
456
456
* @name Two.Version
457
457
* @property {String} - The current working version of the library.
458
458
*/
459
-
Version: 'v0.7.0-beta.1',
459
+
Version: 'v0.7.0-beta.2',
460
460
461
461
/**
462
462
* @name Two.PublishDate
463
463
* @property {String} - The automatically generated publish date in the build process to verify version release candidates.
464
464
*/
465
-
PublishDate: '2018-11-03T10:28:50+01:00',
465
+
PublishDate: '2018-11-18T10:50:17+01:00',
466
466
467
467
/**
468
468
* @name Two.Identifier
@@ -580,14 +580,16 @@ SOFTWARE.
580
580
/**
581
581
* @name Two.Utils.shim
582
582
* @function
583
-
* @param {Canvas} CanvasModule - The `Canvas` object provided by `node-canvas`.
584
-
* @returns {Canvas} Returns an instanced canvas object from the provided `node-canvas` `Canvas` object.
583
+
* @param {canvas} canvas - The instanced `Canvas` object provided by `node-canvas`.
584
+
* @param {Image} [Image] - The prototypical `Image` object provided by `node-canvas`. This is only necessary to pass if you're going to load bitmap imagery.
585
+
* @returns {canvas} Returns the instanced canvas object you passed from with additional attributes needed for Two.js.
585
586
* @description Convenience method for defining all the dependencies from the npm package `node-canvas`. See [node-canvas]{@link https://github.com/Automattic/node-canvas} for additional information on setting up HTML5 `<canvas />` drawing in a node.js environment.
0 commit comments