Punch Button
How do I make an punch button?
A button that has text punched out of it.. What is a punch button? How do you make a punch button? This script and codes were developed by Josh Beckwith on 29 August 2022, Monday.
Punch Button - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Punch Button</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src="https://rawgit.com/x-tag/core/master/dist/x-tag-core.js"></script>
<iframe class="video" src="https://player.vimeo.com/video/104094320?autoplay=1&loop=1&color=ff9933&title=0&byline=0&portrait=0" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<punch-button label="PUNCH BUTTON"></punch-button> <script src="js/index.js"></script>
</body>
</html>
Punch Button - Script Codes CSS Codes
punch-button { position: relative; font-weight: bold; text-align: center; letter-spacing: .2em; font-size: 1.5em; border-radius: 3px; overflow: hidden; white-space: nowrap;
}
punch-button div { border: 1px solid red; padding: 20px 35px;
}
punch-button canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%;
}
punch-button { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
body { background: black; color: white; font-family: Helvetica, Arial, sans-serif; margin: 0; padding: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.video { position: absolute; width: 100%; height: 100%;
}
Punch Button - Script Codes JS Codes
'use strict';
/* credits: grabbed some code from this gist https://gist.github.com/psobot/4311375 video by beeple: http://beeple-crap.com/
*/
xtag.register('punch-button', { content: '\n <div></div>\n <canvas>\n ', lifecycle: { created: function created() { this._canvas = this.querySelector('canvas'); this._ctx = this._canvas.getContext('2d'); this._div = this.querySelector('div'); this._div.style.opacity = 0; // this._canvas.style.opacity = 0 } }, accessors: { label: { attribute: {}, get: function get() { return this._label; }, set: function set(label) { this._label = label; this._div.innerHTML = label; this.draw(); } } }, methods: { draw: function draw() { var style = document.defaultView.getComputedStyle(this, ""); var dpr = window.devicePixelRatio || 1; this._canvas.width = this.offsetWidth * dpr; this._canvas.height = this.offsetHeight * dpr; this._ctx.fillStyle = '#ffffff'; this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height); this._ctx.fillStyle = '#000000'; var fontSplit = style.font.split(' '); fontSplit[4] = parseInt(fontSplit[4]) * dpr + 'px'; // dpr font size this._ctx.font = fontSplit.join(' '); this._ctx.textBaseline = 'top'; this._ctx.globalCompositeOperation = 'destination-out'; var textWidth = this._ctx.measureText(this._label, 0, 0).width; var left = (this._canvas.width - textWidth) * .5; var textHeight = this._ctx.measureText('M').width; var top = (this._canvas.height - textHeight) * .5; this._ctx.fillText(this._label, left, top); } }
});
Developer | Josh Beckwith |
Username | positlabs |
Uploaded | August 29, 2022 |
Rating | 3 |
Size | 3,958 Kb |
Views | 24,288 |
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 |
Cryptaris Glitch Button | 4,648 Kb |
Hootsuite Button Demo | 1,457 Kb |
Fly Eye CSS | 8,718 Kb |
Spherical orbiter | 3,870 Kb |
Youtube 360 player sandbox | 2,195 Kb |
Blurry text | 1,754 Kb |
Xtag render | 2,320 Kb |
Three orbiter | 3,490 Kb |
Refraction image reveal | 3,014 Kb |
Emoji Split | 3,063 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 |
Table Exercise | Fresco | 9,585 Kb |
Add This API | ThatGuySam | 2,848 Kb |
Twitch JSON API | Jvhti | 2,808 Kb |
Scrolling Horizontal Isotope | Bramus | 2,017 Kb |
Replace url via jquery | Serluk | 1,429 Kb |
A Pen by Alex Bergin | Abergin | 3,347 Kb |
Animated Vertical CSS3 Menu Black | MaCeLMp4 | 2,750 Kb |
Adding and Removing Element | Accimeesterlin | 2,119 Kb |
Vertically rotating text with CSS | Nopr | 2,141 Kb |
A Pen by Jason Kinney | Jason-kinney | 1,980 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!