Skip to content

Commit

Permalink
v0.2.0 | typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
indus committed May 13, 2014
1 parent c5775b9 commit 2940a59
Show file tree
Hide file tree
Showing 12 changed files with 2,394 additions and 790 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,25 @@ Methods and properties beyond the native API are marked with a leading underscor

#### options (with defaults)
```javascript
{ verbose: false,
{ logLevel: 2,
port: 9222,
retry: 3,
retryDelay: 1000,
spawn: {
command: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
args: [ '--app=' + __dirname + '\\index.html',
'--remote-debugging-port={PORT}',
'--user-data-dir=' + os.tmpdir() + '\\nccanvas' ],
options: {}
},
retry: 3,
retryDelay: 1000 }
}
}
```
### startup-errors
**ncc** is preconfigured to start a chrome childprocess on a Windows system with a default Chrome installation. If you are faceing problems getting **ncc** started (especially on a none-windows system) you should make changes to the 'spawn'-[options](https://github.com/indus/ncc#options). Try to **[spawn](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)** a blank chrome instance first...
```javascript
var spawn = require('child_process').spawn,
args = [],
chrome = spawn('path/to/chromeExecutable', args);
var spawn = require('child_process').spawn,
args = [],
chrome = spawn('path/to/chromeExecutable', args);

chrome.stdout.on('data', function (data) {
console.log('stdout: ' + data);
Expand Down
1 change: 1 addition & 0 deletions examples/1_draw_ncc_logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ncc(function (err, canvas) {
if (err)
console.error("ncc draw Error:", err);
console.timeEnd("ncc draw time");
console.log("\n\033[46m\t" + "Tataa!" + "\033[49m\n");
})

// --- ALTERNATIVES ---
Expand Down
6 changes: 3 additions & 3 deletions examples/2_early_access.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var canvas = ncc(function (err, canvas) {
return;
}

console.log("... in order of creation!");
console.log("\n\033[46m\t" + "... in order of creation!" + "\033[49m\n");
})

// --- ALTERNATIVES ---
Expand All @@ -32,7 +32,7 @@ ctx.font = "30px Arial";
ctx.textAlign = "center";
ctx.fillText("NCC Example 2 - early access", canvas.width / 2, 60, canvas.width-50);

ctx(function (err,res) {
console.log("all callbacks get invoked ...");
ctx(function (err, res) {
console.log("\n\033[46m\t" + "all callbacks get invoked ..." + "\033[49m\n");
})

4 changes: 3 additions & 1 deletion examples/3_get_return_values.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var canvas = ncc(function (err, canvas) {
// --- INFO ---
// 'val' is whatever the function-call would have returned directly in the browser

console.log("\n\033[46m\t" + "textWidth: '" + val.width + "'" + "\033[49m\n");

canvas.width = val.width;
canvas.height = 22;

Expand All @@ -43,7 +45,7 @@ var canvas = ncc(function (err, canvas) {
return;
}

console.log("dataURL: '" + val.substring(0, 40) + "...' [length: " + val.length + "]");
console.log("\n\033[46m\t" + "dataURL: '" + val.substring(0, 40) + "...' [length: " + val.length + "]" + "\033[49m\n");
})
});
})
2 changes: 1 addition & 1 deletion examples/4_gradients_and_patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var canvas = ncc(function (err, canvas) {
return;
}

console.error("Tataa!");
console.error("\n\033[46m\t" + "Tataa!" + "\033[49m\n");
});
});

Expand Down
2 changes: 1 addition & 1 deletion examples/5_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var canvas = ncc(function (err, canvas) {
return;
}

console.error("Hi! My name is Stefan, but you can call me 'indus'!");
console.log("\n\033[46m\t" + "Hi! My name is Stefan, but you can call me 'indus'!" + "\033[49m\n");
});
}

Expand Down
10 changes: 4 additions & 6 deletions examples/6_shadow_canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ncc(function (err, canvas_main) {

ctx_main.save()
ctx_main.translate(128, 128);
ctx_main.rotate(Math.PI / 180 * 45);
ctx_main.rotate(Math.PI / 180 * 45)();
ctx_main.translate(-75, -75);

ctx_main.drawImage(canvas_shadow, 0, 0)
Expand All @@ -49,18 +49,16 @@ ncc(function (err, canvas_main) {

// --- INFO ---
// to give garbage collection a chance you should nullify all proxy-objects (image, canvas, etc.) that are no longer in use
// do not forget to call the hidden function '_null()' before setting them to 'null'
// every proxy-object has a hidden attribute '_remote' taht has to be set to 'null' explicitly:

canvas_shadow._null()
canvas_shadow = null;
canvas_shadow = canvas_shadow._remote = null;

ctx_main(function (err, res) {
if (err) {
console.error("shadow canvas Error:", err);
return;
}

console.error("Tataa!");
console.log("\n\033[46m\t" + "Tataa!" + "\033[49m\n");
})

// --- INFO ---
Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
module.exports = require('./lib/ncc');
/*!
* ncc v0.2.x
*
* Copyright 2014 Stefan Keim (indus)
* Released under the MIT license
* https://github.com/indus/ncc/blob/master/license.md
*
* Date: 2014-05-13
*/

module.exports = require('./lib/ncc');
Loading

0 comments on commit 2940a59

Please sign in to comment.