diff options
| -rw-r--r-- | colors2.html | 100 | ||||
| -rw-r--r-- | colors3.html | 108 |
2 files changed, 208 insertions, 0 deletions
diff --git a/colors2.html b/colors2.html new file mode 100644 index 0000000..2f82ad1 --- /dev/null +++ b/colors2.html @@ -0,0 +1,100 @@ +<link rel="stylesheet" href="css/sally.css" type="text/css" charset="utf-8" /> +<link rel="stylesheet" href="css/ak.css" type="text/css" charset="utf-8" /> + +<body class="loading"> +<center> + +<div id="canvas_rapper" style="margin: 0 auto;margin-top:7%"> +</div> + +</body> +<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> +<script src="js/util.js"></script> +<script src="js/color.js"></script> +<script src="js/lex.js"></script> +<script src="js/matrix.js"></script> +<script> + +// var color_hue_order = ("black dark-blue purple dark-red red orange " + +// "yellow lime green dark-cyan cyan blue magenta dark-gray light-gray white").split(" "); + +var color_mat_order = ("dark-red red orange yellow lime cyan dark-cyan blue dark-blue purple magenta dark-red black").split(" ") + +function color_mat (i) { return colors[color_mat_order[ mod(i,color_mat_order.length) ]] } + +function lerp_color (lex, start_color, end_color, t, x, y) { + t = clamp(t, 0, 1) + t *= 6 + if (t < 1.0) { + lex.bg = start_color + } + else if (t < 2.0) { + lex.bg = start_color + lex.fg = end_color + lex.char = (x+y) % 2 ? " " : "x" + } + else if (t < 3.0) { + lex.bg = start_color + lex.fg = end_color + lex.char = "x" + } + else if (t < 4.0) { + if ((x+y) % 2) { + lex.bg = end_color + lex.fg = start_color + } + else { + lex.bg = start_color + lex.fg = end_color + } + lex.char = "x" + } + else if (t < 5.0) { + lex.bg = end_color + lex.fg = start_color + lex.char = "x" + } + else if (t < 6.0) { + lex.bg = end_color + lex.fg = start_color + lex.char = (x+y) % 2 ? " " : "x" + } + else { + lex.bg = end_color + } +} + +var grid_w = 6, grid_h = 4, across = 14, down = 9, gap = 1, dd = 100 +var width = grid_w * across, height = grid_h * down +//var grid_w = 3, grid_h = 3, across = 24, gap = 1 +var canvas = new Matrix (width, height, function(x,y){ + var lex = new Lex (x,y) + + var i = floor(x / grid_w) + var j = floor(y / grid_h) * across + var hue = floor((i+j) / dd) + var t = ((i+j) / dd) % 1 + + var xx = x % grid_w + var yy = y % grid_h + + if (hue < 4*color_mat_order.length-1) { + var start_color = color_mat(hue) + var end_color = color_mat(hue+1) + } + else { + var start_color = gray(hue) + var end_color = gray(hue+1) + } + + if (xx != grid_w-gap && yy != grid_h-gap) { + lerp_color(lex, start_color, end_color, t, xx, yy) + } + + lex.build() + return lex +}) +canvas.append(canvas_rapper) + +document.body.className = "" +</script>
\ No newline at end of file diff --git a/colors3.html b/colors3.html new file mode 100644 index 0000000..15cb8bd --- /dev/null +++ b/colors3.html @@ -0,0 +1,108 @@ +<link rel="stylesheet" href="css/sally.css" type="text/css" charset="utf-8" /> +<link rel="stylesheet" href="css/ak.css" type="text/css" charset="utf-8" /> + +<body class="loading"> +<center> + +<div id="canvas_rapper" style="margin: 0 auto;margin-top:7%"> +</div> + +</body> +<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> +<script src="js/util.js"></script> +<script src="js/color.js"></script> +<script src="js/lex.js"></script> +<script src="js/matrix.js"></script> +<script> + +// var color_hue_order = ("black dark-blue purple dark-red red orange " + +// "yellow lime green dark-cyan cyan blue magenta dark-gray light-gray white").split(" "); + +var color_mat_order = ("dark-red red orange yellow lime cyan dark-cyan blue dark-blue purple magenta dark-red black").split(" ") +var patterns = {} +patterns[2] = [ 0, 2, + 3, 1 ] +patterns[3] = [ 0, 5, 3, + 8, 1, 6, + 4, 7, 2, ] +patterns[4] = [ 0, 8, 2, 10, + 6, 14, 4, 12, + 3, 11, 1, 9, + 5, 13, 7, 15 ] + +function color_mat (i) { return colors[color_mat_order[ mod(i,color_mat_order.length) ]] } + +function lerp_color (lex, start_color, end_color, t, x, y) { + t = clamp(t, 0, 1) + t *= 7 + + var step = (x+y) % 2 + var step2 = (x+y+1) % 2 +// var step3 = (x+y/2) % 2 +// if (1.0 < t && t < 6.0) lex.char = (step) ? "x" : " " + if (2.0 < t && t < 5.0) lex.char = "x" + else if (1.5 < t && t < 7.5) lex.char = (step) ? "x" : " " + else lex.char = (step2) ? "x" : " " + + if (t < 1.0) { + lex.bg = start_color + lex.fg = start_color + } + else if (t < 3.0) { + lex.bg = start_color + lex.fg = end_color + } + else if (t < 4.0) { + if ((x+y) % 2) { + lex.bg = end_color + lex.fg = start_color + } + else { + lex.bg = start_color + lex.fg = end_color + } + } + else if (t < 6.0) { + lex.bg = end_color + lex.fg = start_color + } + else { + lex.bg = end_color + lex.fg = end_color + } +} + +var grid_w = 6, grid_h = 4, across = 14, down = 9, gap = 1, dd = 130 +var width = grid_w * across, height = grid_h * down +//var grid_w = 3, grid_h = 3, across = 24, gap = 1 +var canvas = new Matrix (width, height, function(x,y){ + var lex = new Lex (x,y) + + var i = floor(x / grid_w) + var j = floor(y / grid_h) * across + var hue = floor((i+j) / dd) + var t = ((i+j) / dd) % 1 + + var xx = x % grid_w + var yy = y % grid_h + + if (hue < 4*color_mat_order.length-1) { + var start_color = color_mat(hue) + var end_color = color_mat(hue+1) + } + else { + var start_color = gray(hue) + var end_color = gray(hue+1) + } + + if (xx != grid_w-gap && yy != grid_h-gap) { + lerp_color(lex, start_color, end_color, t, xx, yy) + } + + lex.build() + return lex +}) +canvas.append(canvas_rapper) + +document.body.className = "" +</script>
\ No newline at end of file |
