Skip to content

Commit

Permalink
bower power
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Jun 4, 2014
1 parent 612a50f commit e786a74
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 4 deletions.
10 changes: 10 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "cg",
"version": "0.1.0",
"description" : "cg (computational geometry) algorithms templates for JavaScript",
"homepage": "https://github.com/aureooms/cg",
"moduleType": [
"node"
],
"license": "GPL v2"
}
54 changes: 54 additions & 0 deletions js/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var opt = {
ns : 'cg',
src : __dirname + '/src/',
out : __dirname + '/dist/'
};



// == GENERIC ==

var fs = require('fs');
var util = require('util');
var fmt = util.format;
var recbuild_t = require('recbuild');
var UglifyJS = require("uglify-js");


var recbuild = recbuild_t({
name : opt.ns,
rec : false,
flat : true
});


if (!fs.existsSync(opt.out)) fs.mkdirSync(opt.out);

var fd,
base = fmt('%s/%s%%s', opt.out, opt.ns),
concat = fmt(base, '.js'),
min = fmt(base, '.min.js'),
map = fmt(base, '.js.map');

var fhandle = function(f) {
var raw = fs.readFileSync(f);
fs.writeSync(fd, raw.toString());
fs.writeSync(fd, '\n');
};

var rhandle = function(raw) {
fs.writeSync(fd, raw);
fs.writeSync(fd, '\n');
};



fd = fs.openSync(concat, 'w');
recbuild(opt.src, opt.ns, -1, fhandle, rhandle);
fs.closeSync(fd);


var minified = UglifyJS.minify(concat, { outSourceMap: map });

fs.writeFileSync(min, minified.code);
fs.writeFileSync(map, minified.map);
40 changes: 40 additions & 0 deletions js/dist/cg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(function(exports){

'use strict';


/* /home/genius/Bureau/cg/js/src/2d */
/* /home/genius/Bureau/cg/js/src/2d/sin_sign.js */

/**
* Computes the cross product of _ab_ and _ac_,
* can be interpreted as the sinus sign in a "right-handed" coordinate system
* (i.e. clockwise angle values).
*
* <p>
* Originally implemented as
*
* a[1] * (c[0] - b[0]) + b[1] * (a[0] - c[0]) + c[1] * (b[0] - a[0])
*
* with
* - 2 add
* - 3 sub
* - 3 mul
*
* Reduced to
*
* (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])
*
* with
* - 5 sub
* - 2 mul
*
*/

var sin_sign = function(a, b, c){
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
};


exports.sin_sign = sin_sign;
})(typeof exports === 'undefined' ? this['cg'] = {} : exports);
1 change: 1 addition & 0 deletions js/dist/cg.js.map

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

1 change: 1 addition & 0 deletions js/dist/cg.min.js

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

1 change: 0 additions & 1 deletion js/src/0000 intro.js

This file was deleted.

1 change: 0 additions & 1 deletion js/src/9999 outro.js

This file was deleted.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
"name": "cg",
"version": "0.1.0",
"description": "cg (computational geometry) algorithms templates for JavaScript",
"main": "js/index.js",
"main": "dist/cg.js",
"dependencies": {
"recquire": "~0.1.0"
},
"devDependencies": {
"qunit": "git://github.com/gotwarlost/node-qunit.git#istanbul-coverage",
"coveralls": "^2.10.0"
"coveralls": "^2.10.0",
"uglify-js": "^2.4.13"
},
"scripts": {
"build": "node js/build.js",
"test": "export DIR=node_modules/qunit/support/qunit/qunit && mkdir -p $DIR && cp support/qunit.js $DIR/ && node test/js/run.js"
},
"repository": {
Expand Down

0 comments on commit e786a74

Please sign in to comment.