assets/js/ui/{brush,custom}.js, index.html: merged into brush.js.

assets/js/ui/{letters,palette}.js, index.html: merged into paletters.js.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-11-24 08:38:52 +01:00
parent 07b0380242
commit cfdb8a151a
5 changed files with 121 additions and 121 deletions

View File

@ -106,3 +106,33 @@ var brush = (function(){
return brush return brush
})() })()
var custom = (function(){
var exports = {}
exports.clone = function (){
var new_brush = brush.clone()
var rapper = document.createElement("div")
rapper.className = "custom"
new_brush.append(rapper)
custom_rapper.appendChild(rapper)
// store in localstorage?
rapper.addEventListener("click", function(e){
if (e.shiftKey) {
rapper.parentNode.removeChild(rapper)
delete new_brush
} else {
// load this brush
exports.load(new_brush)
}
})
}
exports.load = function(new_brush){
brush.assign( new_brush )
}
return exports
})()

View File

@ -1,29 +0,0 @@
var custom = (function(){
var exports = {}
exports.clone = function (){
var new_brush = brush.clone()
var rapper = document.createElement("div")
rapper.className = "custom"
new_brush.append(rapper)
custom_rapper.appendChild(rapper)
// store in localstorage?
rapper.addEventListener("click", function(e){
if (e.shiftKey) {
rapper.parentNode.removeChild(rapper)
delete new_brush
} else {
// load this brush
exports.load(new_brush)
}
})
}
exports.load = function(new_brush){
brush.assign( new_brush )
}
return exports
})()

View File

@ -1,89 +0,0 @@
var letters = (function(){
var last_charset = ""
var charset_index = 0
var charsets = [
'Basic Latin',
'Latin-1 Supplement',
'Box Drawing',
'Block Elements',
]
var letters = new Matrix (1, 1, function(x,y){
var lex = new Lex (x,y)
return lex
})
letters.charset = ""
letters.repaint = function(charset){
letters.charset = charset = charset || last_charset
last_charset = charset
var chars = unicode.block(charset, 32)
if (chars[0] != " ") chars.unshift(" ")
if (canvas.vertical) {
letters.resize( Math.ceil( chars.length / 16 ), 16 )
}
else {
letters.resize( 32, Math.ceil( chars.length / 32 ) )
}
var i = 0
letters.forEach(function(lex,x,y){
if (canvas.vertical) { x=x^y;y=x^y;x=x^y }
var char = chars[i++]
if (palette.chars.indexOf(brush.char) > 1) {
lex.bg = brush.fg
lex.fg = brush.bg
}
else {
lex.bg = colors.black
lex.fg = brush.fg == fillColor ? colors.black : brush.fg
}
lex.char = char
lex.opacity = 1
lex.build()
})
}
letters.bind = function(){
letters.forEach(function(lex,x,y){
if (lex.bound) return
lex.bound = true
lex.span.addEventListener('mousedown', function(e){
e.preventDefault()
if (e.shiftKey) {
charset_index = (charset_index+1) % charsets.length
letters.repaint(charsets[charset_index])
return
}
else if (e.ctrlKey || e.which == 3) {
brush.char = lex.char
brush.bg = brush.fg
brush.fg = fillColor
}
else {
brush.char = lex.char
if (lex.char == " ") {
brush.bg = brush.fg
}
else if (brush.bg != fillColor) {
brush.fg = brush.bg
brush.bg = fillColor
}
}
if (! brush.modified) {
brush.generate()
}
palette.repaint()
})
lex.span.addEventListener('contextmenu', function(e){
e.preventDefault()
})
})
}
return letters
})()

View File

@ -1,3 +1,93 @@
var letters = (function(){
var last_charset = ""
var charset_index = 0
var charsets = [
'Basic Latin',
'Latin-1 Supplement',
'Box Drawing',
'Block Elements',
]
var letters = new Matrix (1, 1, function(x,y){
var lex = new Lex (x,y)
return lex
})
letters.charset = ""
letters.repaint = function(charset){
letters.charset = charset = charset || last_charset
last_charset = charset
var chars = unicode.block(charset, 32)
if (chars[0] != " ") chars.unshift(" ")
if (canvas.vertical) {
letters.resize( Math.ceil( chars.length / 16 ), 16 )
}
else {
letters.resize( 32, Math.ceil( chars.length / 32 ) )
}
var i = 0
letters.forEach(function(lex,x,y){
if (canvas.vertical) { x=x^y;y=x^y;x=x^y }
var char = chars[i++]
if (palette.chars.indexOf(brush.char) > 1) {
lex.bg = brush.fg
lex.fg = brush.bg
}
else {
lex.bg = colors.black
lex.fg = brush.fg == fillColor ? colors.black : brush.fg
}
lex.char = char
lex.opacity = 1
lex.build()
})
}
letters.bind = function(){
letters.forEach(function(lex,x,y){
if (lex.bound) return
lex.bound = true
lex.span.addEventListener('mousedown', function(e){
e.preventDefault()
if (e.shiftKey) {
charset_index = (charset_index+1) % charsets.length
letters.repaint(charsets[charset_index])
return
}
else if (e.ctrlKey || e.which == 3) {
brush.char = lex.char
brush.bg = brush.fg
brush.fg = fillColor
}
else {
brush.char = lex.char
if (lex.char == " ") {
brush.bg = brush.fg
}
else if (brush.bg != fillColor) {
brush.fg = brush.bg
brush.bg = fillColor
}
}
if (! brush.modified) {
brush.generate()
}
palette.repaint()
})
lex.span.addEventListener('contextmenu', function(e){
e.preventDefault()
})
})
}
return letters
})()
var palette = (function(){ var palette = (function(){
var palette = new Matrix (32, 2, function(x,y){ var palette = new Matrix (32, 2, function(x,y){

View File

@ -99,11 +99,9 @@
<script src="assets/js/ui/brush.js"></script> <script src="assets/js/ui/brush.js"></script>
<script src="assets/js/ui/canvas.js"></script> <script src="assets/js/ui/canvas.js"></script>
<script src="assets/js/ui/custom.js"></script>
<script src="assets/js/ui/keys.js"></script> <script src="assets/js/ui/keys.js"></script>
<script src="assets/js/ui/controls.js"></script> <script src="assets/js/ui/controls.js"></script>
<script src="assets/js/ui/palette.js"></script> <script src="assets/js/ui/paletters.js"></script>
<script src="assets/js/ui/letters.js"></script>
<script src="assets/js/ui/selection.js"></script> <script src="assets/js/ui/selection.js"></script>
<script src="assets/js/ui/transform.js"></script> <script src="assets/js/ui/transform.js"></script>