Top Banner
 Le FULL Vectoriel
37

Le Full vectoriel

Jul 29, 2015

Download

Internet

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Le Full vectoriel

   

Le FULL Vectoriel

Page 2: Le Full vectoriel

Qui... est Christophe Villeneuve ?

<<

afup – lemug.fr – mysql – mariadb – drupal – demoscene – firefoxos – drupagora – phptour – forumphp – solutionlinux – demoinparis – Lire à toi – eyrolles – editions eni – programmez – linux pratique – webriver – phptv – neuros ­ elephpant

Page 3: Le Full vectoriel

Sommaire

● Bitmap● Vectoriel avec SVG● Démo● Le code de la démo

Page 4: Le Full vectoriel

● Bitmap

Bitmap VS Vectoriel

● Vectoriel

= Pas de perte= pixelisé

Page 5: Le Full vectoriel

Afficher une image 

<img src='atari.png'>

<img src='atari.png' width='100'>

Page 6: Le Full vectoriel
Page 7: Le Full vectoriel

SVG

● Signifie Scalable Vector Graphics● Format vectoriel en XML● Supporte 

– Image statique– Animation et l'interactivité avec 

Synchronized Multimedia Integration Language (SMIL)– Couleur RGB avec une option Alpha en plus

● Mémorise le 'graph' objet en mémoire dans le DOM● Couplage à CSS

Page 8: Le Full vectoriel

Image

1

Page 9: Le Full vectoriel

Définir

● code

<svg      width="200px" height="200px"      viewBox="0 0 200 200"     version="1.1"         xmlns="http://www.w3.org/2000/svg"     xmlns:xlink="http://www.w3.org/1999/xlink">      <img src='atari.svg'>

</svg> 

Page 10: Le Full vectoriel

Code SVG<svg   xmlns:svg="http://www.w3.org/2000/svg"   xmlns="http://www.w3.org/2000/svg"   Version="1.1"    width="120"   height="143"   id="svg2">

  <rect     width="5.9977822"  height="37.701492"     x="111.20078"     y="102.76726"     id="rect3"     style="fill:#000000" />  <path     d="m 16.5,101.8125 c ­1.889001,0 ­3.50086,1.17072 ­4.125,2.84375 l 0,0.0312 ­10.6875,35.78125 6.40625,0 2.46875,­9.71875 11.90625,0 2.59375,9.71875 6.5625,0 ­10.96875,­35.8125 ­0.03125,0 C 19.994483,102.9913 18.390703,101.8125 16.5,101.8125 z m ­0.0625,8.21875 4.125,15.6875 ­8.15625,0 4.03125,­15.6875 z"     id="path5"     style="fill:#000000" />

…</svg>

Page 11: Le Full vectoriel

Résultat

Page 12: Le Full vectoriel

Texte

Page 13: Le Full vectoriel

Les bases du SVG

<svg xmlns="http://www.w3.org/2000/svg"

    xmlns:xlink="http://www.w3.org/1999/xlink">

    <text x="5" y="190"

          transform="translate(40) rotate(­45 10 50)"

    >Very Important Party</text>

</svg>

Texte

Habillage

    <rect x="40" y="5" height="110" width="110"

          style="stroke:#ff0000; fill: #CFCFCF;"

          transform="translate(30) rotate(28 50 35)">

    </rect>

Page 14: Le Full vectoriel

Carré

2

Page 15: Le Full vectoriel

Définir

● Positionnement

Page 16: Le Full vectoriel

Définir la forme

    <rect fill="#AFBCC7" stroke="#646464" stroke­width="5px" x="100px" y="100px"width="100px" height="100px">        </rect>

Page 17: Le Full vectoriel

Animer la forme

    <rect fill="#AFBCC7" stroke="#646464" stroke­width="5px" x="100px" y="100px"     width="100px" height="100px">

    <animateTransform        attributeType="XML"        attributeName="transform"        type="rotate"        from="0,150,150" to="360,150,150"        begin="0s" dur="5s"        repeatCount="indefinite"/>    </rect>

Page 18: Le Full vectoriel

Script complet

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" Width="320" height="320">

    <rect fill="#AFBCC7" stroke="#646464" stroke­width="5px" x="100px" y="100px"  width="100px" height="100px">    <animateTransform        attributeType="XML"        attributeName="transform"        type="rotate"        from="0,150,150" to="360,150,150"        begin="0s" dur="5s"        repeatCount="indefinite"/>    </rect></svg>

Page 19: Le Full vectoriel

Résultat… en live3

Page 20: Le Full vectoriel

Effet Gradient

5

Page 21: Le Full vectoriel

Définir

● Courbe

<svg xmlns="http://www.w3.org/2000/svg">

<radialGradient id= "Grad" cx="80%" r="20%" spreadMethod="reflect">    <stop offset="5%" stop­color="red"/>    <stop offset="50%" stop­color="green" stop­opacity="1"/>    <stop offset="90%" stop­color="blue" stop­opacity="0.5"/></radialGradient>

<rect x="0" y="0" width="200" height="200"  style="fill:url(#Grad);" /> 

</svg>

Page 22: Le Full vectoriel

Définir

● Bordure

<rect x="30" y="10" 

width="200" height="200" rx="10" ry="10" 

style="fill:url(#effet); stroke: #CCCCCC; stroke­width: 3;" 

/> 

Page 23: Le Full vectoriel

Définir

● Animation en Javascript<svg xmlns="http://www.w3.org/2000/svg" onload = "startup()" >…</svg>

<script>function startup(){            radialGrad = document.getElementById("effet");

  for (i=0; i<ngradient;i++) {    stops[i]=document.getElementById("stops"+i);  }

 timer = setInterval("vary()",100);}</script>

Page 24: Le Full vectoriel

Résultat

● Après quelques modifications– Dimensions– Point de départ

6

Page 25: Le Full vectoriel

Effet CurveCourbe de bézier

7

Page 26: Le Full vectoriel

Qu'est ce...

● Modifier la rotation d'un trait

<path d="M50,50 Q50,100 100,100"style="stroke: #006666; fill:none;"/>

Page 27: Le Full vectoriel

Réalisation

● En code

<svg xmlns:svg="http://www.w3.org/2000/svg" Version="1.1" width="400" height="450" onload = "startup()">

<script><g> <path id="curve" stroke-width="3" stroke="red" fill="none" /> </g></svg>

Page 28: Le Full vectoriel

Définir

● Les formes

    f(t)=sin(at)+cos(bt+phi)

Page 29: Le Full vectoriel

Définir

● Boucle

function Animate(){  def(alpha, beta, phi);  phi += dphi;    phi %= 2.0*Math.PI;  if(phi > 2.0*Math.PI ­ dphi &&                                    phi < 2.0*Math.PI + dphi) {      if(alpha==11) {      if(beta==11) {alpha=1; beta=2;  }      else {       alpha=1; beta++      }    }    Else { alpha++;    }    modifyColor();  }  modifyEquation(); }

Page 30: Le Full vectoriel

Résultat… en live7

Page 31: Le Full vectoriel

Effet de gouttes

8

Page 32: Le Full vectoriel

Réalisation

● En code

<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" onload="startUp()" onresize="resize()">...</svg>

Page 33: Le Full vectoriel

Définir la goutte

<defs> <radialGradient id="rg" cx="20%" cy="20%" r="100%" fx="30%" fy="30%" >   <stop stop­color="white" offset="0" stop­opacity="0.5"/>   <stop stop­color="aqua" offset="20%" stop­opacity="0.5"/>   <stop stop­color="blue" offset="80%" stop­opacity="0.5"/>   <stop stop­color="blue" offset="100%" stop­opacity="0.5"/> </radialGradient></defs>

<rect height="100%" width="100%" fill="black"/>

<g id="GroupOfBubbles"> <circle id="Bubble" cx="­150" cy="­150" r="50" fill="url(#rg)" /></g>

Page 34: Le Full vectoriel

Animation

● En codefunction startUp() { resize(); var mybubble = document.getElementById("Bubble")

xm = nx/2; ym = ny/2;

for(i=0;i<NB;i++) { object[i] = new makeSphere(i); }

setInterval("for (i in object)object[i].moveSphere()",16)}

Page 35: Le Full vectoriel

WebApps

Page 36: Le Full vectoriel

WebApps

● Pas de pertes de qualités● C'est un format léger et souple● Mutli­devices / Multi­appareils

https://developer.mozilla.org/fr/docs/Web/SVG

Page 37: Le Full vectoriel

Merci● Code source inspiré du web

Questions

@hellosct1

@neuro_paris

livre Drupal avancé ­ Editions Eyrolles ­ Christophe Villeneuve ­ Vanessa Kovalsky David