Tinted image renderer

Size
2,176 Kb
Views
8,096

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 Previews

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);
}
Tinted image renderer - Script Codes
Tinted image renderer - Script Codes
Home Page Home
Developer Sarah Cartwright
Username SarahC
Uploaded December 05, 2022
Rating 3
Size 2,176 Kb
Views 8,096
Do you need developer help for Tinted image renderer?

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!

Sarah Cartwright (SarahC) Script Codes
Create amazing Facebook ads 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!