diff options
| author | Jules <jules@asdf.us> | 2015-05-24 18:36:43 -0400 |
|---|---|---|
| committer | Jules <jules@asdf.us> | 2015-05-24 18:36:43 -0400 |
| commit | 1693c54b393ac75f4711f47e702ef819e59c4557 (patch) | |
| tree | 12659cb1450754ee8d8dfe19b4e8adf4c2fef9c5 | |
| parent | 4d59003edf6e50c399b024d83d12f0e1f8da0193 (diff) | |
| parent | 4da580e1a1a9a86c826fd403da8031cea2bc3a96 (diff) | |
Merge branch 'master' of asdf.us:ascii
| -rw-r--r-- | js/blit.js | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -47,11 +47,26 @@ var blit = (function(){ } }) } + var distance_rect = function(x, y, ratio){ + return Math.sqrt((Math.pow(y * ratio, 2)) + Math.pow(x, 2)) + } + var distance_square = function(x, y, ratio){ + return Math.sqrt((Math.pow(y * ratio, 2)) + Math.pow(x * ratio, 2)) + } blit.circle = function(A, lex){ - var hw = brush.w/2|0, hh = brush.h/2|0 + var hw = brush.w/2, hh = brush.h/2 + var ratio, distance + + if (brush.w === brush.h){ + distance = distance_square + ratio = hw / hh * (brush.w === 3 || brush.w === 5 ? 1.2 : 1.05) + } else { + distance = distance_rect + ratio = hw / hh + } + A.forEach(function(lex,x,y) { - var len = Math.sqrt(Math.pow(x-hw,2)+Math.pow(y-hh,2)) - if (len > Math.abs(hw)) { + if (distance(x - hw + 0.5, y - hh + 0.5, ratio) > hw){ lex.clear() } }) |
