summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2017-03-24 22:10:04 +0100
committerJules Laplace <jules@okfoc.us>2017-03-24 22:10:04 +0100
commita4bb7570a5ba91122c464a586efc5a897bef015b (patch)
treec0827c4e94b48ace05b09b5009ffa1aa52a849ed
parentef888cdb9f8d970eb95e77f17a7d66b755882cf0 (diff)
dither blocks in their own file
-rw-r--r--index.html1
-rw-r--r--js/dither.js15
-rw-r--r--js/ui/palette.js2
3 files changed, 17 insertions, 1 deletions
diff --git a/index.html b/index.html
index a7d3e1e..074080f 100644
--- a/index.html
+++ b/index.html
@@ -116,6 +116,7 @@
<script src="js/png.js"></script>
<script src="js/unicode.js"></script>
<script src="js/color.js"></script>
+<script src="js/dither.js"></script>
<script src="js/undo.js"></script>
<script src="js/clipboard.js"></script>
<script src="js/upload.js"></script>
diff --git a/js/dither.js b/js/dither.js
new file mode 100644
index 0000000..37baf01
--- /dev/null
+++ b/js/dither.js
@@ -0,0 +1,15 @@
+var dither = {
+ aa: '▓▒░ ',
+ a: '▓',
+ b: '▒',
+ c: '░',
+ d: ' ',
+ p: function(n){
+ if (0 <= 0 && n < 1) {
+ return block.aa[Math.floor(n * 4)]
+ }
+ else {
+ return block.aa[Math.floor(n % 4)]
+ }
+ }
+}
diff --git a/js/ui/palette.js b/js/ui/palette.js
index 5931543..40da8b6 100644
--- a/js/ui/palette.js
+++ b/js/ui/palette.js
@@ -8,7 +8,7 @@ var palette = (function(){
var palette_index = localStorage.getItem("ascii.palette") || 1
var palette_list = [all_hue, all_inv_hue, mirc_color, mirc_color_reverse]
var palette_fn = palette_list[palette_index]
- palette.chars = " ▓▒░"
+ palette.chars = " " + dither.a + dither.b + dither.c
palette.repaint = function(){
var xw = use_experimental_palette ? 5 : 2