<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="700" height="700"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.rect(0, 0, canvas.width, canvas.height);
// add linear gradient
var grd = context.createLinearGradient(0, 0, canvas.width, canvas.height);
// light blue
grd.addColorStop(0, '#9ED6BF');
// dark blue
grd.addColorStop(1, '#008CB3');
context.fillStyle = grd;
context.fill();
</script>
</body>
</html>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="578" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var centerX = canvas.width / 2.2;
var centerY = canvas.height / 3.5;
var radius = 70;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 3 * Math.PI, false);
context.fillStyle = 'blue';
context.fill();
context.lineWidth = 4;
context.strokeStyle = '#003300';
context.stroke();
</script>
</body>
</html>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="800" height="900"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(500, 600);
context.lineTo(500, 100);
context.stroke();
</script>
</body>
</html>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="578" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var rectWidth = 150;
var rectHeight = 75;
// shear matrix:
// 1 sx 0
// sy 1 0
// 0 0 1
var sx = 0.75;
// .75 horizontal shear
var sy = 0;
// no vertical shear
// translate context to center of canvas
context.translate(canvas.width / 5, canvas.height / 14);
// apply custom transform
context.transform(3, sy, sx, 1, 0, 0);
context.fillStyle = 'lightblue';
context.fillRect(-rectWidth / 2, rectHeight / -3, rectWidth, rectHeight);
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="578" height="200"></canvas>
<script>
function loadImages(sources, callback) {
var images = {};
var loadedImages = 0;
var numImages = 0;
// get num of sources
for(var src in sources) {
numImages++;
}
for(var src in sources) {
images[src] = new Image();
images[src].onload = function() {
if(++loadedImages >= numImages) {
callback(images);
}
};
images[src].src = sources[src];
}
}
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var sources = {
darthVader: 'http://a57.foxnews.com/global.fncstatic.com/static/managed/img/Entertainment/2010/876/493/PaulaDeen640.jpg?ve=1&tl=1',
yoda: 'http://www.html5canvastutorials.com/demos/assets/yoda.jpg'
};
loadImages(sources, function(images) {
context.drawImage(images.darthVader, 75, 20, 200, 100);
context.drawImage(images.yoda, 350, 55, 93, 104);
});
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="400" height="700"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.font = 'italic 50pt Calibri';
context.fillText('Sarah', -120, 400);
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="700" height="700"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
context.arc(50, 550, 100, 0, Math.PI, true);
context.closePath();
context.lineWidth = 5;
context.fillStyle = 'red';
context.fill();
context.strokeStyle = '#550000';
context.stroke();
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
Description: HTML artwork to get to know the program. We were to experiment with shapes, text, photos, and color.
Thoughts: This project was difficult because it was hard to know what element of code corresponded to what element and to what degree. I chose to be abstract and utilize a picture of Paula Deen.
No comments:
Post a Comment