Socket
Socket
Sign inDemoInstall

chem

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chem - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

Cokefile

337

lib/chem.js

@@ -1,13 +0,7 @@

// Generated by CoffeeScript 1.3.3
var all_out_files, animations_json_out, chemPath, chemfile_path, client_out, cmpStr, compileClientSource, compilerFromPath, compilers, createSpritesheet, exec, extend, filesFromAnimFrames, forceRequire, forceRequireChemfile, fs, getAllImgFiles, getChemfilePath, img_path, path, serveStaticFiles, sign, spawn, spritesheet_out, tasks, userPath, util, walk, watchFiles, watchSpritesheet, watchers,
__slice = [].slice;
var fs, path, util, spawn, watchFilesOnce, compilers, compilerFromPath, chemfile_path, getChemfilePath, forceRequireChemfile, chemPath, userPath, client_out, img_path, spritesheet_out, animations_json_out, all_out_files, sign, exec, compileClientSource, serveStaticFiles, watchSpritesheet, forceRequire, walk, cmpStr, getAllImgFiles, filesFromAnimFrames, createSpritesheet, tasks, run, __out = typeof exports != 'undefined' && exports || this;
fs = require('fs');
path = require('path');
util = require('util');
spawn = require("child_process").spawn;
spawn = require('child_process').spawn;
watchFilesOnce = require('./watch').watchFilesOnce;
compilers = {

@@ -27,6 +21,5 @@ '.coffee': {

};
compilerFromPath = function(filepath) {
compilerFromPath = function(filepath){
var ext;
if (!(filepath != null)) {
if (filepath == null) {
return null;

@@ -37,6 +30,4 @@ }

};
chemfile_path = null;
getChemfilePath = function() {
getChemfilePath = function(){
var chemfile_compiler;

@@ -46,7 +37,6 @@ if (chemfile_path != null) {

}
chemfile_path = (function() {
var file, _i, _len, _ref;
_ref = fs.readdirSync(userPath("."));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
file = _ref[_i];
chemfile_path = function(){
var file, __i, __ref, __len;
for (__i = 0, __len = (__ref = fs.readdirSync(userPath("."))).length; __i < __len; ++__i) {
file = __ref[__i];
if (file.indexOf("chemfile.") === 0) {

@@ -57,4 +47,4 @@ return file;

return null;
})();
if (!((chemfile_compiler = compilerFromPath(chemfile_path)) != null)) {
}();
if ((chemfile_compiler = compilerFromPath(chemfile_path)) == null) {
console.error("Missing chemfile or unrecognized chemfile extension.");

@@ -69,4 +59,3 @@ process.exit(-1);

};
forceRequireChemfile = function() {
forceRequireChemfile = function(){
var chem_path, req_path;

@@ -77,38 +66,17 @@ chem_path = path.resolve(getChemfilePath());

};
chemPath = function(file) {
chemPath = function(file){
return path.join(path.dirname(fs.realpathSync(__filename)), "..", file);
};
userPath = function(file) {
userPath = function(file){
return path.join(process.cwd(), file);
};
client_out = userPath("./public/main.js");
img_path = userPath("./assets/img");
spritesheet_out = userPath("./public/spritesheet.png");
animations_json_out = userPath("./public/animations.json");
all_out_files = [client_out, spritesheet_out, animations_json_out];
extend = function() {
var arg, args, obj, prop, val, _i, _len;
obj = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
for (prop in arg) {
val = arg[prop];
obj[prop] = val;
}
}
return obj;
};
sign = function(n) {
if (n > 0) {
sign = function(it){
if (it > 0) {
return 1;
} else if (n < 0) {
} else if (it < 0) {
return -1;

@@ -119,40 +87,33 @@ } else {

};
exec = function(cmd, args, cb) {
exec = function(cmd, args, cb){
var bin;
if (args == null) {
args = [];
}
if (cb == null) {
cb = function() {};
}
args == null && (args = []);
cb == null && (cb = function(){});
bin = spawn(cmd, args);
bin.stdout.on('data', function(data) {
return process.stdout.write(data);
bin.stdout.on('data', function(data){
process.stdout.write(data);
});
bin.stderr.on('data', function(data) {
return process.stderr.write(data);
bin.stderr.on('data', function(data){
process.stderr.write(data);
});
return bin.on('exit', cb);
bin.on('exit', cb);
};
compileClientSource = function(options) {
var compile, l, libs, main, _ref;
compileClientSource = function(options){
var compile, libs, main, l, __ref;
compile = require('jspackage').compile;
_ref = forceRequireChemfile(), libs = _ref.libs, main = _ref.main;
__ref = forceRequireChemfile(), libs = __ref.libs, main = __ref.main;
options.mainfile = userPath(main);
options.libs = ((function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = libs.length; _i < _len; _i++) {
l = libs[_i];
_results.push(userPath(l));
options.libs = (function(){
var __i, __ref, __len, __results = [];
for (__i = 0, __len = (__ref = libs).length; __i < __len; ++__i) {
l = __ref[__i];
__results.push(userPath(l));
}
return _results;
})()).concat([chemPath("./src/shared/"), chemPath("./src/client/")]);
return compile(options, function(err, compiled_code) {
return __results;
}()).concat([chemPath("./src/shared/"), chemPath("./src/client/")]);
compile(options, function(err, compiled_code){
var timestamp;
if (err) {
timestamp = (new Date()).toLocaleTimeString();
console.error("" + timestamp + " - error: " + err);
timestamp = new Date().toLocaleTimeString();
console.error(timestamp + " - error: " + err);
return;

@@ -163,5 +124,4 @@ }

};
serveStaticFiles = function(port) {
var app, file_server, http, node_static, public_dir;
serveStaticFiles = function(port){
var node_static, http, public_dir, file_server, app;
node_static = require('node-static');

@@ -171,43 +131,20 @@ http = require('http');

file_server = new node_static.Server(public_dir);
app = http.createServer(function(request, response) {
return file_server.serve(request, response);
app = http.createServer(function(request, response){
file_server.serve(request, response);
});
app.listen(port);
return console.info("Serving at http://localhost:" + port);
console.info("Serving at http://0.0.0.0:" + port);
};
watchers = [];
watchFiles = function(files, cb) {
var file, success, watcher, _i, _j, _len, _len1;
for (_i = 0, _len = watchers.length; _i < _len; _i++) {
watcher = watchers[_i];
watcher.close();
}
watchers = [];
success = true;
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
file = files[_j];
try {
watchers.push(fs.watch(file, cb));
} catch (error) {
console.error("Image file not found: " + file);
success = false;
}
}
return success;
};
watchSpritesheet = function() {
watchSpritesheet = function(){
var recompile, rewatch;
recompile = function() {
recompile = function(){
var timestamp;
createSpritesheet();
timestamp = (new Date()).toLocaleTimeString();
console.info("" + timestamp + " - generated " + spritesheet_out);
return console.info("" + timestamp + " - generated " + animations_json_out);
timestamp = new Date().toLocaleTimeString();
console.info(timestamp + " - generated " + spritesheet_out);
console.info(timestamp + " - generated " + animations_json_out);
};
rewatch = function() {
var all_img_files, anim, animations, file, files, name, success, watch_files, _i, _len;
watch_files = [];
rewatch = function(){
var watch_files, animations, all_img_files, success, name, anim, files, file, __i, __len;
watch_files = [getChemfilePath()];
animations = forceRequireChemfile().animations;

@@ -224,16 +161,15 @@ all_img_files = getAllImgFiles();

}
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
for (__i = 0, __len = files.length; __i < __len; ++__i) {
file = files[__i];
watch_files.push(path.join(img_path, file));
}
}
if (watchFiles(watch_files, recompile) && success) {
return recompile();
watchFilesOnce(watch_files, rewatch);
if (success) {
recompile();
}
};
fs.watch(getChemfilePath(), rewatch);
return rewatch();
rewatch();
};
forceRequire = function(module_path) {
forceRequire = function(module_path){
var resolved_path;

@@ -244,12 +180,9 @@ resolved_path = require.resolve(module_path);

};
walk = function(dir) {
var processDir, results;
walk = function(dir){
var results, processDir;
results = [];
processDir = function(full_path, part_path) {
var file, full_file, part_file, stat, _i, _len, _ref, _results;
_ref = fs.readdirSync(full_path);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
file = _ref[_i];
processDir = function(full_path, part_path){
var file, full_file, part_file, stat, __i, __ref, __len;
for (__i = 0, __len = (__ref = fs.readdirSync(full_path)).length; __i < __len; ++__i) {
file = __ref[__i];
full_file = path.join(full_path, file);

@@ -259,8 +192,7 @@ part_file = path.join(part_path, file);

if (stat.isDirectory()) {
_results.push(processDir(full_file, part_file));
processDir(full_file, part_file);
} else {
_results.push(results.push(part_file));
results.push(part_file);
}
}
return _results;
};

@@ -270,4 +202,3 @@ processDir(dir, "");

};
cmpStr = function(a, b) {
cmpStr = function(a, b){
if (a < b) {

@@ -281,24 +212,17 @@ return -1;

};
getAllImgFiles = function() {
getAllImgFiles = function(){
return walk(img_path);
};
filesFromAnimFrames = function(frames, anim_name, all_img_files) {
var files, img;
if (frames == null) {
frames = anim_name;
}
filesFromAnimFrames = function(frames, anim_name, all_img_files){
var img, files, __res, __i, __len;
frames == null && (frames = anim_name);
if (typeof frames === 'string') {
files = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = all_img_files.length; _i < _len; _i++) {
img = all_img_files[_i];
if (img.indexOf(frames) === 0) {
_results.push(img);
}
__res = [];
for (__i = 0, __len = all_img_files.length; __i < __len; ++__i) {
img = all_img_files[__i];
if (img.indexOf(frames) === 0) {
__res.push(img);
}
return _results;
})();
}
files = __res;
files.sort(cmpStr);

@@ -310,33 +234,32 @@ return files;

};
createSpritesheet = function() {
var Canvas, Image, Spritesheet, Vec2d, all_img_files, anim, animations, canvas, context, file, files, frame, frame_list, image, name, out, sheet, stream, _default, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
Canvas = require('canvas');
Image = Canvas.Image;
createSpritesheet = function(){
var Canvas, Image, Vec2d, Spritesheet, animations, defaults, frame_list, all_img_files, seen, name, anim, files, file, frame, image, sheet, canvas, context, out, stream, __ref, __i, __len;
Image = (Canvas = require('canvas')).Image;
Vec2d = require(chemPath('./lib/vec2d')).Vec2d;
Spritesheet = require(chemPath('./lib/spritesheet')).Spritesheet;
_ref = forceRequireChemfile(), _default = _ref._default, animations = _ref.animations;
__ref = forceRequireChemfile().spritesheet, animations = __ref.animations, defaults = __ref.defaults;
frame_list = [];
all_img_files = getAllImgFiles();
seen = {};
for (name in animations) {
anim = animations[name];
animations[name] = anim = extend({}, _default, anim);
animations[name] = anim = __import(__import({}, defaults), anim);
files = filesFromAnimFrames(anim.frames, name, all_img_files);
anim.frames = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
image = new Image();
image.src = fs.readFileSync(path.join(img_path, file));
frame = {
image: image,
size: new Vec2d(image.width, image.height),
filename: file,
pos: new Vec2d(0, 0)
};
frame_list.push(frame);
for (__i = 0, __len = files.length; __i < __len; ++__i) {
file = files[__i];
if ((frame = seen[file]) == null) {
image = new Image();
image.src = fs.readFileSync(path.join(img_path, file));
seen[file] = frame = {
image: image,
size: new Vec2d(image.width, image.height),
filename: file,
pos: new Vec2d(0, 0)
};
frame_list.push(frame);
}
anim.frames.push(frame);
}
if (anim.anchor === "center") {
anim.anchor = anim.frames[0].size.scaled(0.5).floor();
}
anim.anchor = (__fn());
}

@@ -347,4 +270,4 @@ sheet = new Spritesheet(frame_list);

context = canvas.getContext('2d');
for (_j = 0, _len1 = frame_list.length; _j < _len1; _j++) {
frame = frame_list[_j];
for (__i = 0, __len = frame_list.length; __i < __len; ++__i) {
frame = frame_list[__i];
context.drawImage(frame.image, frame.pos.x, frame.pos.y);

@@ -354,3 +277,3 @@ }

stream = canvas.createPNGStream();
stream.on('data', function(chunk) {
stream.on('data', function(chunk){
return out.write(chunk);

@@ -360,5 +283,4 @@ });

anim = animations[name];
_ref1 = anim.frames;
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
frame = _ref1[_k];
for (__i = 0, __len = (__ref = anim.frames).length; __i < __len; ++__i) {
frame = __ref[__i];
delete frame.image;

@@ -368,14 +290,29 @@ delete frame.filename;

}
return fs.writeFileSync(animations_json_out, JSON.stringify(animations, null, 4), 'utf8');
fs.writeFileSync(animations_json_out, JSON.stringify(animations, null, 4), 'utf8');
function __fn(){
switch (anim.anchor) {
case 'center':
return anim.frames[0].size.scaled(0.5).floor();
case 'topleft':
return new Vec2d(0, 0);
case 'topright':
return new Vec2d(anim.frames[0].size.x, 0);
case 'bottomleft':
return new Vec2d(0, anim.frames[0].size.y);
case 'bottomright':
return anim.frames[0].size;
default:
return anim.anchor;
}
}
};
tasks = {
help: function() {
return process.stderr.write("Usage: \n\n # create a new project\n chem init <your_project_name> [<template_name>]\n # possible templates are: empty, meteor\n\n # run a development server which will automatically recompile your code,\n # generate your spritesheets, and serve your assets\n chem dev\n");
help: function(){
process.stderr.write("Usage: \n\n # create a new project\n # possible templates are: meteor, readme\n \n chem init <your_project_name> [<template>]\n\n\n # run a development server which will automatically recompile your code,\n # generate your spritesheets, and serve your assets\n \n chem dev\n");
},
init: function(args) {
var project_name, src, template;
init: function(args){
var project_name, template, src;
project_name = args[0];
template = args[1] || "meteor";
if (!(project_name != null)) {
if (project_name == null) {
tasks.help();

@@ -386,5 +323,5 @@ process.exit(1);

src = chemPath("templates/" + template);
return exec('cp', ['-r', src, project_name]);
exec('cp', ['-r', src, project_name]);
},
dev: function(args, options) {
dev: function(args, options){
serveStaticFiles(options.port || 10308);

@@ -394,10 +331,9 @@ compileClientSource({

});
return watchSpritesheet();
watchSpritesheet();
},
clean: function() {
return exec('rm', ['-f'].concat(all_out_files));
clean: function(){
exec('rm', ['-f'].concat(all_out_files));
}
};
exports.run = function() {
__out.run = run = function(){
var cmd, task;

@@ -407,6 +343,11 @@ cmd = process.argv[2];

if (task != null) {
return task(process.argv.slice(3), {});
task(process.argv.slice(3), {});
} else {
return tasks.help([], {});
tasks.help([], {});
}
};
function __import(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}

@@ -1,3 +0,2 @@

// Generated by CoffeeScript 1.3.3
exports.Vec2d = require('./vec2d').Vec2d;
var __out = typeof exports != 'undefined' && exports || this;
__out.Vec2d = require('./vec2d').Vec2d;

@@ -1,7 +0,4 @@

// Generated by CoffeeScript 1.3.3
var Spritesheet, Vec2d, byReverseHeightThenFilename, byXThenY;
var Vec2d, byReverseHeightThenFilename, byXThenY, Spritesheet, __out = typeof exports != 'undefined' && exports || this;
Vec2d = require('./vec2d').Vec2d;
byReverseHeightThenFilename = function(a, b) {
byReverseHeightThenFilename = function(a, b){
var diff;

@@ -19,4 +16,3 @@ diff = b.size.y - a.size.y;

};
byXThenY = function(a, b) {
byXThenY = function(a, b){
var diff;

@@ -30,47 +26,17 @@ diff = a.x - b.x;

};
exports.Spritesheet = Spritesheet = (function() {
function Spritesheet(image_list) {
__out.Spritesheet = Spritesheet = (function(){
Spritesheet.displayName = 'Spritesheet';
var prototype = Spritesheet.prototype, constructor = Spritesheet;
function Spritesheet(image_list){
this.image_list = image_list;
}
Spritesheet.prototype.calculatePositions = function() {
var image, image_i, positions, x, y, _i, _len, _ref, _results,
_this = this;
prototype.calculatePositions = function(){
var positions, image_i, image, y, x, __ref, __len, __this = this;
this.image_list.sort(byReverseHeightThenFilename);
this.size = new Vec2d();
positions = [];
_ref = this.image_list;
_results = [];
for (image_i = _i = 0, _len = _ref.length; _i < _len; image_i = ++_i) {
image = _ref[image_i];
for (image_i = 0, __len = (__ref = this.image_list).length; image_i < __len; ++image_i) {
image = __ref[image_i];
positions.sort(byXThenY);
image.pos = (function() {
var intersects, pos, pos_i, _j, _len1;
for (pos_i = _j = 0, _len1 = positions.length; _j < _len1; pos_i = ++_j) {
pos = positions[pos_i];
intersects = (function() {
var i, placed, _k;
if (pos.x + image.size.x >= _this.size.x) {
return true;
}
if (pos.y + image.size.y >= _this.size.y) {
return true;
}
for (i = _k = 0; 0 <= image_i ? _k < image_i : _k > image_i; i = 0 <= image_i ? ++_k : --_k) {
placed = _this.image_list[i];
if (!(placed.pos.x + placed.size.x <= pos.x || placed.pos.x >= pos.x + image.size.x || placed.pos.y + placed.size.y <= pos.y || placed.pos.y >= pos.y + image.size.y)) {
return true;
}
}
return false;
})();
if (!intersects) {
positions.splice(pos_i, 1);
return pos;
}
}
return new Vec2d(_this.size.x, 0);
})();
image.pos = __fn();
if ((y = image.pos.y + image.size.y) < this.size.y) {

@@ -82,9 +48,34 @@ positions.push(new Vec2d(image.pos.x, y));

}
_results.push(this.size.boundMin(image.pos.plus(image.size)));
this.size.boundMin(image.pos.plus(image.size));
}
return _results;
function __fn(){
var pos_i, pos, intersects, __ref, __len;
for (pos_i = 0, __len = (__ref = positions).length; pos_i < __len; ++pos_i) {
pos = __ref[pos_i];
intersects = __fn();
if (!intersects) {
positions.splice(pos_i, 1);
return pos;
}
}
return new Vec2d(__this.size.x, 0);
function __fn(){
var i, placed, __to;
if (pos.x + image.size.x >= __this.size.x) {
return true;
}
if (pos.y + image.size.y >= __this.size.y) {
return true;
}
for (i = 0, __to = image_i; i < __to; ++i) {
placed = __this.image_list[i];
if (!(placed.pos.x + placed.size.x <= pos.x || placed.pos.x >= pos.x + image.size.x || placed.pos.y + placed.size.y <= pos.y || placed.pos.y >= pos.y + image.size.y)) {
return true;
}
}
return false;
}
}
};
return Spritesheet;
})();
}());

@@ -1,9 +0,9 @@

// Generated by CoffeeScript 1.3.3
var Vec2d, _exports;
_exports = typeof exports !== "undefined" && exports !== null ? exports : (window.Chem || (window.Chem = {}));
_exports.Vec2d = Vec2d = (function() {
function Vec2d(x_or_pair, y) {
_exports = typeof exports != 'undefined' && exports !== null
? exports
: window.Chem || (window.Chem = {});
_exports.Vec2d = Vec2d = (function(){
Vec2d.displayName = 'Vec2d';
var prototype = Vec2d.prototype, constructor = Vec2d;
function Vec2d(x_or_pair, y){
if (y != null) {

@@ -25,8 +25,6 @@ this.x = x_or_pair;

}
Vec2d.prototype.offset = function(dx, dy) {
prototype.offset = function(dx, dy){
return new Vec2d(this.x + dx, this.y + dy);
};
Vec2d.prototype.add = function(other) {
prototype.add = function(other){
this.x += other.x;

@@ -36,4 +34,3 @@ this.y += other.y;

};
Vec2d.prototype.sub = function(other) {
prototype.sub = function(other){
this.x -= other.x;

@@ -43,12 +40,9 @@ this.y -= other.y;

};
Vec2d.prototype.plus = function(other) {
prototype.plus = function(other){
return this.clone().add(other);
};
Vec2d.prototype.minus = function(other) {
prototype.minus = function(other){
return this.clone().sub(other);
};
Vec2d.prototype.neg = function() {
prototype.neg = function(){
this.x = -this.x;

@@ -58,4 +52,3 @@ this.y = -this.y;

};
Vec2d.prototype.mult = function(other) {
prototype.mult = function(other){
this.x *= other.x;

@@ -65,8 +58,6 @@ this.y *= other.y;

};
Vec2d.prototype.times = function(other) {
prototype.times = function(other){
return this.clone().mult(other);
};
Vec2d.prototype.scale = function(scalar) {
prototype.scale = function(scalar){
this.x *= scalar;

@@ -76,12 +67,9 @@ this.y *= scalar;

};
Vec2d.prototype.scaled = function(scalar) {
prototype.scaled = function(scalar){
return this.clone().scale(scalar);
};
Vec2d.prototype.clone = function() {
prototype.clone = function(){
return new Vec2d(this.x, this.y);
};
Vec2d.prototype.apply = function(func) {
prototype.apply = function(func){
this.x = func(this.x);

@@ -91,8 +79,6 @@ this.y = func(this.y);

};
Vec2d.prototype.applied = function(func) {
prototype.applied = function(func){
return this.clone().apply(func);
};
Vec2d.prototype.distanceTo = function(other) {
prototype.distanceTo = function(other){
var dx, dy;

@@ -103,21 +89,16 @@ dx = other.x - this.x;

};
Vec2d.prototype.equals = function(other) {
prototype.equals = function(other){
return this.x === other.x && this.y === other.y;
};
Vec2d.prototype.toString = function() {
prototype.toString = function(){
return "(" + this.x + ", " + this.y + ")";
};
Vec2d.prototype.lengthSqrd = function() {
prototype.lengthSqrd = function(){
return this.x * this.x + this.y * this.y;
};
Vec2d.prototype.length = function() {
prototype.length = function(){
return Math.sqrt(this.lengthSqrd());
};
Vec2d.prototype.angle = function() {
if (this.lengthSqrd === 0) {
prototype.angle = function(){
if (this.lengthSqrd() === 0) {
return 0;

@@ -128,4 +109,3 @@ } else {

};
Vec2d.prototype.normalize = function() {
prototype.normalize = function(){
var length;

@@ -139,8 +119,6 @@ length = this.length();

};
Vec2d.prototype.normalized = function() {
prototype.normalized = function(){
return this.clone().normalize();
};
Vec2d.prototype.boundMin = function(other) {
prototype.boundMin = function(other){
if (this.x < other.x) {

@@ -153,4 +131,3 @@ this.x = other.x;

};
Vec2d.prototype.boundMax = function(other) {
prototype.boundMax = function(other){
if (this.x > other.x) {

@@ -163,21 +140,16 @@ this.x = other.x;

};
Vec2d.prototype.floor = function() {
prototype.floor = function(){
return this.apply(Math.floor);
};
Vec2d.prototype.floored = function() {
prototype.floored = function(){
return this.applied(Math.floor);
};
Vec2d.prototype.project = function(other) {
prototype.project = function(other){
this.scale(this.dot(other) / other.lengthSqrd());
return this;
};
Vec2d.prototype.dot = function(other) {
prototype.dot = function(other){
return this.x * other.x + this.y * other.y;
};
Vec2d.prototype.rotate = function(other) {
prototype.rotate = function(other){
this.x = this.x * other.x - this.y * other.y;

@@ -187,13 +159,9 @@ this.y = this.x * other.y + this.y * other.x;

};
Vec2d.prototype.distanceSqrd = function(other) {
prototype.distanceSqrd = function(other){
return Math.pow(this.x - other.x, 2) + Math.pow(this.y - other.y, 2);
};
Vec2d.prototype.distance = function(other) {
prototype.distance = function(other){
return Math.sqrt(this.distanceSqrd(other));
};
return Vec2d;
})();
}());

@@ -5,3 +5,3 @@ {

"author": "Andrew Kelley <superjoe30@gmail.com>",
"version": "0.0.1",
"version": "0.0.2",
"licenses": [{

@@ -25,4 +25,7 @@ "type": "MIT",

"devDependencies": {
"coffee-script": "~1.3.3"
"coco": "~0.7.6"
},
"scripts": {
"dev": "npm install . && coke watch"
},
"bin": {

@@ -29,0 +32,0 @@ "chem": "./bin/chem"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc