有帮助?打赏吧!

专门记录不常用,容易遗忘的帖子

角度=弧度*180.0f/PI

弧度=角度*PI/180.0f

 

//js 操作数组插入元素到某个位置

var arr=["a","b","c","d"]
arr.splice(2,0,"ww");//2 表示 第三位; 0 表示 删除第三位后的0位, 同时在第三位插入 "ww"
alert(arr)

 

//多行文字 垂直居中

<div class="outer">
  <div class="middle">
    把你要居中的文本放在这里
    这是第二行
  </div>
</div>

 

 

threejs 使用已有的canvas

var renderer = new THREE.WebGLRenderer(
{
canvas: document.getElementById("canv")
});
//renderer.setSize( window.innerWidth, window.innerHeight );

 

 

 

 

//求灰度

var ascii = document.getElementById("ascii");
for(var i = 0; i < colordata.length; i = i+4)
{
r = colordata[i];
g = colordata[i+1];
b = colordata[i+2];
//converting the pixel into grayscale
gray = r*0.2126 + g*0.7152 + b*0.0722;
//overwriting the colordata array with grayscale values
//colordata[i] = colordata[i+1] = colordata[i+2] = gray;

//text for ascii art.
//blackish = dense characters like "W", "@"
//whitish = light characters like "`", "."
if(gray > 250) character = " "; //almost white
else if(gray > 230) character = "`";
else if(gray > 200) character = ":";
else if(gray > 175) character = "*";
else if(gray > 150) character = "+";
else if(gray > 125) character = "#";
else if(gray > 50) character = "W";
else character = "@"; //almost black

//newlines and injection into dom
if(i != 0 && (i/4)%W == 0) //if the pointer reaches end of pixel-line
{
ascii.appendChild(document.createTextNod

posted @ 2015-05-18 21:38  luoeeyang  Views(167)  Comments(0Edit  收藏  举报