Advertisement
AzisMM

index.html

Jul 11th, 2022
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Penskalaan</title>
  8.     <style>
  9.         canvas {
  10.             border: 2px solid #000;
  11.         }
  12.     </style>
  13.     <script src="transform.js"></script>
  14.     <script src="grafika_lib.js"></script>
  15. </head>
  16. <body>
  17.     <canvas id="canvas1" width="400" height="400"></canvas>
  18.     <script>
  19.         var canvasKita;
  20.         canvasKita = document.querySelector("#canvas1");
  21.         var ctx;
  22.         ctx = canvasKita.getContext("2d");
  23.         var imageDataSaya = ctx.getImageData(0, 0, canvasKita.width, canvasKita.height);
  24.  
  25.         var point_array = [
  26.             {x:100,y:100},
  27.             {x:150,y:150},
  28.             {x:50,y:150},
  29.         ];
  30.        
  31.         polygon(imageDataSaya, point_array, 0,255,0);
  32.  
  33.         // Translasi
  34.         // var point_array2 = [];
  35.         // var temp = translasi(point_array[0], {x:100,y:0});
  36.         // point_array2.push(temp);
  37.         // temp = translasi(point_array[1], {x:100,y:0});
  38.         // point_array2.push(temp);
  39.         // temp = translasi(point_array[2], {x:100,y:0});
  40.         // point_array2.push(temp);
  41.  
  42.         // polygon(imageDataSaya, point_array2, 0,255,0);
  43.  
  44.  
  45.         // var point_array3 = [];
  46.         // var temp = penskalaan(point_array[0], {x:100,y:0});
  47.         // point_array3.push(temp);
  48.         // temp = penskalaan(point_array[1], {x:100,y:0});
  49.         // point_array3.push(temp);
  50.         // temp = penskalaan(point_array[2], {x:100,y:0});
  51.         // point_array3.push(temp);
  52.  
  53.         // polygon(imageDataSaya, point_array3, 0,0,255);
  54.  
  55.         ctx.putImageData(imageDataSaya, 0, 0);
  56.     </script>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement