Tinted image renderer
How do I make an tinted image renderer?
What is a tinted image renderer? How do you make a tinted image renderer? This script and codes were developed by Sarah Cartwright on 05 December 2022, Monday.
Tinted image renderer - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Tinted image renderer</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> This Pen does nothing on its own - it is used in other pens. <script src="js/index.js"></script>
</body>
</html>
Tinted image renderer - Script Codes CSS Codes
body { padding: 10px; margin: 0px; background: #2e2e2e; color: #909090; font: 12px arial, sans-serif;
}
Tinted image renderer - Script Codes JS Codes
//Width and height are the back buffers dimensions, which dictate the maximum image size that can be drawn
function tintedImageRenderer(width, height){ this.backCanvas = document.createElement('canvas'); this.backCanvasWidth = width; this.backCanvasHeight = height; this.backCtx = this.backCanvas.getContext("2d"); this.backCanvas.width = this.backCanvasWidth; this.backCanvas.height = this.backCanvasHeight;
}
tintedImageRenderer.prototype.drawRotatedTintedImage = function (imageInfo){ var imageWidth = imageInfo.image.width * imageInfo.scale, imageHeight = imageInfo.image.height * imageInfo.scale; var imageCenterWidth = imageWidth/2, imageCenterHeight = imageHeight/2, angle = imageInfo.angle / 180 * Math.PI; this.backCtx.clearRect(0, 0, this.backCanvasWidth, this.backCanvasHeight); this.backCtx.save(); this.backCtx.translate(imageCenterWidth,imageCenterHeight); this.backCtx.rotate(angle); this.backCtx.translate(-imageCenterWidth, -imageCenterHeight); this.backCtx.globalAlpha = imageInfo.alpha; this.backCtx.drawImage(imageInfo.image, 0, 0, imageWidth, imageHeight); this.backCtx.globalAlpha = 1; this.backCtx.globalCompositeOperation = 'source-atop'; this.backCtx.fillStyle = 'rgba(' + imageInfo.red + ', ' + imageInfo.green + ', ' + imageInfo.blue + ', 1)'; this.backCtx.fillRect(0, 0, canvasWidth, canvasHeight); this.backCtx.restore(); //Draw all the canvas imageInfo.destinationContext.globalCompositeOperation = 'screen'; imageInfo.destinationContext.drawImage(this.backCanvas, imageInfo.imageX - imageCenterWidth, imageInfo.imageY - imageCenterHeight); imageInfo.destinationContext.globalCompositeOperation = 'source-over'; //Draw part of a canvas //var image = this.backCtx.getImageData(0, 0, imageWidth, imageHeight); //imageInfo.destinationContext.putImageData(image, imageInfo.imageX, imageInfo.imageY);
}
Developer | Sarah Cartwright |
Username | SarahC |
Uploaded | December 05, 2022 |
Rating | 3 |
Size | 2,176 Kb |
Views | 8,096 |
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!
Name | Size |
A Pen by Sarah Cartwright | 1,738 Kb |
Three.js particles | 7,333 Kb |
Iocaine Powder - by Dan Egnor | 5,731 Kb |
Circuit Snakes | 5,087 Kb |
3D Fireworks | 5,096 Kb |
3D Spatial hash | 2,084 Kb |
Canvas view-type arrays | 3,013 Kb |
Linear Feedback Shift Register | 2,197 Kb |
Firework - Smoke types | 7,632 Kb |
OLED Emulator - Horizontal bytes | 5,745 Kb |
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!
Name | Username | Size |
FCC Portfolio | Cmwebby | 4,304 Kb |
CSS Variables | Jdsteinbach | 4,759 Kb |
Scroll to top button | DominicFrancois | 3,743 Kb |
Base64 SVG Me | MrBambule | 44,786 Kb |
A bit of elegance | Hackthevoid | 9,095 Kb |
A Pen by Stan Williams | Stanssongs | 6,706 Kb |
Commuter Line Tokyu 8500 | Pedox | 7,031 Kb |
Realistic Buttons | Stoypenny | 2,248 Kb |
Slick Slider | Wearebold | 5,913 Kb |
Opening Reveal Modal On Document Ready | Winghouchan | 1,787 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!