Javascript - 水波纹效果

时间:2012-03-02 14:06:02

标签: javascript

我需要JS上的脚本,这将改变这种“水波纹”风格的图像/ html(对不起,6MB GIF文件!):

http://fcunited.ru/_temp/listening2.gif

任何lib?我只找到了这个:http://code.almeros.com/code-examples/water-effect-canvas/#.T1DPAXmuG_R

但这并不是我所需要的。

3 个答案:

答案 0 :(得分:6)

如果HTML5是一个选项(用加载图像的画布替换图像),您可以从演示中提取此效果并调整大小和位置的效果(包括源代码):

http://js1k.com/2010-first/demo/131

答案 1 :(得分:0)

这是Jonas Wagner最初创建的水波纹效果。

var floor = Math.floor;

function loadImage(callback) {
    var img = document.getElementById('bg');
    callback(img);
}

function getDataFromImage(img) {
    canvas.width = img.width;
    canvas.height = img.height;
    ctx.clearRect(0, 0, img.width, img.height);
    ctx.drawImage(img, 0 ,0);
    return ctx.getImageData(0, 0, img.width, img.height);
}

function disturb(x, y, z){
    if(x < 2 || x > width-2 || y < 1 || y > height-2)
        return;
    var i = x+y*width;
    buffer0[i] += z;
    buffer0[i-1] -= z;
}

function process(){
    var img = ctx.getImageData(0, 0, width, height),
        data = img.data,
        i, x;

    // average cells to make the surface more even
    for(i=width+1;i<size-width-1;i+=2){
        for(x=1;x<width-1;x++,i++){
            buffer0[i] = (buffer0[i]+buffer0[i+1]+buffer0[i-1]+buffer0[i-width]+buffer0[i+width])/5;
        }
    }

    for(i=width+1;i<size-width-1;i+=2){
        for(x=1;x<width-1;x++,i++){
            // wave propagation
            var waveHeight = (buffer0[i-1] + buffer0[i+1] + buffer0[i+width] + buffer0[i-width])/2-buffer1[i];
            buffer1[i] = waveHeight;
            // calculate index in the texture with some fake referaction
            var ti = i+floor((buffer1[i-2]-waveHeight)*0.08)+floor((buffer1[i-width]-waveHeight)*0.08)*width;
            // clamping
            ti = ti < 0 ? 0 : ti > size ? size : ti;
            // some very fake lighting and caustics based on the wave height
            // and angle
            var light = waveHeight*2.0-buffer1[i-2]*0.6,
                i4 = i*4,
                ti4 = ti*4;
            // clamping
            light = light < -10 ? -10 : light > 100 ? 100 : light;
            data[i4] = texture.data[ti4]+light;
            data[i4+1] = texture.data[ti4+1]+light;
            data[i4+2] = texture.data[ti4+2]+light;
        }
    }
    aux = buffer0;
    buffer0 = buffer1;
    buffer1 = aux;
    ctx.putImageData(img, 0, 0);
}
var canvas = document.getElementById('c'),
    ctx = canvas.getContext('2d'),
    width = 320,
    height = 240,
    size = width*height,
    buffer0 = [],
    buffer1 = [],
    aux, i, texture;

for(i=0;i<size;i++){
    buffer0.push(0);
    buffer1.push(0);
}

loadImage(function(img){
    texture = getDataFromImage(img);
    canvas.width = width;
    canvas.height = height;
    ctx.fillRect(0, 0, width, height);
    setInterval(process, 1000/60);
    resizeBy(width-innerWidth, height-innerHeight);
});

canvas.onmousemove = function(e){
    disturb(
            floor(e.clientX/innerWidth*width),
            floor(e.clientY/innerHeight*height),
            15000);
}
<img id="bg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWIAAAEBCAYAAABCPK+OAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsTAAALEwEAmpwYAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY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eFvDuLO+s5hYmV+DMjHZMp6fsW7wvH46iWlWfv76eed1j7Of/Ig7kuOeOGzzt7tJQ8Nel7Adgzhs87c76xuazgdAOx8Je31vjXyrbXfmt0MJJgLsYDTKxzwfNfObmZnfMS3HjByZfc3FnO1f4Uwz9wS/6XPE7SqDPHC4cuxWIdbeKsdhqOXY+sEWRsok88qx9lrf6SiTzCvH2mt+5hcEdCbyvORYez9ifuRTE2Nj4EEvWR5ce6qc1tWvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatSvequcatTPvdNGrI32TcAETMAEXkPAG/FrOPtRTMAETGBJwBvxEo0LJmACJvAaAt6IX8PZj2ICJmACSwLeiJdoXDABEzCB1xB4nz6fln+UJ89hWdKC+qINd1nSgvrWTwSWaLSg/qQ2/yUaLahvfhOBJRotqD+pPX9LNHvh/W3/Vcz2weTtw3GRf2v/bbYHB1IO9iafYra+UzG/bUw8P14/3j8e2j///Gf7PfDYeGMVxWaiH1TuW3KQjex2i4W27zht+2l31puf58frx/vHM/vndo247abbLttt31Ri1yUvftuEI95uh0+f9Q3LwQ0uPRv3g5n69JlfQ2R+gWG7MRfiH2suytRn6/U78wh6B8uDWaRyX48/i1/6YR1Prj37dKc19bVtlY8eralv/SCw4mJ+nh+dDfXH9MyMNO/5mdl8PX5pI84v3rV4dULXdNSth8Rj1vwe44bK/CDxmDW/x7ihGvye3Ig5oK0JmIAJmMCjBLwRP0rOOhMwARP4IALeiD8IpA9jAiZgAo8SODbicbXisUNZ/xg3VOYHices+T3GDZX5QeIx+yy/thFzECxPJWL9Ih9We/Gx9Km2qmlfPiaxHoN+asQcG6t568drCBfz8/zqWsHHMie6dqqa9uWZItZj0E+NmGNjNf9b9H+qkwdEtrf05h49Rq7lOHqrHMfItRxbb37VTHh+OoHMJsdeP5+3fm7+WxMM88nqq6n+qXGRUI36i/ZTWjXqnxoXCdWov2g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xtefO7jdOq6xK/uzbi1QM4bwImYAIm8DgBb8SPs7PSBEzABD6EgDfiD8Hog5iACZjA4wT6RhwXL/QCRuVrj9bjsbVGHDZu9GoPud5hvbJRZuprj/kxOd0qG2WmvvaYn/kpAZ0NnRn1tecfzM/2tya2R2u/Qrg5+hsi4VMLGzd+1TAK9NKjuei13vyYDc9PrAivH+8ffQ50r9zXyPa3Jlgt+6SwwbLrtkW0r6Q3SO72qEne+h12ZrSlzW/B5r75edtmsyk+af4++/GPHf2Tzv+7P/5XfP22jfjv9ua1b7Sbty2UuI+n2nN95cTYR9xz/b7nYklYD5Gw5vfR89MXTrDtnDdn8z5v/j778Zm2TuHrr7/8+r36+efH/4qv3/6OOJ5av8UiitsY+XPUGvalcO60/kxspvlV+PE8uiW6/fVD8Qr9mWDfip+Zv2eff3tXflopX5Ofvkbzec9k71n/83GI6vOfHyV6X/v6ffbjdzp6zzPqdvrNOkrafsnP/Tm+pI1a7s+x9ZcJZF45vqzuVdWof4s2elSj/iv0+fFyfMtzUI3692qj/1591vw2fT7fHN/7Gtyrz/05/tePr6+/P752C233mIAJmMA/JOCN+B/C9aFNwARM4BYC3ohvoeQeEzABE/iHBLwR/0O4PrQJmIAJ3EJgbMSPXKnWR7Beadzvm9/9zFRhfkrjft/87memiif5jY24fxZHD33fj4Gtn9lFdM+LY37mlwl4fjKRdfzN18+xER+/ELedavjta/c5e+1pm4wMitas/3r84qXS1+jVr9+zj//Z+lgDz/B79vn/9sd/lt9n66+9fn90uML/m7+zbPHRE347Ytztt5bovvXm5/lhYezW68f7B3vkhf1ze0dM19hMp1HScvgat8Y5cWzaHETL1pufzoPn57SgvH7YOHar8/KD949tI9626dPums9e4WQa1pufzkvMisbqU9Oc52fmBaOwcVNWxJozv5pRg/dt+P0flZOFplYONFQAAAAASUVORK5CYII=" style="display:none;">
<canvas id="c" style="position: absolute; top:0; left:0; width:100%;height:100%; "></canvas>

答案 2 :(得分:-1)

.paperButton {
  display: block;
  text-align: center;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  -webkit-transition: all 0.2s ease;
  -moz-transition: all 0.2s ease;
  -o-transition: all 0.2s ease;
  transition: all 0.2s ease;
  z-index: 0;
  cursor:pointer;
}
.animate {
  -webkit-animation: ripple 0.65s linear;
  -moz-animation: ripple 0.65s linear;
  -ms-animation: ripple 0.65s linear;
  -o-animation: ripple 0.65s linear;
  animation: ripple 0.65s linear;
}
 @-webkit-keyframes 
ripple {  100% {
opacity: 0;
-webkit-transform: scale(2.5);
}
}
@-moz-keyframes 
ripple {  100% {
opacity: 0;
-moz-transform: scale(2.5);
}
}
@-o-keyframes 
ripple {  100% {
opacity: 0;
-o-transform: scale(2.5);
}
}
@keyframes 
ripple {  100% {
opacity: 0;
transform: scale(2.5);
}
}


$(function(){
    var ink, i, j, k;
    $(".paperButton").mousedown(function(e){    
            if($(this).find(".ink").length === 0){
                $(this).prepend("<span class='ink'></span>");
            }

            ink = $(this).find(".ink");
            ink.removeClass("animate");

            if(!ink.height() && !ink.width()){
                i = Math.max($(this).outerWidth(), $(this).outerHeight());
                ink.css({height: i, width: i});
            }

            j = e.pageX - $(this).offset().left - ink.width()/2;
            k = e.pageY - $(this).offset().top - ink.height()/2;

            ink.css({top: k+'px', left: j+'px'}).addClass("animate");

});
});