Skip to content

Instantly share code, notes, and snippets.

View cxytomo's full-sized avatar
🎯
Focusing

cxytomo

🎯
Focusing
View GitHub Profile
$(function () {
$('select.selectOnly').selectBox(html.selectBox.sb1);
$('input[type=radio]').radiobox(html.radiobox.rb2);
//clearTimeout
clearTimeout(realtime_haloTimer);
//mapInstance
var mapInstance;
//get canvas element
var canvas = document.getElementById('areaCode-canv'),
ctx = canvas.getContext('2d');
@cxytomo
cxytomo / img-align.html
Last active August 14, 2018 08:43
未知大小图片在已知大小容器水平/垂直居中
<!DOCTYPE html>
<html lan="en">
<head>
<title>未知大小图片在已知大小容器水平/垂直居中</title>
<meta charset="UTF-8">
<style type="text/css">
#first {
/*非IE的主流浏览器识别的垂直居中的方法*/
display: table-cell;
vertical-align:middle;
function createImageDataPressed (e) {
window.open(canv.toDataURL(),"cavasImage","left=0,top=0,width="+canv.width+",height="+canv.height+",toolbar=0,resizable=0");
}
function keyPressed(e){
if(!game && guess>0){
var keyPressed = String.fromCharCode(e.keyCode)//获得按下的键的值
, keyPressedIndex;
keyPressed = keyPressed.toLowerCase();
lettersGuessed.push(keyPressed);
keyPressedIndex = letters.indexOf(keyPressed);
if(keyPressedIndex >= 0){
guess = guess - 1;
if(keyPressedIndex === index) {
function initGame(){
index = Math.floor(Math.random()*letters.length);
letterToGuess = letters[index];
//console.log(letterToGuess);
lettersGuessed = [];
window.addEventListener('keyup',keyPressed,true);
var formElement = document.getElementById('createImageData');
formElement.addEventListener('click',createImageDataPressed,false);
drawScreen();
}
var canv = document.getElementById('game')
, contxt = canv.getContext('2d')
, guess = 3 //猜测的次数
, message = "Guess The Letter From a(lower) to z(higher)"//游戏提示
, letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
, today = new Date()//日期显示
, letterToGuess = ""//系统随机产生的待猜测的字母
, letterToGArray = []//游戏结束时,用于显示待猜测字母
, LowerOrHigher = ""//每次键按下后对用户提示
, lettersGuessed//存放已经按过的字母
(function canvasApp() {
var canv = document.getElementById('game')
, contxt = canv.getContext('2d')
, guess = 3
, message = "Guess The Letter From a(lower) to Z(higher)"
, letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
, today = new Date()
, letterToGuess = ""
, LowerOrHigher = ""
, lettersGuessed
@cxytomo
cxytomo / HTML5 canvas.js
Created March 23, 2013 13:20
an example of HTML5 canvas
//slide icon created by HTML5 canvas
(function(){
var canv = $(‘#slide_icon’)[0];
//canv.style.width=”300px“;
//canv.style.height=“300px”;
var cont = canv.getContext(’2d’);
//border cont.beginPath();
cont.moveTo(8,10);
cont.arc(8,18,8,Math.PI*3/2,Math.PI,true);
@cxytomo
cxytomo / drag.html
Created November 7, 2012 14:42 — forked from fxxkscript/drag.html
HTML5 Drag and Drop
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 Drag and Drop</title>
<style>
body {
background-color: #515151;
width: 100%;
height: 100%;
@cxytomo
cxytomo / prueba_estabilidad2.m
Created October 29, 2012 02:00
Diagrama de Nyquist
function prueba_estabilidad2(num, den)
sys = tf(num, den)
raices = roots(den)
nyquist(sys);
for i = 1:length(raices);
text(real(raices(i)), imag(raices(i)), "*");
printf("%f, %f",real(raices(i)), imag(raices(i)))
endfor
endfunction