目前分類:JavaScript (6)

瀏覽方式: 標題列表 簡短摘要
rd3DPlane

简介

进行上图所示的3D格子地板的渲染,需要进行Canvas的像素级别操作,从视点连接屏幕(屏幕就是canvas)中的所有像素点,形成大量的射线,倘若射线与地板相交,把交点以及交点的颜色反馈给屏幕(canvas)。如下图所示:

image

像素操作

在进行3D渲染之前,必须了解Canvas的像素操作相关概念。在给定了width和height的canvas上,在坐标(x ,y)上的像素的index构成如下。

var data=getImageData(0, 0, canvas.width, canvas.height);

红色index:((width * y) + x) * 4          像素值:data[((width * y) + x) * 4]

绿色index:((width * y) + x) * 4 + 1    像素值:data[((width * y) + x) * 4+1]

蓝色index:((width * y) + x) * 4 + 2    像素值:data[((width * y) + x) * 4+2]

透明度index:((width * y) + x) * 4 + 3 像素值:data[((width * y) + x) * 4+3]

修改了任何像素的红、绿、蓝和alpha值之后,可以通过第二个函数来更新canvas上的显示,那就是context.putImageData(imagedata, dx, dy)。

寻找交点

怎么找到射线与地板的交点?可以先列出已知的条件:

戮克 發表在 痞客邦 留言(0) 人氣()

摘要: 火狐下正常,但是在IE下,一点Flash中调用JS函数的按钮就出JS错误“'null' 为空或不是对象”,查看关于ExternalInterface的帮助,提到一点是: 注意:在将 SWF 文件嵌入到 HTML 页中时,请确保 <object> 和 <embed...
 
火狐下正常,但是在IE下,一点Flash中调用JS函数的按钮就出JS错误“'null' 为空或不是对象”,查看关于ExternalInterface的帮助,提到一点是:

 

注意:在将 SWF 文件嵌入到 HTML 页中时,请确保 <object> 和 <embed> 标签的 id 和 name 属性不包括诸如以下的字符: (句点)、-、+、*、/ 和 \。

既然提到id和name和属性不得包含特 殊符号,是不是在调用ExternalInterface时,id属性也是必不可少的。<object>中加上 id,问题迎刃而解~

另外flash调用js例子:

点击Flash的时候就执行GetJS方法

戮克 發表在 痞客邦 留言(0) 人氣()

測試網址:
http://dbhills.blogspot.com/p/blog-page.html
是使用這家東西做得,有需要的人可以去看。他還有其他各式各樣的圖表。
http://www.highcharts.com/

程式碼如下直接把X軸和Y軸的值,替換成自己想要的程式碼就可以動了。

  1
2
3

戮克 發表在 痞客邦 留言(0) 人氣()

原文

測試網址
http://dbhills.blogspot.com/p/typetextjavascript-var-url-document.html
功能為網頁自動轉址及判斷是否為手機瀏覽,可以用於智慧轉址。開啟網頁會去判斷用Android、ipad、iphone或PC何種作業系統裝置開啟網頁,並自動依照裝置不同連結不同網頁。

程式碼如下

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script type="text/javascript">

var URL = document.location.toString();
var useragent = navigator.userAgent;
useragent = useragent.toLowerCase();

if( useragent.indexOf('iphone') != -1 ) location.replace("https://itunes.apple.com/us/app/li-da-zi-xun-xing-dongapp/id665035983?l=zh&ls=1&mt=8");//iphone
else if( useragent.indexOf('ipad') != -1 || useragent.indexOf('ipod') != -1) location.replace("https://itunes.apple.com/us/app/li-da-zi-xun-xing-dongapp/id665035983?l=zh&ls=1&mt=8");//ipad
else if( useragent.indexOf('android') != -1 ) {
if( ConsiderLimits() )
{
location.replace("https://play.google.com/store/apps/details?id=tw.com.giantapp.sample"); // android pad
}else{
location.replace("https://play.google.com/store/apps/details?id=tw.com.giantapp.sample"); // android phone
}
}else{
location.replace("http://www.e-giant.com.tw/"); // PC
}

function ConsiderLimits() {
if( screen.width >= 1024 && screen.height >= 600 )
return 1;
return 0;
}

</script>

戮克 發表在 痞客邦 留言(0) 人氣()




 1
2
3
4
5
6

戮克 發表在 痞客邦 留言(0) 人氣()

基礎
1.WWW的基礎
2.Client端網頁技術(前端或客戶端,即上網的一端)
JavaScript
VBScript
JScript
HTML
DHTML
3.Server端網頁技術(後端或稱伺服端,即放網頁和資料的一端)
ASP

戮克 發表在 痞客邦 留言(0) 人氣()