Mostrando entradas con la etiqueta Javascript. Mostrar todas las entradas
Mostrando entradas con la etiqueta Javascript. Mostrar todas las entradas

Calendarios con estilo para tu blog

comentar



Ahora mostrar la fecha en tu blog puede, ademas de ser practico, ser un elemento mas de decoracion del sitio. Para tal motivo, me he estrujado un poquito las neuronas y me ha salido este widget tan 'cool' que muestra el numero y el nombre del dia a la perfeccion. Con un diseño elegante, con forma de icono y fondos combinando degradados y 'glossy', he utilizado Javascript para lo tecnico y CSS3 para lo visual. Esta disponible en 3 tonos: azul, negro y rojo, elige el que mas te guste y copia su codigo correspondiente para ponertelo en tu blog o web.


ver codigo
<style>
/* Calendario diseñado por (design by):
Johnny Vega  -  REDEANDO Blog
http://redeando.blogspot.com */

.cajacalendario {
height: 200px;
position: relative;
margin: 0 auto;
width: 200px;}
.widget { text-align: center;}
.widget-calendario {
    height: 150px;
    margin-bottom: 24px;
    width: 190px;
}
#nombredia {
background: #1e5799;
background: -moz-linear-gradient(top,  #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8));
background: -webkit-linear-gradient(top,  #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
background: -o-linear-gradient(top,  #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
background: -ms-linear-gradient(top,  #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
background: linear-gradient(to bottom,  #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 );
font-family: 'Francois One', sans-serif;
text-shadow: 0 0 9px #ffffff;border-left:4px solid #C1C1C1;border-right:4px solid #C1C1C1;border-top:4px solid #C1C1C1;
    border-radius: 35px 35px 0 0;
    color: #f9f9f9 !important;text-decoration:none !important;
font-size: 30px;letter-spacing:0px;font-weight:bold;
    line-height: 35px;height: 40px;
    position: relative;
    text-transform: lowercase;
}
#dia {
border-radius: 0 0 35px 35px;border:0px solid #565656;
background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2o5RiY4czv6H2GzuAcg8S9mbGq0sGTRRcmCSqig97VdGVSMaWyx9FwFgaSPgRlJweey-NFCsUJbjIj5gj2I4nJ0i9Fi2BYi18LZgA3w6MYjslG0TG6clzDhp3BCC92evE7yzcx7-_YGQ/s1600/fondo+calendario.png) no-repeat center bottom;
    color: #0C74B6;font-family: 'Francois One', sans-serif;
    font-size: 130px;text-shadow: -5px 0 #cdcdcd, 0 1px #000000, 0px 0 #cdcdcd, 0 -1px #000000, -1px 1px 2px #000000;
    height:150px;
    line-height: 120px;}
</style>
<div class="cajacalendario"><div class="widget"><div class="widget-calendario"><a style="text-decoration:none !important;" href="http://redeando.blogspot.com" target="_blank"><div id="nombredia"></div></a><div id="dia"></div></div></div></div>
<link href='http://fonts.googleapis.com/css?family=Francois+One' rel='stylesheet' type='text/css'>
<script>
    (function() {

    var date = new Date(),
    weekday = ["domingo", "lunes", "martes", "miercoles", "jueves", "viernes", "sabado"];

    document.getElementById('nombredia').innerHTML = weekday[date.getDay()];
    document.getElementById('dia').innerHTML = date.getDate();

}) ();
</script>


ver codigo
<style>
/* Calendario diseñado por (design by):
Johnny Vega  -  REDEANDO Blog
http://redeando.blogspot.com */
.cajacalendario2 {
height: 200px;
position: relative;
margin: 0 auto;
width: 200px;}
.widget2 { text-align: center;}
.widget-calendario2 {
    height: 150px;
    margin-bottom: 24px;
    width: 190px;
}
#nombredia2 {
background: #4c4c4c;
background: -moz-linear-gradient(top,  #4c4c4c 0%, #595959 12%, #666666 25%, #474747 39%, #2c2c2c 50%, #000000 51%, #111111 60%, #2b2b2b 76%, #1c1c1c 91%, #131313 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4c4c4c), color-stop(12%,#595959), color-stop(25%,#666666), color-stop(39%,#474747), color-stop(50%,#2c2c2c), color-stop(51%,#000000), color-stop(60%,#111111), color-stop(76%,#2b2b2b), color-stop(91%,#1c1c1c), color-stop(100%,#131313));
background: -webkit-linear-gradient(top,  #4c4c4c 0%,#595959 12%,#666666 25%,#474747 39%,#2c2c2c 50%,#000000 51%,#111111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);
background: -o-linear-gradient(top,  #4c4c4c 0%,#595959 12%,#666666 25%,#474747 39%,#2c2c2c 50%,#000000 51%,#111111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);
background: -ms-linear-gradient(top,  #4c4c4c 0%,#595959 12%,#666666 25%,#474747 39%,#2c2c2c 50%,#000000 51%,#111111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);
background: linear-gradient(to bottom,  #4c4c4c 0%,#595959 12%,#666666 25%,#474747 39%,#2c2c2c 50%,#000000 51%,#111111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313',GradientType=0 );
font-family: 'Francois One', sans-serif;
text-shadow: 0 0 9px #ffffff;border-left:4px solid #C1C1C1;border-right:4px solid #C1C1C1;border-top:4px solid #C1C1C1;
    border-radius: 35px 35px 0 0;
    color: #f9f9f9 !important;text-decoration:none !important;
font-size: 30px;letter-spacing:0px;font-weight:bold;
    line-height: 35px;height: 40px;
    position: relative;
    text-transform: lowercase;
}
#dia2 {
border-radius: 0 0 35px 35px;border:0px solid #565656;
background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2o5RiY4czv6H2GzuAcg8S9mbGq0sGTRRcmCSqig97VdGVSMaWyx9FwFgaSPgRlJweey-NFCsUJbjIj5gj2I4nJ0i9Fi2BYi18LZgA3w6MYjslG0TG6clzDhp3BCC92evE7yzcx7-_YGQ/s1600/fondo+calendario.png) no-repeat center bottom;
    color: #565656;font-family: 'Francois One', sans-serif;
    font-size: 130px;text-shadow: -5px 0 #cdcdcd, 0 1px #000000, 0px 0 #cdcdcd, 0 -1px #000000, -1px 1px 2px #000000;
    height:150px;
    line-height: 120px;}
</style>
<div class="cajacalendario2"><div class="widget2"><div class="widget-calendario2"><a style="text-decoration:none !important;" href="http://redeando.blogspot.com" target="_blank"><div id="nombredia2"></div></a><div id="dia2"></div></div></div></div>
<link href='http://fonts.googleapis.com/css?family=Francois+One' rel='stylesheet' type='text/css'>
<script>
    (function() {

    var date = new Date(),
    weekday = ["domingo", "lunes", "martes", "miercoles", "jueves", "viernes", "sabado"];

    document.getElementById('nombredia2').innerHTML = weekday[date.getDay()];
    document.getElementById('dia2').innerHTML = date.getDate();

}) ();
</script>


ver codigo
<style>
/* Calendario diseñado por (design by):
Johnny Vega  -  REDEANDO Blog
http://redeando.blogspot.com */
.cajacalendario3 {
height: 200px;
position: relative;
margin: 0 auto;
width: 200px;}
.widget3 { text-align: center;}
.widget-calendario3 {
    height: 150px;
    margin-bottom: 24px;
    width: 190px;
}
#nombredia3 {
background: #efc5ca;
background: -moz-linear-gradient(top,  #efc5ca 0%, #d24b5a 50%, #ba2737 51%, #f18e99 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#efc5ca), color-stop(50%,#d24b5a), color-stop(51%,#ba2737), color-stop(100%,#f18e99));
background: -webkit-linear-gradient(top,  #efc5ca 0%,#d24b5a 50%,#ba2737 51%,#f18e99 100%);
background: -o-linear-gradient(top,  #efc5ca 0%,#d24b5a 50%,#ba2737 51%,#f18e99 100%);
background: -ms-linear-gradient(top,  #efc5ca 0%,#d24b5a 50%,#ba2737 51%,#f18e99 100%);
background: linear-gradient(to bottom,  #efc5ca 0%,#d24b5a 50%,#ba2737 51%,#f18e99 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efc5ca', endColorstr='#f18e99',GradientType=0 );
font-family: 'Francois One', sans-serif;
text-shadow: 0 0 9px #ffffff;border-left:4px solid #C1C1C1;border-right:4px solid #C1C1C1;border-top:4px solid #C1C1C1;
    border-radius: 35px 35px 0 0;
color: #f9f9f9 !important;text-decoration:none !important;
font-size: 30px;letter-spacing:0px;font-weight:bold;
    line-height: 35px;height: 40px;
    position: relative;
    text-transform: lowercase;
}
#dia3 {
border-radius: 0 0 35px 35px;border:0px solid #565656;
background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2o5RiY4czv6H2GzuAcg8S9mbGq0sGTRRcmCSqig97VdGVSMaWyx9FwFgaSPgRlJweey-NFCsUJbjIj5gj2I4nJ0i9Fi2BYi18LZgA3w6MYjslG0TG6clzDhp3BCC92evE7yzcx7-_YGQ/s1600/fondo+calendario.png) no-repeat center bottom;
    color: #BB2939;font-family: 'Francois One', sans-serif;
    font-size: 130px;text-shadow: -5px 0 #cdcdcd, 0 1px #000000, 0px 0 #cdcdcd, 0 -1px #000000, -1px 1px 2px #000000;
    height:150px;
    line-height: 120px;}
</style>
<div class="cajacalendario3"><div class="widget3"><div class="widget-calendario3"><a style="text-decoration:none !important;" href="http://redeando.blogspot.com" target="_blank"><div id="nombredia3"></div></a><div id="dia3"></div></div></div></div>
<link href='http://fonts.googleapis.com/css?family=Francois+One' rel='stylesheet' type='text/css'>
<script>
    (function() {

    var date = new Date(),
    weekday = ["domingo", "lunes", "martes", "miercoles", "jueves", "viernes", "sabado"];

    document.getElementById('nombredia3').innerHTML = weekday[date.getDay()];
    document.getElementById('dia3').innerHTML = date.getDate();

}) ();
</script>


leer articulo ➨

Girar imagenes con un click

comentar

© REDEANDO Blog 2013.


Combinando un poquito de Javascript y otro poquillo de CSS3 podemos conseguir que cualquier imagen de nuestro blog o web gire al hacer click con el raton sobre ella.

Para poner este efecto en una imagen, la cuestion es muy sencilla. Copiamos y pegamos el siguiente codigo donde queramos mostrarla, sustituyendo lo que esta en color rojo por la url de dicha imagen:
<img src="URL DE LA IMAGEN" id="girar"><script>
//<![CDATA[
$('#girar').on("click", function(e) {
  e.preventDefault();
  $('#girar').addClass('giro');
 
  var t1 = setTimeout(function() {
  $('#girar').removeClass('giro');
  }, 1000);
});
  //]]>
</script>
<style>
#girar {
  position: relative;cursor:pointer;
  -webkit-transition: all 500ms ease-in-out;
    -moz-transition: all 500ms ease-in-out;
    -o-transition: all 500ms ease-in-out;
    -ms-transition: all 500ms ease-in-out;
}

#girar.giro {
    -webkit-transform: rotate(90deg);
       -moz-transform: rotate(90deg);
        -ms-transform: rotate(90deg);
         -o-transform: rotate(90deg);
            transform: rotate(90deg);
    zoom: 1;
}
</style>



En caso de que queramos que gire hacia otro lado, modificando la parte del codigo CSS (-webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -ms-transform: rotate(90deg); -o-transform: rotate(90deg); transform: rotate(90deg);), podemos cambiar el agulo de rotacion. Y como ejemplo, aqui teneis 2 imagenes, podeis hacer click en cualquiera de ellas para comprobarlo.




leer articulo ➨

Letras que cambian de color al pasar el cursor

1 comentó



Ya hemos visto en este mismo blog muchas tecnicas para aplicar al texto, bien sean sombras, animaciones, parpadeos de colores, etc... Pues bien, en este caso, vamos a ver como aplicando un poco de Javascript combinado con CSS, no solo conseguimos que cada letra sea de un color diferente, sino que al pasar el cursor sobre cada una de ellas, estas cambien de color independientemente.

Aqui debajo tienes el ejemplo, pasa el raton por las letras y observaras este efecto camaleonico:




Si te ha gustado y quieres ponerlo en tu blog o web, copia el siguiente codigo y pegalo donde tu quieras. Lo que esta resaltado en color verde es el tamaño de la fuente, lo que esta en azul son los codigos HEX de los colores utilizados y donde esta en color rojo, sustituyelo por el texto que quieras poner.

ver codigo
<div style="font-size:60px;cursor:pointer;font-weight:bold;font-family:Arial Black;text-shadow:-2px 2px 2px #333333;"><script>
//Colores utilizados en el texto
var colors=new Array('#3498db','#e74c3c','#2ecc71','#e67e22','#1abc9c','#f1c40f','#2BB4E1','#7A7B7A');


function printCSS(){
    document.write('<style>');
  
    for(var i=0;i<colors.length;i++){
        document.write('.color-'+i+'{color:'+colors[i]+'}');
    }
  
    document.write('</style>');
}



function generateText(text){
    for(var i=0;i<text.length;i++){
        var rnd=Math.floor(Math.random()*colors.length);
  
        document.write('<span id="letter-'+i+'" class="color-'+rnd+'" onmouseover="changeColor(this.id)">');
        document.write(text[i]);
        document.write('</span>');
    }
}



function changeColor(el){
    el=document.getElementById(el);
    var rnd=Math.floor(Math.random()*colors.length);
 
    while(el.className=='color-'+rnd){
        rnd=Math.floor(Math.random()*colors.length);
    }
 
    el.className='color-'+rnd;
}


printCSS();
generateText('ESCRIBE TU TEXTO AQUI');
</script></div>


leer articulo ➨

Texto interactivo

1 comentó

Para ponerlo de titulo en el blog, para poner un mensaje o para lo que tu quieras utilizarlo, te voy a enseñar un codigo realizado con Javascript y la etiqueta canvas (HTML5) que te permitira añadir un texto interactivo. Como puedes ver en el ejemplo de aqui abajo, al pasar el cursor alrededor o por encima, este se va moviendo y haciendo 'la ola'. Ademas, cada vez que recargues la pagina aparecerera con un color distinto. Para ponerlo en tu blog o web, tan solo tienes que copiar el codigo y pegarlo alli donde quieras mostrarlo. Donde esta indicado en color rojo, escribes el texto que quieras. Lo que esta en color verde es el tamaño o espacio que ocupa y lo que esta en azul es el tamaño y el tipo de la fuente.
<canvas id="c"></canvas> <script> document.body.clientWidth; with(Math){r=random;f=floor;pi=PI;at=atan2}w=window;a=[];function rn(b){return f(r()*b)}function rc(){return"rgb("+rn(255)+","+rn(255)+","+rn(255)+")"} w.onload=function(){c=document.getElementById("c");c.width=cw=600;c.height=ch=300;o=c.getContext("2d");g=o.createLinearGradient(0,0,cw,70);g.addColorStop(0,rc());g.addColorStop(0.5,rc());o.fillStyle=g;o.font="60px Arial Black";o.fillText("TU TEXTO AQUI",50,200);for(x=0;x<cw;x+=5)for(y=0;y<ch;y+=5){d=o.getImageData(x,y,1,1).data;color="rgb("+d[0]+","+d[1]+","+d[2]+")";d[2]!=0&&a.push({x:x,y:y,c:color})}w.onmousemove=function(b){x=b.clientX;y=b.clientY};setInterval(function(){c.width=cw;for(i=0;i<a.length;i++){o.save(); o.translate(a[i].x,a[i].y);o.rotate(at(x-a[i].x,-(y-a[i].y))*(180/pi)/50);o.fillStyle=a[i].c;o.beginPath();o.moveTo(20,20);o.lineTo(25,20);o.lineTo(20,25);o.fill();o.restore()}},10)};</script>
leer articulo ➨

Cubo 3D con tu logo

2 comentaron

Vamos a ver una original manera de presentar el logo de tu blog o web o la imagen que desees transformandola en un cubo 3D. ¿Como conseguimos este efecto? Pues con la libreria three.js, utilizada por desarrolladores de juegos y animadores, ya que con ella se pueden crear increibles animaciones utilizando para ello simplemente Javascript y HTML5. Para que veais como queda, he puesto esta imagen que veis a la derecha y aqui abajo teneis el resultado. La imagen aparece por los seis lados del cubo y pasando el cursor del raton por encima podemos rotarlo en todas las direcciones posibles.
Si quieres añadirlo en tu blog o web, copia el siguente codigo y pegalo donde quieras mostrar el cubo. Sustituye URL IMAGEN (en color rojo) por la direccion URL de la imagen que quieras poner.
ver codigo
<div id="container"></div>
<script src="https://sites.google.com/site/redeando1/cubotresd.js"></script>
<script src="https://sites.google.com/site/redeando1/cubotresd2.js"></script>
<script>
var container, stats;
   var camera, scene, renderer;
   var group;
   var mouseX = 0, mouseY = 0;

   var windowHalfX = window.innerWidth / 2;
   var windowHalfY = window.innerHeight / 2;

   init();
   animate();

   function init() {

    container = document.getElementById( 'container' );

    camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
    camera.position.z = 500;

    scene = new THREE.Scene();

    group = new THREE.Object3D();
    scene.add( group );

    // earth

    var earthTexture = new THREE.Texture();
    var loader = new THREE.ImageLoader();

    loader.addEventListener( 'load', function ( event ) {

     earthTexture.image = event.content;
     earthTexture.needsUpdate = true;

    } );

    loader.load( 'URL IMAGEN' );

    var geometry = new THREE.CubeGeometry( 200, 200, 200 );
    var material = new THREE.MeshBasicMaterial( { map: earthTexture, overdraw: true } );

    var mesh = new THREE.Mesh( geometry, material );
    group.add( mesh );

    // shadow

    var shadowTexture = new THREE.Texture();
    var loader = new THREE.ImageLoader();

    loader.addEventListener( 'load', function ( event ) {

     shadowTexture.image = event.content;
     shadowTexture.needsUpdate = true;

    } );

    loader.load( '' );

    var geometry = new THREE.PlaneGeometry( 400, 400, 3, 3 );
    var material = new THREE.MeshBasicMaterial( { map: shadowTexture, overdraw: true } );

    var mesh = new THREE.Mesh( geometry, material );
    mesh.position.y = - 250;
    mesh.rotation.x = - Math.PI / 2;
    group.add( mesh );

    renderer = new THREE.CanvasRenderer();
    renderer.setSize( window.innerWidth, window.innerHeight );

    container.appendChild( renderer.domElement );

    stats = new Stats();
    stats.domElement.style.position = 'absolute';
    stats.domElement.style.top = '0px';
  
    document.addEventListener( 'mousemove', onDocumentMouseMove, false );

    //

    window.addEventListener( 'resize', onWindowResize, false );

   }

   function onWindowResize() {

    windowHalfX = window.innerWidth / 2;
    windowHalfY = window.innerHeight / 2;

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );

   }

   function onDocumentMouseMove( event ) {

    mouseX = ( event.clientX - windowHalfX );
    mouseY = ( event.clientY - windowHalfY );

   }

   //

   function animate() {

    requestAnimationFrame( animate );

    render();
    stats.update();

   }

   function render() {

    camera.position.x += ( mouseX - camera.position.x ) * 0.05;
    camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
    camera.lookAt( scene.position );

    group.rotation.y -= 0.002;

    renderer.render( scene, camera );

   }
</script>
leer articulo ➨

Texto intermitente que cambia de color como un neon

5 comentaron



Combinando Javascript y CSS3 para cambiar y editar los colores, aplicando text-shadow para crear el brillo, podemos crear textos que se 'apagan' y se encienden como los neones luminosos. Se le pueden dar muchas utilidades a esta tecnica, como por ejemplo aplicandoselo al titulo del blog. Aqui teneis tres ejemplos, aunque se pueden combinar los colores a vuestro gusto:


color azul neon

de color rojo

verde luminoso


Cuando quieras poner un texto con este efecto, tan solo tienes que copiar y pegar el siguiente codigo alli donde quieras mostrarlo. Donde esta indicado en color rojo escribe las palabras que desees. Tambien puedes modificar algunos parametros como el color de la fuente, del luminoso y su tamaño donde esta indicado en color azul.

ver codigo
<span class="luz" id="blink"><b>TU TEXTO AQUI</b></span>

<script>
(function() {

setInterval(function(){
  var el = document.getElementById('blink');
  if(el.className == 'luz'){
      el.className = 'luz on';
  }else{
      el.className = 'luz';
  }
},500);

})();
</script>

<style>
.luz.on{
  color: #0099ff;/*color del texto al cambiar*/
  text-shadow:
     1px  1px rgba(255, 255, 255, .1),
    -1px -1px rgba(0, 0, 0, .88),
     0px  0px 20px #0099ff;/*color de la luz del texto*/
}
.luz{
  font-size:80px;/*tamaño de la fuente*/
  color: #000000;
  text-shadow:
     1px  1px rgba(255, 255, 255, .1),
    -1px -1px rgba(0, 0, 0, .88);
}
</style>



leer articulo ➨

Lluvia en tu blog

4 comentaron

Si en invierno y navidades a much@s les da por poner nieve cayendo en su blog o web... ¿Porque no poner lluvia? La verdad es que es relativamente facil de conseguir este efecto. Para ello necesitamos un poco de Javascript, le añadimos un toque de CSS3 y ¡voila!, ya tenemos nuestra receta hecha (el codigo, quiero decir). Como podeis comprobar, funciona, mirad como esta diluviando sin parar en este mismo blog. Mientras cojo el paraguas, os cuento como podeis añadir esta animacion en vuestra pagina. Teneis que dirigiros a la plantilla, buscad la etiqueta <body> y justo debajo pegais el siguiente codigo y guardais los cambios. Saludos pasados por agua.










leer articulo ➨

Confeti cayendo por el blog

1 comentó


Para una celebracion o simplemente para decoracion, os voy a contar un truquito para añadir confeti en vuestro blog. Se trata de un codigo Javascript, utilizando la etiqueta canvas (HTML5), que hace que vaya cayendo desde la cabecera hacia abajo y que ademas sigue al cursor al moverlo de lado a lado. Para que funcione correctamente, debemos añadir dicho codigo en la plantilla antes de la etiqueta </body>. Si quereis cambiar la distancia desde que cae hasta que desaparece el confeti, modificad los numeros que estan en color verde, a mas tanto por ciento mas distancia y viceversa.

ver demostracion

ver el codigo
<canvas style="height:20%;width:100%;position:absolute;left:0px;top:0px;z-index:99999;" id="confeti"></canvas>

<script type="text/javascript">
  //<![CDATA[
(function() {

(function() {
  var Confetti, PI_2, canvas, colors, confetti, context, drawCircle, i, range, resizeWindow, xpos;

  canvas = document.getElementById("confeti");

  context = canvas.getContext("2d");

  window.w = window.innerWidth;

  window.h = window.innerHeight;

  resizeWindow = function() {
    window.w = canvas.width = window.innerWidth;
    return window.h = canvas.height = window.innerHeight;
  };

  window.addEventListener('resize', resizeWindow, false);

  window.onload = function() {
    return setTimeout(resizeWindow, 0);
  };

  range = function(a, b) {
    return (b - a) * Math.random() + a;
  };

  colors = [[85, 71, 106], [174, 61, 99], [219, 56, 83], [244, 92, 68], [248, 182, 70]];

  PI_2 = 2 * Math.PI;

  drawCircle = function(x, y, r, style) {
    context.beginPath();
    context.arc(x, y, r, 0, PI_2, false);
    context.fillStyle = style;
    return context.fill();
  };

  xpos = 0.5;

  document.onmousemove = function(e) {
    return xpos = e.pageX / w;
  };

  window.requestAnimationFrame = (function() {
    return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
      return window.setTimeout(callback, 1000 / 60);
    };
  })();

  Confetti = (function() {

    function Confetti() {
      this.style = colors[~~range(0, 5)];
      this.rgb = "rgba(" + this.style[0] + "," + this.style[1] + "," + this.style[2];
      this.r = ~~range(2, 6);
      this.replace();
    }

    Confetti.prototype.replace = function() {
      this.opacity = 0;
      this.dop = 0.03 * range(1, 5);
      this.x = range(-2 * this.r, w - 2 * this.r);
      this.y = range(-2 * this.r, h - 2 * this.r);
      this.xmax = w - this.r;
      this.ymax = h - this.r;
      this.vx = 2 * Math.random() + 10 * xpos - 6;
      return this.vy = this.r + range(-1, 1);
    };

    Confetti.prototype.draw = function() {
      var _ref;
      this.x += this.vx;
      this.y += this.vy;
      this.opacity += this.dop;
      if (this.opacity > 1) {
        this.opacity = 1;
        this.dop *= -1;
      }
      if (this.opacity < 0 || this.y > this.ymax || !((0 < (_ref = this.x) && _ref < this.xmax))) {
        this.replace();
      }
      return drawCircle(~~this.x, ~~this.y, this.r, "" + this.rgb + "," + this.opacity + ")");
    };

    return Confetti;

  })();

  confetti = (function() {
    var _results;
    _results = [];
    for (i = 1; i <= 300; i++) {
      _results.push(new Confetti);
    }
    return _results;
  })();

  window.step = function() {
    var c, _i, _len, _results;
    requestAnimationFrame(step);
    context.clearRect(0, 0, w, h);
    _results = [];
    for (_i = 0, _len = confetti.length; _i < _len; _i++) {
      c = confetti[_i];
      _results.push(c.draw());
    }
    return _results;
  };

  step();

}).call(this);

})();
//]]>
</script>


leer articulo ➨

Presentacion de imagenes apiladas

1 comentó

Cuando queremos mostrar una galeria de imagenes en nuestro blog, pienso que la manera estetica de hacerla es fundamental. Si es original y encima tiene animaciones como esta, no te digo 'na'. Utilizando el CSS3 y el Javascript se consigue esta presentacion con las imagenes apiladas-desordenadas que al hacer click sobre ellas, estas van pasando como si lo hicieramos con la mano.






















Si quieres ponerla en tu blog o web, primero copia este codigo y pegalo en tu plantilla antes de </head>.
Ver/Ocultar Codigo

<script>
(function() {

var queue = false,
    touch = 'ontouchstart' in document.documentElement ? true : false,
    images = document.querySelector('.images'),
    imageWidth = images.firstElementChild.offsetWidth,
    imageOffset = images.firstElementChild.offsetLeft,
    cssTransition = function () {
      var body = document.body || document.documentElement,
          style = body.style,
          property = 'Transition',
          vendors = ['Moz', 'Webkit', 'O', 'ms'],
          vendorCount = vendors.length;

      if (typeof style[property.toLowerCase()] === 'string') {
        return true;
      }

      do {
        if (typeof style[vendors[vendorCount] + property] === 'string') {
          return true;
        }
      } while (vendorCount--);

      return false;
    },
    timeout = cssTransition() ? [300, 400] : [0, 0];

images.addEventListener(touch ? 'touchend' : 'click', function (event) {
  if (!queue) {
    queue = true;

    var direction = ((touch ? event.changedTouches[0].pageX : event.pageX) - imageOffset) > imageWidth / 2 ? 'slide-right' : 'slide-left',
        last = images.lastElementChild.classList;

    last.add(direction);

    setTimeout(function () {
      last.remove(direction);
      last.add('back');

      setTimeout(function () {
        images.insertBefore(images.lastElementChild, images.firstElementChild);
        last.remove('back');
        queue = false;
      }, timeout[0]);
    }, timeout[1]);
  }
}, false);

})();
  </script>


<style>
.images {
  cursor: pointer;position:relative;
}
.images:hover .image:nth-child(4) {
  -webkit-transform: rotate(10deg) translateX(50px);
  -moz-transform: rotate(10deg) translateX(50px);
  -ms-transform: rotate(10deg) translateX(50px);
  -o-transform: rotate(10deg) translateX(50px);
  transform: rotate(10deg) translateX(50px);
}
.images:hover .image:nth-child(3) {
  -webkit-transform: rotate(3deg) translateX(75px);
  -moz-transform: rotate(3deg) translateX(75px);
  -ms-transform: rotate(3deg) translateX(75px);
  -o-transform: rotate(3deg) translateX(75px);
  transform: rotate(3deg) translateX(75px);
}
.images:hover .image:nth-child(2) {
  -webkit-transform: rotate(-2deg) translateX(-50px);
  -moz-transform: rotate(-2deg) translateX(-50px);
  -ms-transform: rotate(-2deg) translateX(-50px);
  -o-transform: rotate(-2deg) translateX(-50px);
  transform: rotate(-2deg) translateX(-50px);
}
.images:hover .image:first-child {
  -webkit-transform: rotate(-8deg) translateX(-75px) translateY(-10px);
  -moz-transform: rotate(-8deg) translateX(-75px) translateY(-10px);
  -ms-transform: rotate(-8deg) translateX(-75px) translateY(-10px);
  -o-transform: rotate(-8deg) translateX(-75px) translateY(-10px);
  transform: rotate(-8deg) translateX(-75px) translateY(-10px);
}

.image {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 250px;
  width: 300px;
  margin-top: -110px;
  margin-left: -105px;
  border: 5px solid #fff;
  border-bottom-width: 15px;
  -webkit-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
-moz-box-shadow:    7px 7px 5px rgba(50, 50, 50, 0.75);
box-shadow:         7px 7px 5px rgba(50, 50, 50, 0.75);
  z-index: 2;
  -webkit-transition: -webkit-transform 0.3s ease-in-out;
  -moz-transition: -moz-transform 0.3s ease-in-out;
  -o-transition: -o-transform 0.3s ease-in-out;
  transition: transform 0.3s ease-in-out;
}
.image:first-child {
  -webkit-transform: rotate(8deg);
  -moz-transform: rotate(8deg);
  -ms-transform: rotate(8deg);
  -o-transform: rotate(8deg);
  transform: rotate(8deg);
}
.image:nth-child(2) {
  -webkit-transform: rotate(2deg);
  -moz-transform: rotate(2deg);
  -ms-transform: rotate(2deg);
  -o-transform: rotate(2deg);
  transform: rotate(2deg);
}
.image:nth-child(3) {
  -webkit-transform: rotate(-3deg);
  -moz-transform: rotate(-3deg);
  -ms-transform: rotate(-3deg);
  -o-transform: rotate(-3deg);
  transform: rotate(-3deg);
}
.image:nth-child(4) {
  -webkit-transform: rotate(-10deg);
  -moz-transform: rotate(-10deg);
  -ms-transform: rotate(-10deg);
  -o-transform: rotate(-10deg);
  transform: rotate(-10deg);
}
.image:last-child {
  -webkit-transform: rotate(-5deg);
  -moz-transform: rotate(-5deg);
  -ms-transform: rotate(-5deg);
  -o-transform: rotate(-5deg);
  transform: rotate(-5deg);
}
.image.slide-right {
  -webkit-transform: rotate(290deg) translateX(250px);
  -moz-transform: rotate(290deg) translateX(250px);
  -ms-transform: rotate(290deg) translateX(250px);
  -o-transform: rotate(290deg) translateX(250px);
  transform: rotate(290deg) translateX(250px);
}
.image.slide-left {
  -webkit-transform: rotate(-290deg) translateX(-250px);
  -moz-transform: rotate(-290deg) translateX(-250px);
  -ms-transform: rotate(-290deg) translateX(-250px);
  -o-transform: rotate(-290deg) translateX(-250px);
  transform: rotate(-290deg) translateX(-250px);
}
.image.back {
  z-index: 1;
}
  </style>




Ahora, cada vez que queramos mostrar esta presentacion, agregamos el siguiente codigo, añadiendo las urls de las imagenes.

<div class="images">
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
  <img class="image" src="URL DE LA IMAGEN" style="border:8px solid #ffffff;"/>
</div>




leer articulo ➨

Cronometro digital usando Javascript y CSS

1 comentó





En otro articulo ya os mostre un cronometro grande muy chulo creado con CSS3 integramente. El que os enseño hoy tiene un diseño mas minimalista, pero elegante y a la par efectivo a la vez, pardiez. Tambien esta realizado con CSS3, que es el que provoca las animaciones, aparte del diseño visual. Es verdad que utiliza un poco de Javascript para simplificar el codigo, pero de eso ya os hablare en otra entrada. Sus funciones basicas mediante botones son: Start, Stop y  Reset, como todo buen cronometro que se precie. Si quereis ponerlo en vuestra pagina, mas abajo teneis el codigo completito.




0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
:
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7 8 9
:
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7 8 9
:
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9







Ver/Ocultar Codigo



<center><div class="container">
 <input id="start" name="controls" type="radio" />
 <input id="stop" name="controls" type="radio" />
 <input id="reset" name="controls" type="radio" />
 <div class="timer">
  <div class="cell">
   <div class="numbers tenhour moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
  <div class="cell">
   <div class="numbers hour moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
  <div class="cell divider"><div class="numbers">:</div></div>
  <div class="cell">
   <div class="numbers tenminute movesix">0 1 2 3 4 5 6</div>
  </div>
  <div class="cell">
   <div class="numbers minute moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
  <div class="cell divider"><div class="numbers">:</div></div>
  <div class="cell">
   <div class="numbers tensecond movesix">0 1 2 3 4 5 6</div>
  </div>
  <div class="cell">
   <div class="numbers second moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
  <div class="cell divider"><div class="numbers">:</div></div>
  <div class="cell">
   <div class="numbers milisecond moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
  <div class="cell">
   <div class="numbers tenmilisecond moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
  <div class="cell">
   <div class="numbers hundredmilisecond moveten">0 1 2 3 4 5 6 7 8 9</div>
  </div>
 </div>
 <div id="timer_controls">
  <label for="start">Start</label>
  <label for="stop">Stop</label>
  <label for="reset">Reset</label>
 </div>
</div></center>


<script src="http://hostredeando.ucoz.es/js/prefixfree.js" type="text/javascript"></script>


<style>
.container {
 padding: 20px;width: 400px;
 text-align: center;
}

.timer {
 padding: 10px;
 background: #000000;
 overflow: hidden;
 display: inline-block;
 border: 7px solid #efefef;
 border-radius: 5px;
 position: relative;
box-shadow:
  0 -2px 10px 1px rgba(0, 0, 0, 0.75),
  0 5px 20px -10px rgba(0, 0, 0, 1);

}

.cell {
 width: 0.60em;
 height: 40px;
 font-size: 50px;
 overflow: hidden;
 position: relative;
 float: left;
}

.numbers {
 width: 0.6em;
 line-height: 40px;
 font-family: digital, arial, verdana;
 text-align: center;
 color: #fff;

 position: absolute;
 top: 0;
 left: 0;


 text-shadow: 0 0 5px rgba(255, 255, 255, 1);
}

#timer_controls {
 margin-top: 5px;
}
#timer_controls label {
 box-shadow:
  0 -2px 10px 1px rgba(0, 0, 0, 0.75),
  0 5px 20px -10px rgba(0, 0, 0, 1);

cursor: pointer;
 padding: 5px 10px;
 background: #efefef;
 font-family: arial, verdana, tahoma;
 font-size: 11px;
 border-radius: 0 0 3px 3px;border:1px solid #989293;
}
input[name="controls"] {display: none;}


#stop:checked~.timer .numbers {animation-play-state: paused;}
#start:checked~.timer .numbers {animation-play-state: running;}
#reset:checked~.timer .numbers {animation: none;}

.moveten {
 /*The digits move but dont look good. We will use steps now
 10 digits = 10 steps. You can now see the digits swapping instead of
 moving pixel-by-pixel*/
 animation: moveten 1s steps(10, end) infinite;
 /*By default animation should be paused*/
 animation-play-state: paused;
}
.movesix {
 animation: movesix 1s steps(6, end) infinite;
 animation-play-state: paused;
}

.second {animation-duration: 10s;}
.tensecond {animation-duration: 60s;} /*60 times .second*/

.milisecond {animation-duration: 1s;} /*1/10th of .second*/
.tenmilisecond {animation-duration: 0.1s;}
.hundredmilisecond {animation-duration: 0.01s;}

.minute {animation-duration: 600s;} /*60 times .second*/
.tenminute {animation-duration: 3600s;} /*60 times .minute*/

.hour {animation-duration: 36000s;} /*60 times .minute*/
.tenhour {animation-duration: 360000s;} /*10 times .hour*/

@keyframes moveten {
 0% {top: 0;}
 100% {top: -400px;}
 /*height = 40. digits = 10. hence -400 to move it completely to the top*/
}

@keyframes movesix {
 0% {top: 0;}
 100% {top: -240px;}
 /*height = 40. digits = 6. hence -240 to move it completely to the top*/
}

@font-face {
 font-family: 'digital';
 src: url('http://thecodeplayer.com/uploads/fonts/DS-DIGI.TTF');

</style>






leer articulo ➨

Pluma animada que escribe lo que tu le pongas (con Javascript)

8 comentaron

¿Os gustan los efectos con Javascript? ¿Si? Pues este que estais viendo y leyendo seguro que os atrae.
Aplicando un script, 2 imagenes y un toque de CSS, conseguireis esta animacion para ponerla en vuestro blog o web.
Todo lo que escribais ira apareciendo poco a poco en vuestra pagina como si lo estuvierais escribiendo a mano con una pluma antigua.
Como podreis apreciar, la pluma poco a poco se va quedando sin tinta, cuando esto pasa, ella misma se moja en el tintero y vuelve a escribir con el trazo mas nitido.
Para poner este magnifico efecto de escritura, teneis que copiar el Codigo 1 y añadirlo en la plantilla de vuestro blog antes de </head> y guardar.
Una vez hecho esto, agregais el Codigo 2 alli donde querais mostrar este efecto, sustituyendo lo que esta en rojo por el texto querais poner.
¡Facilisimo!

tintero
CODIGO 1


<script type="text/javascript">
//<![CDATA[
window.onload = function(){

var vLetter = document.getElementById('escritura');
var iSpeedInk = 5;
var sText = document.getElementById('escritura_src').innerHTML;
var iCurChar = 0;
var sChars = '<span>';
var iCurInk = 0;
var sCurCaret = '';
var sCaret = " <img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiphZFazuCkpzYYmnR8LvHs21DLLG9ajyCZdrRG5e2oofMi6GWK-Awm3UncyeizEHY8XsXpD8E7XKL_-yJ_Ggyz54bqn-b4CTZmmIRp5fNGhfhiZRkoesnORv09kCa6mjSOkdDgNM1BTmE/s143/pluma.gif' style='position:absolute' />";

var doStep = function () {
var sChar = sText.charAt(iCurChar);
var iDelay = 32;

if (sChar == '') {
sCurCaret = '';
} else if (sChar == '|') {
sChars = sChars.substring(0, sChars.length-1);
iDelay = 64;
} else if (sChar == '<') {
var iPos = sText.indexOf('>', iCurChar);
sChar = sText.substring(iCurChar, iPos + 1);
iCurChar = iPos;
} else if (sChar == '&') {
var iPos = sText.indexOf(';', iCurChar);
sChar = sText.substring(iCurChar, iPos + 1);
iCurChar = iPos;
} else if (sChar == '.') {
iDelay = 300;
} else if (sChar == ',') {
iDelay = 100;
} else if (sChar == ' ') {
iDelay = 32;
} else if (iCurChar > 5) {
sCurCaret = sCaret;
}

// expenditure of ink
if (sChar == ' ') {
iCurInk += iSpeedInk;
sChar = '</span><span style="color:RGB(' + (iCurInk) + ',' + (iCurInk) + ',' + (iCurInk) + ')">' + sChar;
}

if (document.getElementById('tintero').style.visibility == 'visible') {
sCurCaret = sCaret;
document.getElementById('tintero').style.visibility = 'hidden';
sChar = '</span><span style="color:RGB(0,0,0)">' + sChar;
}

if (iCurInk > 160) {
iCurInk = 0;
document.getElementById('tintero').style.visibility = 'visible';
iDelay = 1000;
sCurCaret = '';
}

sChars += sChar;

if (iCurChar == sText.length - 1)
sCurCaret = '';

vLetter.innerHTML = sChars + sCurCaret;

iCurChar++;

if (iCurChar < sText.length) {
setTimeout(doStep, 20 + iDelay);
}
}

doStep();
};
//]]>
</script>

<style>
#tintero {
bottom: 100px;
left: 140px;
position: relative;
visibility: hidden;
}
#escritura{
font-family: Comic Sans MS;
font-size: 18px;
font-weight: bold;
margin: 50px auto;
position: relative;
width: 75%;
}
#escritura_src {
display: none;
}
</style>




CODIGO 2

<div id="escritura_src">
Escribe aqui el texto que quieras
</div>

<div id="escritura"></div>
<img alt="tintero" id="tintero" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn8j47LK2sIfxsAQrjBnIuZ8W1p6IKPwCcVs2GifTL3t6QEIAQwo2Loa5Ycf8i21HTqeGk3gIwSFt6smK-ueSOXluZX6zm3Wc7ZHzxW3l7wVO2WBPfIJogM8ZJdHlIx1Ulc_th73jfvXw/s184/tintero2.gif" />



leer articulo ➨