Shim with hole (Canvas)
How do I make an shim with hole (canvas)?
An overlay shim with a hole created with canvas magic.. What is a shim with hole (canvas)? How do you make a shim with hole (canvas)? This script and codes were developed by Karsten Buckstegge on 28 September 2022, Wednesday.
Shim with hole (Canvas) - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Shim with hole (Canvas)</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="content"> <div class="text"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia illum iste, ea quis optio rem vel beatae iure soluta hic eaque, ratione id, quod perspiciatis voluptatem ad fugiat enim! </div> <div class="stuff"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis ullam maiores ipsa repellat sit et enim? Numquam veniam ipsam dolorem soluta molestias at corporis saepe illum, iste velit earum unde perferendis. Perspiciatis dignissimos illum provident nemo natus quos similique qui vitae nulla commodi. Assumenda delectus hic ratione eum incidunt tempora. </div>
</div>
<svg> <defs> <clipPath id="clipping"> <rect id="r1" x="20" y="20" width="240" height="290" /> </clipPath> </defs>
</svg>
<canvas id="shim" class="shim"></canvas> <script src="js/index.js"></script>
</body>
</html>
Shim with hole (Canvas) - Script Codes CSS Codes
body * { box-sizing: border-box;
}
.text { display: inline-block; width: 200px; height: 250px; margin: 40px; padding: 20px; background: #bada55;
}
.stuff { display: inline-block; margin: 40px; width: 400px;
}
.shim { position: fixed; top: 0; left: 0;
}
Shim with hole (Canvas) - Script Codes JS Codes
'use strict';
var canvas = document.getElementById('shim');
var context = canvas.getContext('2d');
var windowWidth = undefined;
var windowHeight = undefined;
var createHole = function createHole(context, x, y, width, height, radius, fill) { context.beginPath(); context.moveTo(x, y + radius); context.lineTo(x, y + height - radius); context.arcTo(x, y + height, x + radius, y + height, radius); context.lineTo(x + width - radius, y + height); context.arcTo(x + width, y + height, x + width, y + height - radius, radius); context.lineTo(x + width, y + radius); context.arcTo(x + width, y, x + width - radius, y, radius); context.lineTo(x + radius, y); context.arcTo(x, y, x, y + radius, radius); context.fillStyle = fill; context.fill(); context.restore();
};
var drawCanvas = function drawCanvas() { context.save(); context.clearRect(0, 0, canvas.width, canvas.height); // draw shim context.beginPath(); context.rect(0, 0, canvas.width, canvas.height); context.fillStyle = 'rgba(0, 0, 0, .4)'; context.fill(); // set global composite context.globalCompositeOperation = 'destination-out'; // draw hole createHole(context, 20, 20, 240, 240, 10, 'black');
};
var resizeCanvas = function resizeCanvas() { windowWidth = window.innerWidth; windowHeight = window.innerHeight; canvas.width = windowWidth; canvas.height = windowHeight; drawCanvas();
};
// resize the canvas to fill browser window dynamically
window.addEventListener('resize', resizeCanvas, false);
resizeCanvas();
Developer | Karsten Buckstegge |
Username | MrBambule |
Uploaded | September 28, 2022 |
Rating | 3 |
Size | 3,487 Kb |
Views | 46,552 |
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 |
The wheel of social fortune | 6,570 Kb |
Freddy the Fly | 4,238 Kb |
Broken TV | 2,456 Kb |
Even More Brokener TV | 2,571 Kb |
The wheel of social | 4,072 Kb |
Base64 SVG Me | 44,786 Kb |
Responsive CSS arrow bar with transparent borders | 2,798 Kb |
Scalable animated css menu button | 2,632 Kb |
CSS3 Hover Button | 3,717 Kb |
Dropdown Menu Animation | 3,411 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 |
A Pen by Manoz | Manoz | 2,424 Kb |
Responsive scrolling text | Ashdurham | 2,259 Kb |
CSS Donut Charts | Seanstopnik | 2,908 Kb |
Navier Stoke Fluid Simulation | Esimov | 8,584 Kb |
Mini Profile | Frytyler | 3,828 Kb |
Twitch API | Coderpilot | 3,412 Kb |
Simple Weather App | Cmwebby | 0 Kb |
Revolving Text Landing Page Trial | TimRuby | 2,976 Kb |
Save for later... | Victorfreire | 1,359 Kb |
Responsive Table-less Shopping Cart | Alex_rodrigues | 6,637 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!