mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 17:27:57 +01:00
Silliness.
This commit is contained in:
parent
e8c9932014
commit
c697806385
@ -1,10 +1,21 @@
|
|||||||
var keyboardShortcutsEnabled = true;
|
var keyboardShortcutsEnabled = true;
|
||||||
|
var wordBuffer = "";
|
||||||
|
|
||||||
|
var wordFuncs = {
|
||||||
|
"idbeholdl": function() {
|
||||||
|
alert("Light!");
|
||||||
|
},
|
||||||
|
"idspispopd": function() {
|
||||||
|
drawTextOnCanvas("Im in ur kanvas drawin' ur stuffz.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function initKeyboard() {
|
function initKeyboard() {
|
||||||
|
|
||||||
$(document).keypress(function(event) {
|
$(document).keypress(function(event) {
|
||||||
|
|
||||||
if (!keyboardShortcutsEnabled) return;
|
if (!keyboardShortcutsEnabled) return;
|
||||||
|
if (event.ctrlKey && event.altKey && ! event.metaKey) processWords(event);
|
||||||
if (event.altKey || event.ctrlKey || event.metaKey) return; //ignore key presses with modifier keys except shift
|
if (event.altKey || event.ctrlKey || event.metaKey) return; //ignore key presses with modifier keys except shift
|
||||||
|
|
||||||
var ch = String.fromCharCode(event.which);
|
var ch = String.fromCharCode(event.which);
|
||||||
@ -41,3 +52,23 @@ function initKeyboard() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processWords(e) {
|
||||||
|
wordBuffer += String.fromCharCode(e.which);
|
||||||
|
|
||||||
|
var match = false;
|
||||||
|
for (var k in wordFuncs) {
|
||||||
|
if (k.indexOf(wordBuffer) == 0) {
|
||||||
|
if (k.length == wordBuffer.length) match = wordFuncs[k];
|
||||||
|
else match = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(match) == 'function') {
|
||||||
|
match();
|
||||||
|
wordBuffer = "";
|
||||||
|
} else if (!match) {
|
||||||
|
wordBuffer = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -22,24 +22,27 @@ function onWordArtOk() {
|
|||||||
hidePopup(popupWordArt);
|
hidePopup(popupWordArt);
|
||||||
|
|
||||||
var s = $("#txtWordArt").val();
|
var s = $("#txtWordArt").val();
|
||||||
|
drawTextOnCanvas(s);
|
||||||
|
}
|
||||||
|
|
||||||
if (s!=undefined) {
|
function drawTextOnCanvas(text) {
|
||||||
var points = getStringAsPoints(s);
|
if (typeof(text) == 'string') {
|
||||||
|
var points = getStringAsPoints(text);
|
||||||
|
|
||||||
var bounds = getBounds(points);
|
var bounds = getBounds(points);
|
||||||
var scaleX = (canvasWidth-50) / bounds.width;
|
var scaleX = (canvasWidth-50) / bounds.width;
|
||||||
var scaleY = (canvasHeight-50) / bounds.height;
|
var scaleY = (canvasHeight-50) / bounds.height;
|
||||||
|
|
||||||
var scale = Math.min(scaleX,scaleY);
|
var scale = Math.min(scaleX,scaleY);
|
||||||
|
|
||||||
scalePoints(points,scale);
|
scalePoints(points,scale);
|
||||||
var bounds = getBounds(points);
|
var bounds = getBounds(points);
|
||||||
translatePoints(points,-bounds.x,-bounds.y); //left top of text is (0,0)
|
translatePoints(points,-bounds.x,-bounds.y); //left top of text is (0,0)
|
||||||
translatePoints(points,-bounds.width/2,-bounds.height/2); //anchor point center
|
translatePoints(points,-bounds.width/2,-bounds.height/2); //anchor point center
|
||||||
translatePoints(points,canvasWidth/2,canvasHeight/2); //center in canvas
|
translatePoints(points,canvasWidth/2,canvasHeight/2); //center in canvas
|
||||||
|
|
||||||
canvasDrawPoints(canvas,points);
|
canvasDrawPoints(canvas,points);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStringAsPoints(text) {
|
function getStringAsPoints(text) {
|
||||||
|
Loading…
Reference in New Issue
Block a user