Canvas experiment 2

Size
2,903 Kb
Views
26,312

How do I make an canvas experiment 2?

Clipping an image using canvas.i.e. imageObjectOnCanvas.drawImage(source, startOriginX, startOriginY, widthFromOriginX, heightFromOriginY, starOnDestinationCanvasX, startOnDestinationCanvasY, widthOnDestinationCanvasX, heightOnDestinationCanvasY);. What is a canvas experiment 2? How do you make a canvas experiment 2? This script and codes were developed by Justin Richardsson on 31 August 2022, Wednesday.

Canvas experiment 2 Previews

Canvas experiment 2 - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Canvas experiment 2</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas width="600" height="400" id="imageCanvas"> No canvas for you!
</canvas> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Canvas experiment 2 - Script Codes CSS Codes

body { background: #000; display:-webkit-box; display:-ms-flexbox; display:flex; height: 95vh; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
}
canvas { background: #666;
}

Canvas experiment 2 - Script Codes JS Codes

"use strict";
$(function () { var canvasE = document.getElementById('imageCanvas'), canvasC = canvasE.getContext('2d'), imageObj = new Image(); imageObj.src = 'https://hd.unsplash.com/photo-1449023859676-22e61b0c0695'; canvasC.fillStyle = "blue"; canvasC.fillRect(0, 0, 100, 50); imageObj.onload = function () { var destWidth = 600, destHeight = 400, sourceX = 350, sourceY = 400, sourceWidth = destWidth * 4, sourceHeight = destHeight * 4, destX = canvasE.width / 2 - destWidth / 2, destY = canvasE.height / 2 - destHeight / 2; canvasC.drawImage(imageObj, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight); }; canvasC.translate(50, 50); canvasC.fillStyle = "red"; canvasC.fillRect(-10, -10, 100, 50);
});
Canvas experiment 2 - Script Codes
Canvas experiment 2 - Script Codes
Home Page Home
Developer Justin Richardsson
Username hallaathrad
Uploaded August 31, 2022
Rating 3
Size 2,903 Kb
Views 26,312
Do you need developer help for Canvas experiment 2?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Justin Richardsson (hallaathrad) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!