mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-11-02 04:37:30 +08:00
Move assert helper to utility
This commit is contained in:
6
lib/assert.js
Normal file
6
lib/assert.js
Normal file
@ -0,0 +1,6 @@
|
||||
this.assert = function(condition, message) {
|
||||
if (!condition) {
|
||||
console.error(message);
|
||||
throw new Error;
|
||||
}
|
||||
}
|
||||
@ -3,14 +3,6 @@ var MIN_CORNER_ANGLE = 0.1*Math.PI;
|
||||
var MIN_CORNER_TANGENT_DISTANCE = 4;
|
||||
var REVERSAL_PENALTY = 0.5;
|
||||
|
||||
// Error out if the condition does not hold.
|
||||
function assert(condition, message) {
|
||||
if (!condition) {
|
||||
console.error(message);
|
||||
throw new Error;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper methods for use with angles, which are floats in [-pi, pi).
|
||||
var Angle = {
|
||||
subtract: function(angle1, angle2) {
|
||||
@ -28,7 +20,7 @@ var Angle = {
|
||||
},
|
||||
};
|
||||
|
||||
// Helper methods for use with "points", which are just pairs of integers.
|
||||
// Helper methods for use with "points", which are pairs of integers.
|
||||
var Point = {
|
||||
angle: function(point) {
|
||||
return Math.atan2(point[1], point[0]);
|
||||
|
||||
@ -1,10 +1,3 @@
|
||||
function assert(condition, message) {
|
||||
if (!condition) {
|
||||
console.log(message);
|
||||
throw new Error;
|
||||
}
|
||||
}
|
||||
|
||||
function get_final_bridges(glyph, original_bridges) {
|
||||
var set = {};
|
||||
var result = original_bridges.concat(glyph.manual.bridges_added);
|
||||
|
||||
Reference in New Issue
Block a user