summaryrefslogtreecommitdiff
path: root/js/draw.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-04-04 13:31:15 +0200
committerJules Laplace <julescarbon@gmail.com>2018-04-04 13:31:15 +0200
commitb0ada80bc3a7882ac50c16188004e34061af5845 (patch)
treefc1315b3c9b78cfbd7be10f160210a38a03ad15d /js/draw.js
parent47fafe89da96e698782db86c00ddd25bebc9b623 (diff)
parent165bb4883c59a8b529c09b08bb75c9b3407c9c69 (diff)
Merge branch 'master' of lmno:ascii
Diffstat (limited to 'js/draw.js')
-rw-r--r--js/draw.js44
1 files changed, 40 insertions, 4 deletions
diff --git a/js/draw.js b/js/draw.js
index eb58a27..407e1c8 100644
--- a/js/draw.js
+++ b/js/draw.js
@@ -4,13 +4,32 @@ var draw = (function(){
var last_point = [0,0]
function down (e, lex, point) {
+ var w = canvas.w, h = canvas.h
erasing = (e.which == "3" || e.ctrlKey)
changed = true
if (e.shiftKey) {
line (lex, last_point, point, erasing)
+ if (mirror_x) {
+ line(lex, [w-last_point[0], last_point[1]], [w-point[0], point[1]], erasing)
+ }
+ if (mirror_y) {
+ line(lex, [last_point[0], h-last_point[1]], [point[0], h-point[1]], erasing)
+ }
+ if (mirror_x && mirror_y) {
+ line(lex, [w-last_point[0], h-last_point[1]], [w-point[0], h-point[1]], erasing)
+ }
}
else {
stamp (canvas, brush, point[0], point[1], erasing)
+ if (mirror_x) {
+ stamp (canvas, brush, w-point[0], point[1], erasing)
+ }
+ if (mirror_y) {
+ stamp (canvas, brush, point[0], h-point[1], erasing)
+ }
+ if (mirror_x && mirror_y) {
+ stamp (canvas, brush, w-point[0], h-point[1], erasing)
+ }
}
last_point[0] = point[0]
last_point[1] = point[1]
@@ -22,7 +41,18 @@ var draw = (function(){
}
function move (e, lex, point) {
+ var w = canvas.w, h = canvas.h
line(lex, last_point, point, erasing)
+ if (mirror_x) {
+ line(lex, [w-last_point[0], last_point[1]], [w-point[0], point[1]], erasing)
+ }
+ if (mirror_y) {
+ line(lex, [last_point[0], h-last_point[1]], [point[0], h-point[1]], erasing)
+ }
+ if (mirror_x && mirror_y) {
+ line(lex, [w-last_point[0], h-last_point[1]], [w-point[0], h-point[1]], erasing)
+ }
+
last_point[0] = point[0]
last_point[1] = point[1]
}
@@ -82,11 +112,17 @@ var draw = (function(){
}
else {
var last_point_mod = [], point_mod = []
- last_point_mod[0] = mod( last_point[0], w )
- last_point_mod[1] = mod( last_point[1], h )
- point_mod[0] = mod( point[0], w )
- point_mod[1] = mod( point[1], h )
+ var x_a = mod( last_point[0], w )
+ var y_a = mod( last_point[1], h )
+ var x_b = mod( point[0], w )
+ var y_b = mod( point[1], h )
line(lex, last_point_mod, point_mod, erasing)
+ if (mirror_x) {
+ line(lex, [w-last_point_mod[0], last_point_mod[1]], [w-point_mod[0], point_mod[1]], erasing)
+ }
+ if (mirror_y) {
+ line(lex, [last_point_mod[0], h-last_point_mod[1]], [point_mod[0], h-point_mod[1]], erasing)
+ }
}
last_point[0] = point[0]
last_point[1] = point[1]