SlideShare una empresa de Scribd logo
1 de 100
Web Grafik
Technologien
Toni Kaufmann




<canvas>


CANVAS          SVG        WEBGL




n3xd software studios ag
{
    bool session = !code_free;
}
Code Beispiele sind vereinfacht
     und nicht komplett
<canvas
>
setup



 0   1   2   3   4   5   6   7   8   9   <canvas id="canvas2d" 
 1
                                         " width="10" height="10">
 2
 3
 4                                           Your browser does not
 5                                           support the HTML 5 Canvas
 6
 7
                                             element.
 8
 9                                       </canvas>
setup



 0   1   2   3   4   5   6   7   8   9   <canvas id="canvas2d" 
 1
                                         " width="10" height="10">
 2
 3
 4                                           Your browser does not
 5                                           support the HTML 5 Canvas
 6
 7
                                             element.
 8
 9                                       </canvas>
init


                                          function draw() {
  0   1   2   3   4   5   6   7   8   9
                                              var cvs = document.
  1
  2                                             getElementById('canvas2d');
  3
  4                                           var ctx = cvs.getContext('2d');
  5
  6
  7                                           if (ctx) {
  8                                             ...
  9                                           }
                                          }
init


                                          function draw() {
  0   1   2   3   4   5   6   7   8   9
                                              var cvs = document.
  1
  2                                             getElementById('canvas2d');
  3
  4                                           var ctx = cvs.getContext('2d');
  5
  6
  7                                           if (ctx) {
  8                                             ...
  9                                           }
                                          }
init


                                          function draw() {
  0   1   2   3   4   5   6   7   8   9
                                              var cvs = document.
  1
  2                                             getElementById('canvas2d');
  3
  4                                           var ctx = cvs.getContext('2d');
  5
  6
  7                                           if (ctx) {
  8                                             ...
  9                                           }
                                          }
init


                                          function draw() {
  0   1   2   3   4   5   6   7   8   9
                                              var cvs = document.
  1
  2                                             getElementById('canvas2d');
  3
  4                                           var ctx = cvs.getContext('2d');
  5
  6
  7                                           if (ctx) {
  8                                             ...
  9                                           }
                                          }
drawin
   g


                                         function drawLine(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.moveTo(2,1);
 3
 4                                           ctx.lineTo(8,7);
 5
 6
 7                                           ctx.stroke();
 8                                       }
 9
drawin
   g


                                         function drawLine(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.moveTo(2,1);
 3
 4                                           ctx.lineTo(8,7);
 5
 6
 7                                           ctx.stroke();
 8                                       }
 9
drawin
   g


                                         function drawLine(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.moveTo(2,1);
 3
 4                                           ctx.lineTo(8,7);
 5
 6
 7                                           ctx.stroke();
 8                                       }
 9
drawin
   g


                                         function drawLine(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.moveTo(2,1);
 3
 4                                           ctx.lineTo(8,7);
 5
 6
 7                                           ctx.stroke();
 8                                       }
 9
drawin
   g



 0   1   2   3   4   5   6   7   8   9
 1                                       function drawQuadCircle(ctx) {
 2                                         ctx.moveTo(2,8);
 3                                         ctx.lineTo(2,2);
 4
 5
                                           ctx.lineTo(8,2);
 6                                         ctx.arc(2,2,6,0,PI/2,false);
 7                                         ctx.fill();
 8
                                         }
 9
drawin
   g



 0   1   2   3   4   5   6   7   8   9
 1                                       function drawQuadCircle(ctx) {
 2                                         ctx.moveTo(2,8);
 3                                         ctx.lineTo(2,2);
 4
 5
                                           ctx.lineTo(8,2);
 6                                         ctx.arc(2,2,6,0,PI/2,false);
 7                                         ctx.fill();
 8
                                         }
 9
drawin
   g



 0   1   2   3   4   5   6   7   8   9
 1                                       function drawQuadCircle(ctx) {
 2                                         ctx.moveTo(2,8);
 3                                         ctx.lineTo(2,2);
 4
 5
                                           ctx.lineTo(8,2);
 6                                         ctx.arc(2,2,6,0,PI/2,false);
 7                                         ctx.fill();
 8
                                         }
 9
drawin
   g



 0   1   2   3   4   5   6   7   8   9
 1                                       function drawQuadCircle(ctx) {
 2                                         ctx.moveTo(2,8);
 3                                         ctx.lineTo(2,2);
 4
 5
                                           ctx.lineTo(8,2);
 6                                         ctx.arc(2,2,6,0,PI/2,false);
 7                                         ctx.fill();
 8
                                         }
 9
drawin
   g



 0   1   2   3   4   5   6   7   8   9
 1                                       function drawQuadCircle(ctx) {
 2                                         ctx.moveTo(2,8);
 3                                         ctx.lineTo(2,2);
 4
 5
                                           ctx.lineTo(8,2);
 6                                         ctx.arc(2,2,6,0,PI/2,false);
 7                                         ctx.fill();
 8
                                         }
 9
drawin
   g



 0   1   2   3   4   5   6   7   8   9
 1                                       function drawQuadCircle(ctx) {
 2                                         ctx.moveTo(2,8);
 3                                         ctx.lineTo(2,2);
 4
 5
                                           ctx.lineTo(8,2);
 6                                         ctx.arc(2,2,6,0,PI/2,false);
 7                                         ctx.fill();
 8
                                         }
 9
contex
   t

 strokeStyle




 ctx.strokeStyle = “rgba(0,0,255,1)”;
contex
   t

 strokeStyle   lineWidth




 ctx.strokeStyle = “rgba(0,0,255,1)”;
 ctx.lineWidth = 2.5;
contex
   t

 strokeStyle   lineWidth   lineCap




 ctx.strokeStyle = “rgba(0,0,255,1)”;
 ctx.lineWidth = 2.5;
 ctx.lineCap = “round”;
contex
   t

 strokeStyle   lineWidth   lineCap      lineJoin




 ctx.strokeStyle = “rgba(0,0,255,1)”;
 ctx.lineWidth = 2.5;
 ctx.lineCap = “round”;
 ctx.lineJoin = “bevel”;
text



 0   1   2   3   4   5   6   7   8   9
 1
 2                                       drawHello(ctx) {
 3                                         ctx.font = “5px Sans”;
 4                                         ctx.fillColor = “blue”;
 5
 6
                                           ctx.fillText(“HELLO”,2,2)
 7                                       }
 8
 9
bilder


                                          drawImage(ctx) {
  0   1   2   3   4   5   6   7   8   9     var img = new Image();
  1                                         img.src = “myimage.png”;
  2
  3
                                            img.onload = function() {
  4                                           ctx.drawImage(img,
  5                                            4,3,6,6,
  6                                            2,2,6,6);
  7
  8
                                            }
  9                                       }
bilder


                                          drawImage(ctx) {
  0   1   2   3   4   5   6   7   8   9     var img = new Image();
  1                                         img.src = “myimage.png”;
  2
  3
                                            img.onload = function() {
  4                                           ctx.drawImage(img,
  5                                            4,3,6,6,
  6                                            2,2,6,6);
  7
  8
                                            }
  9                                       }
bilder


                                          drawImage(ctx) {
  0   1   2   3   4   5   6   7   8   9     var img = new Image();
  1                                         img.src = “myimage.png”;
  2
  3
                                            img.onload = function() {
  4                                           ctx.drawImage(img,
  5                                            4,3,6,6,
  6                                            2,2,6,6);
  7
  8
                                            }
  9                                       }
mehr...



  Bezier
mehr...



  Bezier   Rectangle
mehr...



  Bezier   Rectangle   Path
mehr...



  Bezier   Rectangle   Path   Gradient
transformation
       s


                                         rotate45degreesCCW(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
                                           ctx.tranform(1,0,0,1,0,0);
 2                                         ctx.translate(2,3);
 3                                         ctx.rotate(-PI/4);
 4                                         ctx.translate(-2,-3);
 5
 6
                                           ctx.moveTo(2,3);
 7                                         ctx.lineTo(2,8);
 8                                       }
 9
transformation
       s


                                         rotate45degreesCCW(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
                                           ctx.tranform(1,0,0,1,0,0);
 2                                         ctx.translate(2,3);
 3                                         ctx.rotate(-PI/4);
 4                                         ctx.translate(-2,-3);
 5
 6
                                           ctx.moveTo(2,3);
 7                                         ctx.lineTo(2,8);
 8                                       }
 9
transformation
       s


                                         rotate45degreesCCW(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
                                           ctx.tranform(1,0,0,1,0,0);
 2                                         ctx.translate(2,3);
 3                                         ctx.rotate(-PI/4);
 4                                         ctx.translate(-2,-3);
 5
 6
                                           ctx.moveTo(2,3);
 7                                         ctx.lineTo(2,8);
 8                                       }
 9
transformation
       s


                                         rotate45degreesCCW(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
                                           ctx.tranform(1,0,0,1,0,0);
 2                                         ctx.translate(2,3);
 3                                         ctx.rotate(-PI/4);
 4                                         ctx.translate(-2,-3);
 5
 6
                                           ctx.moveTo(2,3);
 7                                         ctx.lineTo(2,8);
 8                                       }
 9
transformation
       s


                                         rotate45degreesCCW(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
                                           ctx.tranform(1,0,0,1,0,0);
 2                                         ctx.translate(2,3);
 3                                         ctx.rotate(-PI/4);
 4                                         ctx.translate(-2,-3);
 5
 6
                                           ctx.moveTo(2,3);
 7                                         ctx.lineTo(2,8);
 8                                       }
 9
transformation
       s


                                                 rotate45degreesCCW(ctx) {
 0   1   2   3   4   5   6   7   8   9
 1
                                                   ctx.tranform(1,0,0,1,0,0);
 2                                                 ctx.translate(2,3);
 3       0   1   2   3   4   5   6   7   8   9     ctx.rotate(-PI/4);
 4       1                                         ctx.translate(-2,-3);
 5       2
 6       3
                                                   ctx.moveTo(2,3);
 7       4                                         ctx.lineTo(2,8);
 8       5                                       }
 9       6
         7
         8
         9
transformation
       s



                                 9
                                 8
                             7
                                         rotate45degreesCCW(ctx) {
                         6
                         5


 0   1   2   3   4   5   6   7   8   9
                                           ctx.tranform(1,0,0,1,0,0);
                     4




 1
                 3




 2                                         ctx.translate(2,3);
             2
             1




 3                                         ctx.rotate(-PI/4);
         0




 4                                         ctx.translate(-2,-3);
             1
             2




 5
                                           ctx.moveTo(2,3);
                 3




 6
                     4




                                           ctx.lineTo(2,8);
                         5




 7
                         6




 8                                       }
                             7




 9
                                 8
                                 9
transformation
       s

                        9
                    8
                7
                6




                                            rotate45degreesCCW(ctx) {
            5
        4




    0   1   2   3   4   5   6   7   8   9
                                              ctx.tranform(1,0,0,1,0,0);
        3




    1
    2




    2                                         ctx.translate(2,3);
1
0




    3                                         ctx.rotate(-PI/4);
1




    4                                         ctx.translate(-2,-3);
    2
        3




    5
                                              ctx.moveTo(2,3);
        4




    6
            5




    7                                         ctx.lineTo(2,8);
                6
                7




    8                                       }
                    8




    9
                        9
transformation
       s

                        9
                    8
                7
                6




                                            rotate45degreesCCW(ctx) {
            5
        4




    0   1   2   3   4   5   6   7   8   9
                                              ctx.tranform(1,0,0,1,0,0);
        3




    1
    2




    2                                         ctx.translate(2,3);
1
0




    3                                         ctx.rotate(-PI/4);
1




    4                                         ctx.translate(-2,-3);
    2
        3




    5
                                              ctx.moveTo(2,3);
        4




    6
            5




    7                                         ctx.lineTo(2,8);
                6
                7




    8                                       }
                    8




    9
                        9
ompositionen

                                         drawComposition(ctx) {
                                           ctx.fillStyle = ‘blue’;
                                           ctx.rect(2,2,4,4);
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.globalCompositeOperation
 3                                                = ‘source-atop’;
 4
 5
 6                                           ctx.fillStyle = ‘red’;
 7                                           ctx.beginPath();
 8                                           ctx.arc(5,5,2,0,PI*2,true);
 9
                                             ctx.closePath();
                                             ctx.fill();
                                         }
ompositionen

                                         drawComposition(ctx) {
                                           ctx.fillStyle = ‘blue’;
                                           ctx.rect(2,2,4,4);
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.globalCompositeOperation
 3                                                = ‘source-atop’;
 4
 5
 6                                           ctx.fillStyle = ‘red’;
 7                                           ctx.beginPath();
 8                                           ctx.arc(5,5,2,0,PI*2,true);
 9
                                             ctx.closePath();
                                             ctx.fill();
                                         }
ompositionen

                                         drawComposition(ctx) {
                                           ctx.fillStyle = ‘blue’;
                                           ctx.rect(2,2,4,4);
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.globalCompositeOperation
 3                                                = ‘source-atop’;
 4
 5
 6                                           ctx.fillStyle = ‘red’;
 7                                           ctx.beginPath();
 8                                           ctx.arc(5,5,2,0,PI*2,true);
 9
                                             ctx.closePath();
                                             ctx.fill();
                                         }
ompositionen

                                         drawComposition(ctx) {
                                           ctx.fillStyle = ‘blue’;
                                           ctx.rect(2,2,4,4);
 0   1   2   3   4   5   6   7   8   9
 1
 2                                           ctx.globalCompositeOperation
 3                                                = ‘source-atop’;
 4
 5
 6                                           ctx.fillStyle = ‘red’;
 7                                           ctx.beginPath();
 8                                           ctx.arc(5,5,2,0,PI*2,true);
 9
                                             ctx.closePath();
                                             ctx.fill();
                                         }
ompositionen




   source-over      source-in      source-out      source-atop      lighter   xor




 destination-over destination-in destination-out destination-atop   darker    copy
clipping

                                          function clipping(ctx) {

                                              ctx.beginPath();
  0   1   2   3   4   5   6   7   8   9
  1                                           ctx.moveTo(2,1);
  2                                           ctx.lineTo(2,8);
  3                                           ctx.lineTo(7,6);
  4
  5
                                              ctx.closePath();
  6                                           ctx.clip();
  7
  8                                           ctx.fillStyle = "blue";
  9
                                              ctx.fillRect(1,3,7,4);
                                          }
clipping

                                          function clipping(ctx) {

                                              ctx.beginPath();
  0   1   2   3   4   5   6   7   8   9
  1                                           ctx.moveTo(2,1);
  2                                           ctx.lineTo(2,8);
  3                                           ctx.lineTo(7,6);
  4
  5
                                              ctx.closePath();
  6                                           ctx.clip();
  7
  8                                           ctx.fillStyle = "blue";
  9
                                              ctx.fillRect(1,3,7,4);
                                          }
clipping

                                          function clipping(ctx) {

                                              ctx.beginPath();
  0   1   2   3   4   5   6   7   8   9
  1                                           ctx.moveTo(2,1);
  2                                           ctx.lineTo(2,8);
  3                                           ctx.lineTo(7,6);
  4
  5
                                              ctx.closePath();
  6                                           ctx.clip();
  7
  8                                           ctx.fillStyle = "blue";
  9
                                              ctx.fillRect(1,3,7,4);
                                          }
www.n3xd.com
<svg>
deklarativ


                   <!DOCTYPE html>
                   ...
                   <body>
           100mm    <svg id="svg1"
                       width=”100mm” height="100mm"
                       xmlns="w3.org/2000/svg">

                      <line x1="0"     y1="0"
                            x2="100mm" y2="100mm"
                             style="stroke:red;
   100mm                     stroke-width:10mm"/>
                     </svg>
                   </body>
                   </html>
deklarativ


                   <!DOCTYPE html>
                   ...
                   <body>
           100mm    <svg id="svg1"
                       width=”100mm” height="100mm"
                       xmlns="w3.org/2000/svg">

                      <line x1="0"     y1="0"
                            x2="100mm" y2="100mm"
                             style="stroke:red;
   100mm                     stroke-width:10mm"/>
                     </svg>
                   </body>
                   </html>
deklarativ


                   <!DOCTYPE html>
                   ...
                   <body>
           100mm    <svg id="svg1"
                       width=”100mm” height="100mm"
                       xmlns="w3.org/2000/svg">

                      <line x1="0"     y1="0"
                            x2="100mm" y2="100mm"
                             style="stroke:red;
   100mm                     stroke-width:10mm"/>
                     </svg>
                   </body>
                   </html>
deklarativ


                   <!DOCTYPE html>
                   ...
                   <body>
           100mm    <svg id="svg1"
                       width=”100mm” height="100mm"
                       xmlns="w3.org/2000/svg">

                      <line x1="0"     y1="0"
                            x2="100mm" y2="100mm"
                             style="stroke:red;
   100mm                     stroke-width:10mm"/>
                     </svg>
                   </body>
                   </html>
deklarativ


                   <!DOCTYPE html>
                   ...
                   <body>
           100mm    <svg id="svg1"
                       width=”100mm” height="100mm"
                       xmlns="w3.org/2000/svg">

                      <line x1="0"     y1="0"
                            x2="100mm" y2="100mm"
                             style="stroke:red;
   100mm                     stroke-width:10mm"/>
                     </svg>
                   </body>
                   </html>
rafik primitiven


  Line
rafik primitiven


  Line   Rectangle
rafik primitiven


  Line   Rectangle   Circle
rafik primitiven


  Line   Rectangle   Circle   Ellipse
rafik primitiven


  Line      Rectangle   Circle   Ellipse




  Poligon
rafik primitiven


  Line      Rectangle   Circle   Ellipse




  Poligon   Polyline
rafik primitiven


  Line      Rectangle   Circle   Ellipse




  Poligon   Polyline    Path
rafik primitiven


  Line      Rectangle   Circle   Ellipse




  Poligon   Polyline    Path     Text
dom tree
                   function draw() {
                     var line1 = document
                        .getElementById('line1');

                     line1.setAttribute("style"
                      ,"stroke:blue
           100mm
                       ;stroke-width:20mm");
                         "
                     line1.setAttribute("x1"
                       ,"50mm");
                   }
                   ...
                   <line id="line1"
  100mm              x1="20mm" y1="20mm"
                     x2="100mm" y2="20mm"
                     style="stroke:red
                        ;stroke-width:10mm"/>
dom tree
                   function draw() {
                     var line1 = document
                        .getElementById('line1');

                     line1.setAttribute("style"
                      ,"stroke:blue
           100mm
                       ;stroke-width:20mm");
                         "
                     line1.setAttribute("x1"
                       ,"50mm");
                   }
                   ...
                   <line id="line1"
  100mm              x1="20mm" y1="20mm"
                     x2="100mm" y2="20mm"
                     style="stroke:red
                        ;stroke-width:10mm"/>
dom tree
                   function draw() {
                     var line1 = document
                        .getElementById('line1');

                     line1.setAttribute("style"
                      ,"stroke:blue
           100mm
                       ;stroke-width:20mm");
                         "
                     line1.setAttribute("x1"
                       ,"50mm");
                   }
                   ...
                   <line id="line1"
  100mm              x1="20mm" y1="20mm"
                     x2="100mm" y2="20mm"
                     style="stroke:red
                        ;stroke-width:10mm"/>
dom tree
                   function draw() {
                     var line1 = document
                        .getElementById('line1');

                     line1.setAttribute("style"
                      ,"stroke:blue
           100mm
                       ;stroke-width:20mm");
                         "
                     line1.setAttribute("x1"
                       ,"50mm");
                   }
                   ...
                   <line id="line1"
  100mm              x1="20mm" y1="20mm"
                     x2="100mm" y2="20mm"
                     style="stroke:red
                        ;stroke-width:10mm"/>
editoren


  Inkscape
editoren


  Inkscape   Illustrator
ewegte bilder
ewegte bilder
ewegte bilder
{webgl
   }
anvas-context


          <canvas id="canvas3d" 
          " width="10" height="10">
          </canvas>

          function draw3d() {
            var cvs = document.
               getElementById('canvas3d');
            var ctx = cvs.getContext(
               'experimental-webgl');

              if (ctx) {
                ...
              }
          }
anvas-context


          <canvas id="canvas3d" 
          " width="10" height="10">
          </canvas>

          function draw3d() {
            var cvs = document.
               getElementById('canvas3d');
            var ctx = cvs.getContext(
               'experimental-webgl');

              if (ctx) {
                ...
              }
          }
pipeline
pipeline




  Motherboard
pipeline




  Motherboard   Grafikkarte
pipeline




  Motherboard   Grafikkarte   Monitor
opengl api


 Motherboar
     d




Monitor




              OpenGL/DirectX
Grafikkarte         API
2560x1440≈3.7mio
       px




Monitor




Grafikkarte
texturen




           OpenGL




           pro Szene
modell




         OpenGL




         pro Frame
ertex=punkt




          Vertex
          Shader




         pro Vertex
ragment=pixel




         Fragment Shader




        pro Fragment (Pixel)
a lot to do!


      Modell


   Vertex Shader


    Fragement


    WebGL Code
a lot to do!       cubeVertexPositionBuffer = gl.createBuffer();
                   gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexPositionBuffer);
                   vertices = [
                   /* Front */ -1.0,-1.0, 1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
                   /* Back*/     -1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0,
                   /* Top */     -1.0, 1.0,-1.0,-1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,-1.0,
                   /* Bottom */-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,-1.0,-1.0,1.0,
                   /* Right*/     1.0,-1.0,-1.0,1.0, 1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,
                   /* Left */ -1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,];
                   gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(vertices),gl.STATIC_DRAW);
                   ...
                     var vertexNormals = [
                   /* Front*/ 0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,
                   /* Back */ 0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,
                   /* Top */     0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,
                   /* Bottom */0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,

      Modell       /* Right */ 1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,
                   /* Left */ -1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0];
                   ...
                   var textureCoords = [
                   /* Front*/ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
                   /* Back */ 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
                   /* Top */ 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
                   /* Bottom */ 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0,

   Vertex Shader   /* Right */ 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
                   /* Left */ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,0.0, 1.0];
                   ...
                   var cubeVertexIndices = [
                   0, 1, 2,        0, 2, 3,    // Front face
                   4, 5, 6,        4, 6, 7,    // Back face
                   8, 9, 10,       8, 10, 11, // Top face
                   12, 13, 14,     12, 14, 15, // Bottom face

    Fragement      16, 17, 18,
                   20, 21, 22,
                   ...
                                   16, 18, 19, // Right face
                                   20, 22, 23 // Left face ];

                   myTexture = gl.createTexture();myTexture.image = new Image();
                   myTexture.image.onload = function () {
                   	    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
                         gl.bindTexture(gl.TEXTURE_2D,myTexture);
                         gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UBYTE, myTexture.image);

    WebGL Code           gl.texParameteri(gl.TEXTURE_2D,gl.MAG_FILTER,gl.LINEAR);
                         gl.texParameteri(gl.TEXTURE_2D,gl.MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
                         gl.generateMipmap(gl.TEXTURE_2D);
                         gl.bindTexture(gl.TEXTURE_2D, null);
                       }
                   myTexture.image.src = "image.png";
a lot to do!       <script id="shader-vs" type="x-shader/x-vertex">

                       attribute vec3 aVertexPosition;
                       attribute vec3 aVertexNormal;
                       attribute vec2 aTextureCoord;
                   	    	
                       uniform mat4 uMVMatrix;
                       uniform mat4 uPMatrix;
                       uniform mat3 uNMatrix;
                   	    	
                       uniform vec3 uAmbientColor;	

      Modell           uniform vec3 uLightingDirection;
                       uniform vec3 uDirectionalColor;
                   	    	
                       varying vec2 vTextureCoord;
                       varying vec3 vLightWeighting;
                   	    	
                       void main(void) {

   Vertex Shader            gl_Position = uPMatrix * uMVMatrix *
                                        vec4(aVertexPosition, 1.0);
                            vTextureCoord = aTextureCoord;
                   	       	
                            vec3 transformedNormal = uNMatrix * aVertexNormal;
                            float directionalLightWeighting =

    Fragement                       max(dot(transformedNormal, uLightingDirection),0.0);
                            vLightWeighting = uAmbientColor
                                   + uDirectionalColor * directionalLightWeighting;

                       }



    WebGL Code     </script>
a lot to do!
                   <script id="shader-fs" type="x-shader/x-fragment">

                    precision mediump float;
                   	 	
                    varying vec2 vTextureCoord;
                    varying vec3 vLightWeighting;
                   	 	
                    uniform sampler2D uSampler;
                   	 	

      Modell        void main(void) {

                         vec4 textureColor = texture2D(uSampler,
                                        vec2(vTextureCoord.s, vTextureCoord.t));

                         gl_FragColor = vec4(textureColor.rgb * vLightWeighting,
                                        textureColor.a);

   Vertex Shader     }



                   </script>




    Fragement


    WebGL Code
a lot to do!       // in init: shader loading, compiling, linking, installing
                   // also in init: uniform binding
                   ... not listed here!

                   // drawing
                   gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
                   gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

                   mat4.perspective(45,gl.viewportWidth/gl.viewportHeight,0.1,100.0,pMatrix);
                   mat4.identity(mvMatrix);
                   mat4.translate(mvMatrix, [0.0, 0.0, -5.0 + zOffset]);
                   mat4.rotate(mvMatrix, degToRad(xRot), [1, 0, 0]);
                   mat4.rotate(mvMatrix, degToRad(yRot), [0, 1, 0]);
                   mat4.rotate(mvMatrix, degToRad(zRot), [0, 0, 1]);

                   gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexPositionBuffer);

      Modell       gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute,
                             cubeVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);

                   gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexNormalBuffer);
                   gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute,
                             cubeVertexNormalBuffer.itemSize, gl.FLOAT, false, 0, 0);

                   gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexTextureCoordBuffer);

   Vertex Shader   gl.vertexAttribPointer(shaderProgram.textureCoordAttribute,
                             cubeVertexTextureCoordBuffer.itemSize, gl.FLOAT, false, 0, 0);

                   gl.activeTexture(gl.TEXTURE0);
                   gl.bindTexture(gl.TEXTURE_2D, crateTexture);
                   gl.uniform1i(shaderProgram.samplerUniform, 0);

                   gl.uniform1i(shaderProgram.useLightingUniform, lighting);

    Fragement      gl.uniform3f(shaderProgram.ambientColorUniform,0.2,0.2,0.2);

                   var lightingDirection = [xLight,-10,-10];
                   var adjustedLD = vec3.create();
                   vec3.normalize(lightingDirection, adjustedLD);
                   vec3.scale(adjustedLD, -1);
                   gl.uniform3fv(shaderProgram.lightingDirectionUniform, adjustedLD);



    WebGL Code     gl.uniform3f(shaderProgram.directionalColorUniform,0.8,0.8,0.8);

                   gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVertexIndexBuffer);
                   setMatrixUniforms();
                   gl.drawElements(gl.TRIANGLES,cubeVertexIndexBuffer.numItems
                        ,gl.UNSIGNED_SHORT, 0);
www.n3xd.com
www.zygotebody.co
       m
ow level api




1990
ibliotheken




1995
tools




2000
ow level again




 2010
√   ~   √
√   √   ~
    ~   √   √
≥3.2    ≥2.0   ≥4        ≥9
                     IE8: excanvas.js




≥5.0    ≥4.0   ≥10       ≥9

≥5.1                    Nein
        ≥4.0   ≥9
Config                  (IEWebGL)
Toni Kaufmann | El. Ing. HTL | dipl. Inf. Ing. ETH
tonik@n3xd.com | www.n3xd.com

Más contenido relacionado

La actualidad más candente

The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.10 book - Part 79 of 212The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.10 book - Part 79 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 63 of 88
The Ring programming language version 1.3 book - Part 63 of 88The Ring programming language version 1.3 book - Part 63 of 88
The Ring programming language version 1.3 book - Part 63 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189Mahmoud Samir Fayed
 
Node.js and angular js
Node.js and angular jsNode.js and angular js
Node.js and angular jsHyungKuIm
 
The Ring programming language version 1.5.3 book - Part 8 of 184
The Ring programming language version 1.5.3 book - Part 8 of 184The Ring programming language version 1.5.3 book - Part 8 of 184
The Ring programming language version 1.5.3 book - Part 8 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 7 of 180
The Ring programming language version 1.5.1 book - Part 7 of 180The Ring programming language version 1.5.1 book - Part 7 of 180
The Ring programming language version 1.5.1 book - Part 7 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 8 of 185
The Ring programming language version 1.5.4 book - Part 8 of 185The Ring programming language version 1.5.4 book - Part 8 of 185
The Ring programming language version 1.5.4 book - Part 8 of 185Mahmoud Samir Fayed
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & WebkitQT-day
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 108 of 210
The Ring programming language version 1.9 book - Part 108 of 210The Ring programming language version 1.9 book - Part 108 of 210
The Ring programming language version 1.9 book - Part 108 of 210Mahmoud Samir Fayed
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004Seonki Paik
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184Mahmoud Samir Fayed
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasSteve Purkis
 
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLМихаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLSergey Platonov
 
The Ring programming language version 1.2 book - Part 60 of 84
The Ring programming language version 1.2 book - Part 60 of 84The Ring programming language version 1.2 book - Part 60 of 84
The Ring programming language version 1.2 book - Part 60 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 48 of 84
The Ring programming language version 1.2 book - Part 48 of 84The Ring programming language version 1.2 book - Part 48 of 84
The Ring programming language version 1.2 book - Part 48 of 84Mahmoud Samir Fayed
 

La actualidad más candente (20)

The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.10 book - Part 79 of 212The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.10 book - Part 79 of 212
 
The Ring programming language version 1.3 book - Part 63 of 88
The Ring programming language version 1.3 book - Part 63 of 88The Ring programming language version 1.3 book - Part 63 of 88
The Ring programming language version 1.3 book - Part 63 of 88
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189
 
Lecture1 classes3
Lecture1 classes3Lecture1 classes3
Lecture1 classes3
 
Node.js and angular js
Node.js and angular jsNode.js and angular js
Node.js and angular js
 
The Ring programming language version 1.5.3 book - Part 8 of 184
The Ring programming language version 1.5.3 book - Part 8 of 184The Ring programming language version 1.5.3 book - Part 8 of 184
The Ring programming language version 1.5.3 book - Part 8 of 184
 
The Ring programming language version 1.5.1 book - Part 7 of 180
The Ring programming language version 1.5.1 book - Part 7 of 180The Ring programming language version 1.5.1 book - Part 7 of 180
The Ring programming language version 1.5.1 book - Part 7 of 180
 
The Ring programming language version 1.5.4 book - Part 8 of 185
The Ring programming language version 1.5.4 book - Part 8 of 185The Ring programming language version 1.5.4 book - Part 8 of 185
The Ring programming language version 1.5.4 book - Part 8 of 185
 
Qt & Webkit
Qt & WebkitQt & Webkit
Qt & Webkit
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180
 
The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88
 
The Ring programming language version 1.9 book - Part 108 of 210
The Ring programming language version 1.9 book - Part 108 of 210The Ring programming language version 1.9 book - Part 108 of 210
The Ring programming language version 1.9 book - Part 108 of 210
 
Bs webgl소모임004
Bs webgl소모임004Bs webgl소모임004
Bs webgl소모임004
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLМихаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
 
The Ring programming language version 1.2 book - Part 60 of 84
The Ring programming language version 1.2 book - Part 60 of 84The Ring programming language version 1.2 book - Part 60 of 84
The Ring programming language version 1.2 book - Part 60 of 84
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
 
The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189The Ring programming language version 1.6 book - Part 71 of 189
The Ring programming language version 1.6 book - Part 71 of 189
 
The Ring programming language version 1.2 book - Part 48 of 84
The Ring programming language version 1.2 book - Part 48 of 84The Ring programming language version 1.2 book - Part 48 of 84
The Ring programming language version 1.2 book - Part 48 of 84
 

Destacado

Water k9 training deck 11 11-14
Water k9 training deck 11 11-14Water k9 training deck 11 11-14
Water k9 training deck 11 11-14Suzanne Elshult
 
Power Point Definicions
Power Point DefinicionsPower Point Definicions
Power Point DefinicionsTubaaa
 
Understanding Social Media’s Impact on Business
Understanding Social Media’s Impact on BusinessUnderstanding Social Media’s Impact on Business
Understanding Social Media’s Impact on BusinessJared Degnan
 
PCN09 - Business Podcasting: There Is A Secret Sauce
PCN09 - Business Podcasting: There Is A Secret SaucePCN09 - Business Podcasting: There Is A Secret Sauce
PCN09 - Business Podcasting: There Is A Secret SauceJared Degnan
 
Profesionalizacija veb-sajtova polaznika i izmena šablona naslovne strane
Profesionalizacija veb-sajtova polaznika i izmena šablona naslovne straneProfesionalizacija veb-sajtova polaznika i izmena šablona naslovne strane
Profesionalizacija veb-sajtova polaznika i izmena šablona naslovne straneAleksandar Urošević
 
Mary Jane Ashmore.Experience2011.Current.Docx1
Mary Jane Ashmore.Experience2011.Current.Docx1Mary Jane Ashmore.Experience2011.Current.Docx1
Mary Jane Ashmore.Experience2011.Current.Docx1adventuremj680
 
Archival education in Overijssel and the Netherlands
Archival education in Overijssel and the NetherlandsArchival education in Overijssel and the Netherlands
Archival education in Overijssel and the NetherlandsArkivformidling
 
Research Brief: Developer Personalities Introduction
Research Brief: Developer Personalities IntroductionResearch Brief: Developer Personalities Introduction
Research Brief: Developer Personalities IntroductionJeff Hadfield
 
Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011
Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011
Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011Jeff Hadfield
 
Marketing to Developers: How are they different and how do I talk to them?
Marketing to Developers: How are they different and how do I talk to them?Marketing to Developers: How are they different and how do I talk to them?
Marketing to Developers: How are they different and how do I talk to them?Jeff Hadfield
 

Destacado (19)

Elektronska pošta
Elektronska poštaElektronska pošta
Elektronska pošta
 
Water k9 training deck 11 11-14
Water k9 training deck 11 11-14Water k9 training deck 11 11-14
Water k9 training deck 11 11-14
 
Power Point Definicions
Power Point DefinicionsPower Point Definicions
Power Point Definicions
 
Understanding Social Media’s Impact on Business
Understanding Social Media’s Impact on BusinessUnderstanding Social Media’s Impact on Business
Understanding Social Media’s Impact on Business
 
PCN09 - Business Podcasting: There Is A Secret Sauce
PCN09 - Business Podcasting: There Is A Secret SaucePCN09 - Business Podcasting: There Is A Secret Sauce
PCN09 - Business Podcasting: There Is A Secret Sauce
 
Profesionalizacija veb-sajtova polaznika i izmena šablona naslovne strane
Profesionalizacija veb-sajtova polaznika i izmena šablona naslovne straneProfesionalizacija veb-sajtova polaznika i izmena šablona naslovne strane
Profesionalizacija veb-sajtova polaznika i izmena šablona naslovne strane
 
Carros
CarrosCarros
Carros
 
ICBA Ad Campaign
ICBA Ad CampaignICBA Ad Campaign
ICBA Ad Campaign
 
Only in spain
Only in spainOnly in spain
Only in spain
 
Mary Jane Ashmore.Experience2011.Current.Docx1
Mary Jane Ashmore.Experience2011.Current.Docx1Mary Jane Ashmore.Experience2011.Current.Docx1
Mary Jane Ashmore.Experience2011.Current.Docx1
 
Kulturarv i Second Life
Kulturarv i Second LifeKulturarv i Second Life
Kulturarv i Second Life
 
Archival education in Overijssel and the Netherlands
Archival education in Overijssel and the NetherlandsArchival education in Overijssel and the Netherlands
Archival education in Overijssel and the Netherlands
 
Unapređivanje WordPress veb-sajta
Unapređivanje WordPress veb-sajtaUnapređivanje WordPress veb-sajta
Unapređivanje WordPress veb-sajta
 
Research Brief: Developer Personalities Introduction
Research Brief: Developer Personalities IntroductionResearch Brief: Developer Personalities Introduction
Research Brief: Developer Personalities Introduction
 
Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011
Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011
Hadfield - Marketing to Developers - Microsoft VSIP Summit Oct 2011
 
aviozvisulPro
aviozvisulProaviozvisulPro
aviozvisulPro
 
Modern Mind
Modern MindModern Mind
Modern Mind
 
Marketing to Developers: How are they different and how do I talk to them?
Marketing to Developers: How are they different and how do I talk to them?Marketing to Developers: How are they different and how do I talk to them?
Marketing to Developers: How are they different and how do I talk to them?
 
Digging Deeper
Digging DeeperDigging Deeper
Digging Deeper
 

Similar a Web Grafik Technologien

HTML5 Canvas (Wall Clock).pptx
HTML5 Canvas (Wall Clock).pptxHTML5 Canvas (Wall Clock).pptx
HTML5 Canvas (Wall Clock).pptxAhmadAbba6
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer developmentAndrey Karpov
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Platonov Sergey
 
(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++Amazon Web Services
 
Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Andrey Karpov
 
Kafka Connect implementation at GumGum
Kafka Connect implementation at GumGumKafka Connect implementation at GumGum
Kafka Connect implementation at GumGumKarim Lamouri
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Docker, Inc.
 
I need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfI need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfallurafashions98
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++vidyamittal
 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Getachew Ganfur
 
Easy Scaling with Open Source Data Structures, by Talip Ozturk
Easy Scaling with Open Source Data Structures, by Talip OzturkEasy Scaling with Open Source Data Structures, by Talip Ozturk
Easy Scaling with Open Source Data Structures, by Talip OzturkZeroTurnaround
 
Василий Сорокин, Простой REST сервер на Qt с рефлексией
Василий Сорокин, Простой REST сервер на Qt с рефлексиейВасилий Сорокин, Простой REST сервер на Qt с рефлексией
Василий Сорокин, Простой REST сервер на Qt с рефлексиейSergey Platonov
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkZachary Blair
 

Similar a Web Grafik Technologien (20)

HTML5 Canvas (Wall Clock).pptx
HTML5 Canvas (Wall Clock).pptxHTML5 Canvas (Wall Clock).pptx
HTML5 Canvas (Wall Clock).pptx
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer development
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
 
Css5 canvas
Css5 canvasCss5 canvas
Css5 canvas
 
(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++(DEV204) Building High-Performance Native Cloud Apps In C++
(DEV204) Building High-Performance Native Cloud Apps In C++
 
Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...
 
Ss
SsSs
Ss
 
Kafka Connect implementation at GumGum
Kafka Connect implementation at GumGumKafka Connect implementation at GumGum
Kafka Connect implementation at GumGum
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
 
I need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdfI need to create a page looks like a picture. But it looks different.pdf
I need to create a page looks like a picture. But it looks different.pdf
 
Qt Network Explained (Portuguese)
Qt Network Explained (Portuguese)Qt Network Explained (Portuguese)
Qt Network Explained (Portuguese)
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++
 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01
 
Easy Scaling with Open Source Data Structures, by Talip Ozturk
Easy Scaling with Open Source Data Structures, by Talip OzturkEasy Scaling with Open Source Data Structures, by Talip Ozturk
Easy Scaling with Open Source Data Structures, by Talip Ozturk
 
Computer Programming- Lecture 9
Computer Programming- Lecture 9Computer Programming- Lecture 9
Computer Programming- Lecture 9
 
Qt Rest Server
Qt Rest ServerQt Rest Server
Qt Rest Server
 
Василий Сорокин, Простой REST сервер на Qt с рефлексией
Василий Сорокин, Простой REST сервер на Qt с рефлексиейВасилий Сорокин, Простой REST сервер на Qt с рефлексией
Василий Сорокин, Простой REST сервер на Qt с рефлексией
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
Mobile Web 5.0
Mobile Web 5.0Mobile Web 5.0
Mobile Web 5.0
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Último (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Web Grafik Technologien

  • 1. Web Grafik Technologien Toni Kaufmann <canvas> CANVAS SVG WEBGL n3xd software studios ag
  • 2. { bool session = !code_free; }
  • 3. Code Beispiele sind vereinfacht und nicht komplett
  • 5. setup 0 1 2 3 4 5 6 7 8 9 <canvas id="canvas2d"  1 " width="10" height="10"> 2 3 4 Your browser does not 5 support the HTML 5 Canvas 6 7 element. 8 9 </canvas>
  • 6. setup 0 1 2 3 4 5 6 7 8 9 <canvas id="canvas2d"  1 " width="10" height="10"> 2 3 4 Your browser does not 5 support the HTML 5 Canvas 6 7 element. 8 9 </canvas>
  • 7. init function draw() { 0 1 2 3 4 5 6 7 8 9 var cvs = document. 1 2 getElementById('canvas2d'); 3 4 var ctx = cvs.getContext('2d'); 5 6 7 if (ctx) { 8 ... 9 } }
  • 8. init function draw() { 0 1 2 3 4 5 6 7 8 9 var cvs = document. 1 2 getElementById('canvas2d'); 3 4 var ctx = cvs.getContext('2d'); 5 6 7 if (ctx) { 8 ... 9 } }
  • 9. init function draw() { 0 1 2 3 4 5 6 7 8 9 var cvs = document. 1 2 getElementById('canvas2d'); 3 4 var ctx = cvs.getContext('2d'); 5 6 7 if (ctx) { 8 ... 9 } }
  • 10. init function draw() { 0 1 2 3 4 5 6 7 8 9 var cvs = document. 1 2 getElementById('canvas2d'); 3 4 var ctx = cvs.getContext('2d'); 5 6 7 if (ctx) { 8 ... 9 } }
  • 11. drawin g function drawLine(ctx) { 0 1 2 3 4 5 6 7 8 9 1 2 ctx.moveTo(2,1); 3 4 ctx.lineTo(8,7); 5 6 7 ctx.stroke(); 8 } 9
  • 12. drawin g function drawLine(ctx) { 0 1 2 3 4 5 6 7 8 9 1 2 ctx.moveTo(2,1); 3 4 ctx.lineTo(8,7); 5 6 7 ctx.stroke(); 8 } 9
  • 13. drawin g function drawLine(ctx) { 0 1 2 3 4 5 6 7 8 9 1 2 ctx.moveTo(2,1); 3 4 ctx.lineTo(8,7); 5 6 7 ctx.stroke(); 8 } 9
  • 14. drawin g function drawLine(ctx) { 0 1 2 3 4 5 6 7 8 9 1 2 ctx.moveTo(2,1); 3 4 ctx.lineTo(8,7); 5 6 7 ctx.stroke(); 8 } 9
  • 15. drawin g 0 1 2 3 4 5 6 7 8 9 1 function drawQuadCircle(ctx) { 2 ctx.moveTo(2,8); 3 ctx.lineTo(2,2); 4 5 ctx.lineTo(8,2); 6 ctx.arc(2,2,6,0,PI/2,false); 7 ctx.fill(); 8 } 9
  • 16. drawin g 0 1 2 3 4 5 6 7 8 9 1 function drawQuadCircle(ctx) { 2 ctx.moveTo(2,8); 3 ctx.lineTo(2,2); 4 5 ctx.lineTo(8,2); 6 ctx.arc(2,2,6,0,PI/2,false); 7 ctx.fill(); 8 } 9
  • 17. drawin g 0 1 2 3 4 5 6 7 8 9 1 function drawQuadCircle(ctx) { 2 ctx.moveTo(2,8); 3 ctx.lineTo(2,2); 4 5 ctx.lineTo(8,2); 6 ctx.arc(2,2,6,0,PI/2,false); 7 ctx.fill(); 8 } 9
  • 18. drawin g 0 1 2 3 4 5 6 7 8 9 1 function drawQuadCircle(ctx) { 2 ctx.moveTo(2,8); 3 ctx.lineTo(2,2); 4 5 ctx.lineTo(8,2); 6 ctx.arc(2,2,6,0,PI/2,false); 7 ctx.fill(); 8 } 9
  • 19. drawin g 0 1 2 3 4 5 6 7 8 9 1 function drawQuadCircle(ctx) { 2 ctx.moveTo(2,8); 3 ctx.lineTo(2,2); 4 5 ctx.lineTo(8,2); 6 ctx.arc(2,2,6,0,PI/2,false); 7 ctx.fill(); 8 } 9
  • 20. drawin g 0 1 2 3 4 5 6 7 8 9 1 function drawQuadCircle(ctx) { 2 ctx.moveTo(2,8); 3 ctx.lineTo(2,2); 4 5 ctx.lineTo(8,2); 6 ctx.arc(2,2,6,0,PI/2,false); 7 ctx.fill(); 8 } 9
  • 21. contex t strokeStyle ctx.strokeStyle = “rgba(0,0,255,1)”;
  • 22. contex t strokeStyle lineWidth ctx.strokeStyle = “rgba(0,0,255,1)”; ctx.lineWidth = 2.5;
  • 23. contex t strokeStyle lineWidth lineCap ctx.strokeStyle = “rgba(0,0,255,1)”; ctx.lineWidth = 2.5; ctx.lineCap = “round”;
  • 24. contex t strokeStyle lineWidth lineCap lineJoin ctx.strokeStyle = “rgba(0,0,255,1)”; ctx.lineWidth = 2.5; ctx.lineCap = “round”; ctx.lineJoin = “bevel”;
  • 25. text 0 1 2 3 4 5 6 7 8 9 1 2 drawHello(ctx) { 3 ctx.font = “5px Sans”; 4 ctx.fillColor = “blue”; 5 6 ctx.fillText(“HELLO”,2,2) 7 } 8 9
  • 26. bilder drawImage(ctx) { 0 1 2 3 4 5 6 7 8 9 var img = new Image(); 1 img.src = “myimage.png”; 2 3 img.onload = function() { 4 ctx.drawImage(img, 5 4,3,6,6, 6 2,2,6,6); 7 8 } 9 }
  • 27. bilder drawImage(ctx) { 0 1 2 3 4 5 6 7 8 9 var img = new Image(); 1 img.src = “myimage.png”; 2 3 img.onload = function() { 4 ctx.drawImage(img, 5 4,3,6,6, 6 2,2,6,6); 7 8 } 9 }
  • 28. bilder drawImage(ctx) { 0 1 2 3 4 5 6 7 8 9 var img = new Image(); 1 img.src = “myimage.png”; 2 3 img.onload = function() { 4 ctx.drawImage(img, 5 4,3,6,6, 6 2,2,6,6); 7 8 } 9 }
  • 30. mehr... Bezier Rectangle
  • 31. mehr... Bezier Rectangle Path
  • 32. mehr... Bezier Rectangle Path Gradient
  • 33. transformation s rotate45degreesCCW(ctx) { 0 1 2 3 4 5 6 7 8 9 1 ctx.tranform(1,0,0,1,0,0); 2 ctx.translate(2,3); 3 ctx.rotate(-PI/4); 4 ctx.translate(-2,-3); 5 6 ctx.moveTo(2,3); 7 ctx.lineTo(2,8); 8 } 9
  • 34. transformation s rotate45degreesCCW(ctx) { 0 1 2 3 4 5 6 7 8 9 1 ctx.tranform(1,0,0,1,0,0); 2 ctx.translate(2,3); 3 ctx.rotate(-PI/4); 4 ctx.translate(-2,-3); 5 6 ctx.moveTo(2,3); 7 ctx.lineTo(2,8); 8 } 9
  • 35. transformation s rotate45degreesCCW(ctx) { 0 1 2 3 4 5 6 7 8 9 1 ctx.tranform(1,0,0,1,0,0); 2 ctx.translate(2,3); 3 ctx.rotate(-PI/4); 4 ctx.translate(-2,-3); 5 6 ctx.moveTo(2,3); 7 ctx.lineTo(2,8); 8 } 9
  • 36. transformation s rotate45degreesCCW(ctx) { 0 1 2 3 4 5 6 7 8 9 1 ctx.tranform(1,0,0,1,0,0); 2 ctx.translate(2,3); 3 ctx.rotate(-PI/4); 4 ctx.translate(-2,-3); 5 6 ctx.moveTo(2,3); 7 ctx.lineTo(2,8); 8 } 9
  • 37. transformation s rotate45degreesCCW(ctx) { 0 1 2 3 4 5 6 7 8 9 1 ctx.tranform(1,0,0,1,0,0); 2 ctx.translate(2,3); 3 ctx.rotate(-PI/4); 4 ctx.translate(-2,-3); 5 6 ctx.moveTo(2,3); 7 ctx.lineTo(2,8); 8 } 9
  • 38. transformation s rotate45degreesCCW(ctx) { 0 1 2 3 4 5 6 7 8 9 1 ctx.tranform(1,0,0,1,0,0); 2 ctx.translate(2,3); 3 0 1 2 3 4 5 6 7 8 9 ctx.rotate(-PI/4); 4 1 ctx.translate(-2,-3); 5 2 6 3 ctx.moveTo(2,3); 7 4 ctx.lineTo(2,8); 8 5 } 9 6 7 8 9
  • 39. transformation s 9 8 7 rotate45degreesCCW(ctx) { 6 5 0 1 2 3 4 5 6 7 8 9 ctx.tranform(1,0,0,1,0,0); 4 1 3 2 ctx.translate(2,3); 2 1 3 ctx.rotate(-PI/4); 0 4 ctx.translate(-2,-3); 1 2 5 ctx.moveTo(2,3); 3 6 4 ctx.lineTo(2,8); 5 7 6 8 } 7 9 8 9
  • 40. transformation s 9 8 7 6 rotate45degreesCCW(ctx) { 5 4 0 1 2 3 4 5 6 7 8 9 ctx.tranform(1,0,0,1,0,0); 3 1 2 2 ctx.translate(2,3); 1 0 3 ctx.rotate(-PI/4); 1 4 ctx.translate(-2,-3); 2 3 5 ctx.moveTo(2,3); 4 6 5 7 ctx.lineTo(2,8); 6 7 8 } 8 9 9
  • 41. transformation s 9 8 7 6 rotate45degreesCCW(ctx) { 5 4 0 1 2 3 4 5 6 7 8 9 ctx.tranform(1,0,0,1,0,0); 3 1 2 2 ctx.translate(2,3); 1 0 3 ctx.rotate(-PI/4); 1 4 ctx.translate(-2,-3); 2 3 5 ctx.moveTo(2,3); 4 6 5 7 ctx.lineTo(2,8); 6 7 8 } 8 9 9
  • 42. ompositionen drawComposition(ctx) { ctx.fillStyle = ‘blue’; ctx.rect(2,2,4,4); 0 1 2 3 4 5 6 7 8 9 1 2 ctx.globalCompositeOperation 3 = ‘source-atop’; 4 5 6 ctx.fillStyle = ‘red’; 7 ctx.beginPath(); 8 ctx.arc(5,5,2,0,PI*2,true); 9 ctx.closePath(); ctx.fill(); }
  • 43. ompositionen drawComposition(ctx) { ctx.fillStyle = ‘blue’; ctx.rect(2,2,4,4); 0 1 2 3 4 5 6 7 8 9 1 2 ctx.globalCompositeOperation 3 = ‘source-atop’; 4 5 6 ctx.fillStyle = ‘red’; 7 ctx.beginPath(); 8 ctx.arc(5,5,2,0,PI*2,true); 9 ctx.closePath(); ctx.fill(); }
  • 44. ompositionen drawComposition(ctx) { ctx.fillStyle = ‘blue’; ctx.rect(2,2,4,4); 0 1 2 3 4 5 6 7 8 9 1 2 ctx.globalCompositeOperation 3 = ‘source-atop’; 4 5 6 ctx.fillStyle = ‘red’; 7 ctx.beginPath(); 8 ctx.arc(5,5,2,0,PI*2,true); 9 ctx.closePath(); ctx.fill(); }
  • 45. ompositionen drawComposition(ctx) { ctx.fillStyle = ‘blue’; ctx.rect(2,2,4,4); 0 1 2 3 4 5 6 7 8 9 1 2 ctx.globalCompositeOperation 3 = ‘source-atop’; 4 5 6 ctx.fillStyle = ‘red’; 7 ctx.beginPath(); 8 ctx.arc(5,5,2,0,PI*2,true); 9 ctx.closePath(); ctx.fill(); }
  • 46. ompositionen source-over source-in source-out source-atop lighter xor destination-over destination-in destination-out destination-atop darker copy
  • 47. clipping function clipping(ctx) { ctx.beginPath(); 0 1 2 3 4 5 6 7 8 9 1 ctx.moveTo(2,1); 2 ctx.lineTo(2,8); 3 ctx.lineTo(7,6); 4 5 ctx.closePath(); 6 ctx.clip(); 7 8 ctx.fillStyle = "blue"; 9 ctx.fillRect(1,3,7,4); }
  • 48. clipping function clipping(ctx) { ctx.beginPath(); 0 1 2 3 4 5 6 7 8 9 1 ctx.moveTo(2,1); 2 ctx.lineTo(2,8); 3 ctx.lineTo(7,6); 4 5 ctx.closePath(); 6 ctx.clip(); 7 8 ctx.fillStyle = "blue"; 9 ctx.fillRect(1,3,7,4); }
  • 49. clipping function clipping(ctx) { ctx.beginPath(); 0 1 2 3 4 5 6 7 8 9 1 ctx.moveTo(2,1); 2 ctx.lineTo(2,8); 3 ctx.lineTo(7,6); 4 5 ctx.closePath(); 6 ctx.clip(); 7 8 ctx.fillStyle = "blue"; 9 ctx.fillRect(1,3,7,4); }
  • 51. <svg>
  • 52. deklarativ <!DOCTYPE html> ... <body> 100mm <svg id="svg1" width=”100mm” height="100mm" xmlns="w3.org/2000/svg"> <line x1="0" y1="0" x2="100mm" y2="100mm" style="stroke:red; 100mm stroke-width:10mm"/> </svg> </body> </html>
  • 53. deklarativ <!DOCTYPE html> ... <body> 100mm <svg id="svg1" width=”100mm” height="100mm" xmlns="w3.org/2000/svg"> <line x1="0" y1="0" x2="100mm" y2="100mm" style="stroke:red; 100mm stroke-width:10mm"/> </svg> </body> </html>
  • 54. deklarativ <!DOCTYPE html> ... <body> 100mm <svg id="svg1" width=”100mm” height="100mm" xmlns="w3.org/2000/svg"> <line x1="0" y1="0" x2="100mm" y2="100mm" style="stroke:red; 100mm stroke-width:10mm"/> </svg> </body> </html>
  • 55. deklarativ <!DOCTYPE html> ... <body> 100mm <svg id="svg1" width=”100mm” height="100mm" xmlns="w3.org/2000/svg"> <line x1="0" y1="0" x2="100mm" y2="100mm" style="stroke:red; 100mm stroke-width:10mm"/> </svg> </body> </html>
  • 56. deklarativ <!DOCTYPE html> ... <body> 100mm <svg id="svg1" width=”100mm” height="100mm" xmlns="w3.org/2000/svg"> <line x1="0" y1="0" x2="100mm" y2="100mm" style="stroke:red; 100mm stroke-width:10mm"/> </svg> </body> </html>
  • 58. rafik primitiven Line Rectangle
  • 59. rafik primitiven Line Rectangle Circle
  • 60. rafik primitiven Line Rectangle Circle Ellipse
  • 61. rafik primitiven Line Rectangle Circle Ellipse Poligon
  • 62. rafik primitiven Line Rectangle Circle Ellipse Poligon Polyline
  • 63. rafik primitiven Line Rectangle Circle Ellipse Poligon Polyline Path
  • 64. rafik primitiven Line Rectangle Circle Ellipse Poligon Polyline Path Text
  • 65. dom tree function draw() { var line1 = document .getElementById('line1'); line1.setAttribute("style" ,"stroke:blue 100mm ;stroke-width:20mm"); " line1.setAttribute("x1" ,"50mm"); } ... <line id="line1" 100mm x1="20mm" y1="20mm" x2="100mm" y2="20mm" style="stroke:red ;stroke-width:10mm"/>
  • 66. dom tree function draw() { var line1 = document .getElementById('line1'); line1.setAttribute("style" ,"stroke:blue 100mm ;stroke-width:20mm"); " line1.setAttribute("x1" ,"50mm"); } ... <line id="line1" 100mm x1="20mm" y1="20mm" x2="100mm" y2="20mm" style="stroke:red ;stroke-width:10mm"/>
  • 67. dom tree function draw() { var line1 = document .getElementById('line1'); line1.setAttribute("style" ,"stroke:blue 100mm ;stroke-width:20mm"); " line1.setAttribute("x1" ,"50mm"); } ... <line id="line1" 100mm x1="20mm" y1="20mm" x2="100mm" y2="20mm" style="stroke:red ;stroke-width:10mm"/>
  • 68. dom tree function draw() { var line1 = document .getElementById('line1'); line1.setAttribute("style" ,"stroke:blue 100mm ;stroke-width:20mm"); " line1.setAttribute("x1" ,"50mm"); } ... <line id="line1" 100mm x1="20mm" y1="20mm" x2="100mm" y2="20mm" style="stroke:red ;stroke-width:10mm"/>
  • 70. editoren Inkscape Illustrator
  • 74. {webgl }
  • 75. anvas-context <canvas id="canvas3d"  " width="10" height="10"> </canvas> function draw3d() { var cvs = document. getElementById('canvas3d'); var ctx = cvs.getContext( 'experimental-webgl'); if (ctx) { ... } }
  • 76. anvas-context <canvas id="canvas3d"  " width="10" height="10"> </canvas> function draw3d() { var cvs = document. getElementById('canvas3d'); var ctx = cvs.getContext( 'experimental-webgl'); if (ctx) { ... } }
  • 79. pipeline Motherboard Grafikkarte
  • 80. pipeline Motherboard Grafikkarte Monitor
  • 81. opengl api Motherboar d Monitor OpenGL/DirectX Grafikkarte API
  • 82. 2560x1440≈3.7mio px Monitor Grafikkarte
  • 83. texturen OpenGL pro Szene
  • 84. modell OpenGL pro Frame
  • 85. ertex=punkt Vertex Shader pro Vertex
  • 86. ragment=pixel Fragment Shader pro Fragment (Pixel)
  • 87. a lot to do! Modell Vertex Shader Fragement WebGL Code
  • 88. a lot to do! cubeVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexPositionBuffer); vertices = [ /* Front */ -1.0,-1.0, 1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, /* Back*/ -1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0, /* Top */ -1.0, 1.0,-1.0,-1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,-1.0, /* Bottom */-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,-1.0,-1.0,1.0, /* Right*/ 1.0,-1.0,-1.0,1.0, 1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0, /* Left */ -1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,]; gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(vertices),gl.STATIC_DRAW); ... var vertexNormals = [ /* Front*/ 0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0, /* Back */ 0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0, /* Top */ 0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0, /* Bottom */0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0, Modell /* Right */ 1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0, /* Left */ -1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0,-1.0,0.0,0.0]; ... var textureCoords = [ /* Front*/ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, /* Back */ 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, /* Top */ 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, /* Bottom */ 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, Vertex Shader /* Right */ 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, /* Left */ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,0.0, 1.0]; ... var cubeVertexIndices = [ 0, 1, 2, 0, 2, 3, // Front face 4, 5, 6, 4, 6, 7, // Back face 8, 9, 10, 8, 10, 11, // Top face 12, 13, 14, 12, 14, 15, // Bottom face Fragement 16, 17, 18, 20, 21, 22, ... 16, 18, 19, // Right face 20, 22, 23 // Left face ]; myTexture = gl.createTexture();myTexture.image = new Image(); myTexture.image.onload = function () { gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); gl.bindTexture(gl.TEXTURE_2D,myTexture); gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UBYTE, myTexture.image); WebGL Code gl.texParameteri(gl.TEXTURE_2D,gl.MAG_FILTER,gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D,gl.MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); gl.bindTexture(gl.TEXTURE_2D, null); } myTexture.image.src = "image.png";
  • 89. a lot to do! <script id="shader-vs" type="x-shader/x-vertex"> attribute vec3 aVertexPosition; attribute vec3 aVertexNormal; attribute vec2 aTextureCoord; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; uniform mat3 uNMatrix; uniform vec3 uAmbientColor; Modell uniform vec3 uLightingDirection; uniform vec3 uDirectionalColor; varying vec2 vTextureCoord; varying vec3 vLightWeighting; void main(void) { Vertex Shader gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); vTextureCoord = aTextureCoord; vec3 transformedNormal = uNMatrix * aVertexNormal; float directionalLightWeighting = Fragement max(dot(transformedNormal, uLightingDirection),0.0); vLightWeighting = uAmbientColor + uDirectionalColor * directionalLightWeighting; } WebGL Code </script>
  • 90. a lot to do! <script id="shader-fs" type="x-shader/x-fragment"> precision mediump float; varying vec2 vTextureCoord; varying vec3 vLightWeighting; uniform sampler2D uSampler; Modell void main(void) { vec4 textureColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); gl_FragColor = vec4(textureColor.rgb * vLightWeighting, textureColor.a); Vertex Shader } </script> Fragement WebGL Code
  • 91. a lot to do! // in init: shader loading, compiling, linking, installing // also in init: uniform binding ... not listed here! // drawing gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); mat4.perspective(45,gl.viewportWidth/gl.viewportHeight,0.1,100.0,pMatrix); mat4.identity(mvMatrix); mat4.translate(mvMatrix, [0.0, 0.0, -5.0 + zOffset]); mat4.rotate(mvMatrix, degToRad(xRot), [1, 0, 0]); mat4.rotate(mvMatrix, degToRad(yRot), [0, 1, 0]); mat4.rotate(mvMatrix, degToRad(zRot), [0, 0, 1]); gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexPositionBuffer); Modell gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, cubeVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexNormalBuffer); gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute, cubeVertexNormalBuffer.itemSize, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexTextureCoordBuffer); Vertex Shader gl.vertexAttribPointer(shaderProgram.textureCoordAttribute, cubeVertexTextureCoordBuffer.itemSize, gl.FLOAT, false, 0, 0); gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, crateTexture); gl.uniform1i(shaderProgram.samplerUniform, 0); gl.uniform1i(shaderProgram.useLightingUniform, lighting); Fragement gl.uniform3f(shaderProgram.ambientColorUniform,0.2,0.2,0.2); var lightingDirection = [xLight,-10,-10]; var adjustedLD = vec3.create(); vec3.normalize(lightingDirection, adjustedLD); vec3.scale(adjustedLD, -1); gl.uniform3fv(shaderProgram.lightingDirectionUniform, adjustedLD); WebGL Code gl.uniform3f(shaderProgram.directionalColorUniform,0.8,0.8,0.8); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVertexIndexBuffer); setMatrixUniforms(); gl.drawElements(gl.TRIANGLES,cubeVertexIndexBuffer.numItems ,gl.UNSIGNED_SHORT, 0);
  • 98. ~ √ √ √ ~ ~ √ √
  • 99. ≥3.2 ≥2.0 ≥4 ≥9 IE8: excanvas.js ≥5.0 ≥4.0 ≥10 ≥9 ≥5.1 Nein ≥4.0 ≥9 Config (IEWebGL)
  • 100. Toni Kaufmann | El. Ing. HTL | dipl. Inf. Ing. ETH tonik@n3xd.com | www.n3xd.com

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n