Skip to content

Commit

Permalink
revisit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan committed May 15, 2017
1 parent e5b7823 commit 9983716
Show file tree
Hide file tree
Showing 13 changed files with 2,790 additions and 2,404 deletions.
63 changes: 0 additions & 63 deletions .gitattributes

This file was deleted.

172 changes: 26 additions & 146 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,157 +1,37 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
# Logs
logs
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
*.sln

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
npm-debug.log*

# RIA/Silverlight projects
Generated_Code/
# Runtime data
pids
*.pid
*.seed

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# =========================
# Windows detritus
# =========================
# node-waf configuration
.lock-wscript

# Windows image file caches
Thumbs.db
ehthumbs.db
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Folder config file
Desktop.ini
# Dependency directories
node_modules
jspm_packages

# Recycle Bin used on file shares
$RECYCLE.BIN/
# Optional npm cache directory
.npm

# Mac desktop service store files
.DS_Store
# Optional REPL history
.node_repl_history
45 changes: 13 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ var ctx = canvas.getContext('2d');
ctx.fillStyle = "slateGray";
ctx.fillRect(28, 28, 200, 200)(); // function call is intentional!
```
this gives you an error on startup? check out [startup-errors](https://github.com/indus/ncc#startup-errors)

### Examples

1. **[draw ncc logo](https://github.com/indus/ncc/blob/master/examples/1_draw_ncc_logo.js)**
>>> **learn** how to setup ncc and draw shapes to canvas
2. **[early access](https://github.com/indus/ncc/blob/master/examples/2_early_access.js)**
>>> **learn** how to start using ncc even before it is fully set up
3. **[get return values](https://github.com/indus/ncc/blob/master/examples/3_get_return_values.js)**
>>> **learn** how to get return values of non-void functions
4. **[gardients/patterns](https://github.com/indus/ncc/blob/master/examples/4_gradients_and_patterns.js)**
>>> **learn** how to use gradients and patterns
5. **[images](https://github.com/indus/ncc/blob/master/examples/5_images.js)**
>>> **learn** how to apply images from urls or the filesystem
6. **[shadow canvas](https://github.com/indus/ncc/blob/master/examples/6_shadow_canvas.js)**
>>> **learn** how work with more than one canvas
Expand All @@ -52,7 +58,7 @@ this gives you an error on startup? check out [startup-errors](https://github.co
... as close as possible.

Differences are a result of the asynchronous nature of **ncc**. All object creations, method calls and property manipulations don't get processed directly, but get serialized and stored until a return value is necessary and a request is therefore unavoidable.
Every 'Object' provided by **ncc** (and also every of their methods returns) is actually a function to trigger a synchronization. You can pass a error-first-callback ( 'function(error, result){...}' ) to such a function to receive the return value of the last action (see [examples](https://github.com/indus/ncc#examples)).
Every 'Object' provided by **ncc** (and also every return value of a method) is actually a function to trigger a synchronization. You can pass a error-first-callback ( 'function(error, result){...}' ) to such a function to receive the return value of the last action (see [examples](https://github.com/indus/ncc#examples)).
<p align="center">
<img src="https://raw.githubusercontent.com/indus/ncc/master/footage/flow.png" alt="flowchart"/>
</p>
Expand All @@ -66,7 +72,7 @@ Methods and properties beyond the native API are marked with a leading underscor
* **ncc(** &lt;options&gt; **,** &lt;callback&gt; **)** >>> **[canvas]**
**ncc(** &lt;callback&gt; **)** >>> **[canvas]**

* **ncc.createCanvas()** >>> **[canvas]**
* **ncc.createCanvas()** >>> **[canvas]** *if one is not enough*

* **ncc.createImage(** &lt;src&gt; **,** &lt;onloadFn&gt; **,** &lt;onerrorFn&gt; **)** >>> **[image]**

Expand All @@ -78,35 +84,10 @@ Methods and properties beyond the native API are marked with a leading underscor

#### options (with defaults)
```javascript
{ logLevel: 2,
{ logLevel: 'info', //['log','info','warn','error']
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: 9,
retryDelay: 500,
headless: false
}
```
### startup-errors
**ncc** is preconfigured to start a chrome childprocess on a Windows system with a default Chrome installation. If you are facing problems getting **ncc** started (especially on a non-windows system) you should make changes to the 'spawn'-[options](https://github.com/indus/ncc#options). If you are not sure what options you need, you can 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);

chrome.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});

chrome.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});

chrome.on('close', function (code) {
console.log('child process exited with code ' + code);
});
```
20 changes: 6 additions & 14 deletions examples/1_draw_ncc_logo.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
// NCC Example 1 - draw ncc logo

var ncc = require('ncc');
var ncc = require('../index.js'); // require('ncc');

console.time("ncc startup time");

// --- INFO ---
// ncc uses error-first callbacks

ncc(function (err, canvas) {
ncc({ logLevel: 'log' }, function (err, canvas) {

// --- INFO ---
// if you see errors you probably have to call 'ncc' with options
//
// 'ncc(<options>,<callback>)'

if (err) {
console.error("ncc startup Error:", err);
return;
}
if (err) throw err;

console.timeEnd("ncc startup time");
console.time("ncc draw time");
Expand Down Expand Up @@ -84,10 +76,10 @@ ncc(function (err, canvas) {
// to actually trigger the action and see a result you have to call a function:

ctx(function (err, ctx) {
if (err)
console.error("ncc draw Error:", err);
if (err) throw err;

console.timeEnd("ncc draw time");
console.log("\n\033[46m\t" + "Tataa!" + "\033[49m\n");
console.log("Tataa!");
})

// --- ALTERNATIVES ---
Expand Down
Loading

0 comments on commit 9983716

Please sign in to comment.