[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
<canvas id="drawTranslatedRectCanvas" width="300" height="200"></canvas> <script> (function () { var canvas = document.getElementById("drawTranslatedRectCanvas"); var context = canvas.getContext("2d"); context.strokeRect(0, 0, 100, 50); context.translate(80, 80); context.strokeRect(0, 0, 100, 50); })(); </script>
<canvas id="drawRotatedRectCanvas" width="300" height="200"></canvas> <script> (function() { var canvas = document.getElementById("drawRotatedRectCanvas"); var context = canvas.getContext("2d"); context.strokeRect(0, 0, 100, 50); context.rotate(Math.PI / 6); //30° context.strokeRect(0, 0, 100, 50); })(); </script>
<canvas id="drawScaledRectCanvas" width="300" height="200"></canvas> <script> (function() { var canvas = document.getElementById("drawScaledRectCanvas"); var context = canvas.getContext("2d"); context.strokeRect(0, 0, 100, 50); context.scale(2, 2); context.strokeRect(0, 0, 100, 50); })(); </script>
<canvas id="drawClearRectDemoCanvas" width="300" height="200"></canvas> <script> (function() { var canvas = document.getElementById("drawClearRectDemoCanvas"); var context = canvas.getContext("2d"); context.fillRect(0, 0, 300, 200); context.clearRect(50, 50, 200, 100); })(); </script>
<canvas id="drawSaveRestoreDemoCanvas" width="300" height="200"></canvas> <script> (function() { var canvas = document.getElementById("drawSaveRestoreDemoCanvas"); var context = canvas.getContext("2d"); context.save(); context.fillStyle = "rgb(0, 0, 255)"; context.fillRect(0, 0, 100, 50); context.restore(); context.fillRect(0, 50, 100, 50); })(); </script>
<canvas id="drawClippedRectangleCanvas" width="300" height="300"></canvas> <script> (function() { var canvas = document.getElementById("drawClippedRectangleCanvas"); var context = canvas.getContext("2d"); context.rect(100, 100, 200, 200); context.stroke(); context.clip(); context.fillRect(0, 0, 200, 200); })(); </script>
<canvas id="drawTextCanvas" width="300" height="200"></canvas><br /> <script> (function() { var canvas = document.getElementById("drawTextCanvas"); var context = canvas.getContext("2d"); context.fillText("Hello world!", 20, 30); })(); </script>
<canvas id="drawFontChangedTextCanvas" width="300" height="200"></canvas><br /> <script> (function() { var canvas = document.getElementById("drawFontChangedTextCanvas"); var context = canvas.getContext("2d"); context.font = "30px Arial"; context.fillText("Hello world!", 20, 30); })(); </script>
<canvas id="drawMeasuredTextCanvas" width="300" height="200"></canvas><br /> <script> (function() { var canvas = document.getElementById("drawMeasuredTextCanvas"); var context = canvas.getContext("2d"); context.font = "30px Arial"; var text = "Hello World!"; var size = context.measureText(text); context.fillRect(0, 0, size.width, 30); context.fillStyle = "rgb(0, 255, 255)"; context.fillText(text, 0, 30); })(); </script>