顯示具有 HTML 標籤的文章。 顯示所有文章
顯示具有 HTML 標籤的文章。 顯示所有文章

2010年11月16日 星期二

canvas+video

<style type="text/css">
 body{ background:#000;}
 #c{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
 }
 #v{
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -180px 0 0 -240px;
 }
</style>
<canvas id="c"></canvas>
<video id="v" controls>
    <source src="/blog/video/大眼睛.mp4" type="video/mp4">
</video>
<script>
document.addEventListener('DOMContentLoaded', function(){
    var v = document.getElementById('v');
    var canvas = document.getElementById('c');
    var context = canvas.getContext('2d');

    var cw = Math.floor(canvas.clientWidth / 100);
    var ch = Math.floor(canvas.clientHeight / 100);
    canvas.width = cw;
    canvas.height = ch;

    v.addEventListener('play', function(){
        draw(this,context,cw,ch);
    },false);

},false);

function draw(v,c,w,h) {
    if(v.paused || v.ended) return false;
    c.drawImage(v,0,0,w,h);
    setTimeout(draw,20,v,c,w,h);
}
</script>

<video id="v" controls>
 <source src="/blog/video/大眼睛.mp4" type="video/mp4">
</video>
<canvas id="c"></canvas>
<script>
function draw(v,c,bc,cw,ch) {
    if(v.paused || v.ended) return false;
    // First, draw it into the backing canvas
    bc.drawImage(v,0,0,cw,ch);
    // Grab the pixel data from the backing canvas
    var idata = bc.getImageData(0,0,cw,ch);
    var data = idata.data;
    var w = idata.width;
    var limit = data.length
    // Loop through the subpixels, convoluting each using an edge-detection matrix.
    for(var i = 0; i < limit; i++) {
        if( i%4 == 3 ) continue;
        data[i] = 127 + 2*data[i] - data[i + 4] - data[i + w*4];
    }
    // Draw the pixels onto the visible canvas
    c.putImageData(idata,0,0);
    // Start over!
    setTimeout(draw,20,v,c,bc,cw,ch);
}
</script>
function draw(v,c,bc,w,h) {
    if(v.paused || v.ended) return false;
    // First, draw it into the backing canvas
    bc.drawImage(v,0,0,w,h);
    // Grab the pixel data from the backing canvas
    var idata = bc.getImageData(0,0,w,h);
    var data = idata.data;
    // Loop through the pixels, turning them grayscale
    for(var i = 0; i < data.length; i+=4) {
        var r = data[i];
        var g = data[i+1];
        var b = data[i+2];
        var brightness = (3*r+4*g+b)>>>3;
        data[i] = brightness;
        data[i+1] = brightness;
        data[i+2] = brightness;
    }
    idata.data = data;
    // Draw the pixels onto the visible canvas
    c.putImageData(idata,0,0);
    // Start over!
    setTimeout(function(){ draw(v,c,bc,w,h); }, 0);
}

文字標籤

標籤 目的 範例
a 超鏈接 Visit my drinks page.
em 斜體強調 I must say I adore lemonade.
strong 重點 This tea is very hot.
small 縮小字體 These grapes are made into wine. Alcohol is addictive.
s 刪除線 text Price: £4.50 £2.00!
cite 工作職稱 works The case Hugo v. Danielle is relevant here.
q 語錄 The judge said You can drink water from the fish tank but advised against it.
dfn 定義實例 The term organic food refers to food produced without synthetic chemicals.
addr 縮略語 Organic food in Ireland is certified by the IOFGA.
time 日期和時間 Published .
code 電腦代碼 The fruitdb program can be used for tracking fruit production.
var 變數 If there are n fruit in the bowl, at least n÷2 will be ripe.
samp 電腦輸出 The computer said Unknown error -3.
kbd 用戶輸入 Hit F1 to continue.
sub 下標 Water is H2O.
sup 上標 The Hydrogen in heavy water is usually 2H.
i 斜體 Lemonade consists primarily of Citrus limon.
b 關鍵詞 Take a lemon and squeeze it with a juicer.
mark 覆蓋強調 Elderflower cordial, with one part cordial to ten parts water, stands apart from the rest.
ruby,rt,rp 頂上註解 OJ (Orange Juice)
bdi 文本方向性隔離 The recommended restaurant is My Juice Cafe (At The Beach).
bdo 格式文本方向性 The proposal is to write English, but in reverse order. "Juice" would become "Juice"
span 其他 In French we call it sirop de sureau.
br 換行 Simply Orange Juice Company
Apopka, FL 32703
U.S.A.
wbr 換行機會 www.simplyorangejuice.com
ins 底線 底線
del 刪除線 刪除線

2010年11月4日 星期四

列印 HTML 網頁強制換頁的方式


強制分頁有大概只有二種用的到:
{ page-break-after: always; /*在標籤後換頁*/ }
{ page-break-before: always; /*在標籤前換頁*/ }
這二個當中,大概最常用的就是 page-break-after: always,就是在指定的標籤後強制換頁,可以參考下面的 HTML 範例:
<div STYLE="page-break-after: always;">
第一頁
</div>
第二頁
再來就可以試著列印看看效果如何。
IE 7 需加入 才可換頁: (2008/2/16 更新)
範例:
第一頁
<P style='page-break-after:always'>&nbsp;</P>
第二頁