<!DOCTYPE html>
<html lang="en" ng-app="qrCodeApp">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AngularJS QR Code Generator with Logo</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
</head>
<body ng-controller="QRCodeController">
<div class="container">
<div class="header">
<h1>QR Code Generator with Logo</h1>
<p>Create custom QR codes with your logo using AngularJS</p>
</div>
<div class="content-grid">
<!-- Left Panel: Settings -->
<div class="card">
<h2>
<ion-icon name="settings-outline"></ion-icon>
QR Code Settings
</h2>
<div class="form-group">
<label>Content Type</label>
<select ng-model="qrData.type" ng-change="updateContent()">
<option value="url">Website URL</option>
<option value="text">Plain Text</option>
<option value="email">Email</option>
<option value="phone">Phone Number</option>
<option value="sms">SMS</option>
<option value="wifi">WiFi</option>
</select>
</div>
<div class="form-group" ng-show="qrData.type === 'url'">
<label>Website URL</label>
<input type="url" ng-model="qrData.url" placeholder="https://example.com">
</div>
<div class="form-group" ng-show="qrData.type === 'text'">
<label>Text Content</label>
<textarea ng-model="qrData.text" placeholder="Enter your text here..."></textarea>
</div>
<div class="form-group" ng-show="qrData.type === 'email'">
<label>Email Address</label>
<input type="text" ng-model="qrData.email" placeholder="email@example.com">
</div>
<div class="form-group" ng-show="qrData.type === 'phone'">
<label>Phone Number</label>
<input type="text" ng-model="qrData.phone" placeholder="+1234567890">
</div>
<div class="form-group" ng-show="qrData.type === 'sms'">
<label>Phone Number</label>
<input type="text" ng-model="qrData.smsNumber" placeholder="+1234567890">
<label style="margin-top: 10px;">Message</label>
<textarea ng-model="qrData.smsMessage" placeholder="Your message..."></textarea>
</div>
<div class="form-group" ng-show="qrData.type === 'wifi'">
<label>Network Name (SSID)</label>
<input type="text" ng-model="qrData.wifiSSID" placeholder="MyNetwork">
<label style="margin-top: 10px;">Password</label>
<input type="text" ng-model="qrData.wifiPassword" placeholder="password123">
<label style="margin-top: 10px;">Security Type</label>
<select ng-model="qrData.wifiSecurity">
<option value="WPA">WPA/WPA2</option>
<option value="WEP">WEP</option>
<option value="nopass">None</option>
</select>
</div>
<div class="form-group">
<label>QR Code Size</label>
<select ng-model="qrSettings.size" ng-change="generateQRCode()">
<option value="200">Small (200x200)</option>
<option value="256">Medium (256x256)</option>
<option value="300">Large (300x300)</option>
<option value="400">Extra Large (400x400)</option>
</select>
</div>
<div class="form-group">
<label>Error Correction Level</label>
<select ng-model="qrSettings.correctLevel" ng-change="generateQRCode()">
<option value="0">Low (7%)</option>
<option value="1">Medium (15%)</option>
<option value="2">Quartile (25%)</option>
<option value="3">High (30%)</option>
</select>
</div>
<div class="color-grid">
<div class="form-group">
<label>QR Color</label>
<div class="color-input-wrapper">
<input type="color" ng-model="qrSettings.colorDark" ng-change="generateQRCode()">
<input type="text" ng-model="qrSettings.colorDark" ng-change="generateQRCode()">
</div>
</div>
<div class="form-group">
<label>Background</label>
<div class="color-input-wrapper">
<input type="color" ng-model="qrSettings.colorLight" ng-change="generateQRCode()">
<input type="text" ng-model="qrSettings.colorLight" ng-change="generateQRCode()">
</div>
</div>
</div>
<div class="form-group">
<label>Upload Logo (Optional)</label>
<div class="file-upload">
<input type="file" accept="image/*" id="logoUpload" onchange="angular.element(this).scope().uploadLogo(event)">
<label for="logoUpload" class="file-upload-label">
<ion-icon name="cloud-upload-outline"></ion-icon>
Choose Logo Image
</label>
</div>
<div class="logo-preview" ng-show="logoImage">
<img ng-src="{{logoImage}}" alt="Logo">
<div class="logo-preview-name">{{logoFileName}}</div>
</div>
</div>
<button class="btn btn-primary" ng-click="generateQRCode()">
<ion-icon name="qr-code-outline"></ion-icon>
Generate QR Code
</button>
<div class="info-box">
<strong>Tip:</strong> Higher error correction levels allow the QR code to remain scannable even if partially damaged or covered by a logo.
</div>
</div>
<!-- Right Panel: Preview -->
<div class="card">
<h2>
<ion-icon name="eye-outline"></ion-icon>
QR Code Preview
</h2>
<div class="qr-display">
<div ng-show="!qrGenerated" class="empty-state">
<ion-icon name="qr-code-outline"></ion-icon>
<p>Your QR code will appear here</p>
</div>
<div ng-show="qrGenerated" class="qr-canvas">
<div id="qrcode"></div>
<div class="logo-overlay" ng-show="logoImage">
<img ng-src="{{logoImage}}" alt="Logo">
</div>
</div>
</div>
<button class="btn btn-secondary" ng-click="downloadQRCode()" ng-show="qrGenerated">
<ion-icon name="download-outline"></ion-icon>
Download QR Code
</button>
<div class="stats">
<div class="stat-card">
<div class="stat-value">{{qrSettings.size}}px</div>
<div class="stat-label">Size</div>
</div>
<div class="stat-card">
<div class="stat-value">{{getErrorLevel()}}</div>
<div class="stat-label">Error Level</div>
</div>
<div class="stat-card">
<div class="stat-value">{{qrData.type.toUpperCase()}}</div>
<div class="stat-label">Type</div>
</div>
</div>
</div>
</div>
</div>
<script>
angular.module('qrCodeApp', [])
.controller('QRCodeController', function($scope, $timeout) {
$scope.qrData = {
type: 'url',
url: 'https://example.com',
text: '',
email: '',
phone: '',
smsNumber: '',
smsMessage: '',
wifiSSID: '',
wifiPassword: '',
wifiSecurity: 'WPA'
};
$scope.qrSettings = {
size: 256,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: 2
};
$scope.logoImage = null;
$scope.logoFileName = '';
$scope.qrGenerated = false;
$scope.qrInstance = null;
$scope.getContent = function() {
switch($scope.qrData.type) {
case 'url':
return $scope.qrData.url || 'https://example.com';
case 'text':
return $scope.qrData.text || 'Sample text';
case 'email':
return 'mailto:' + ($scope.qrData.email || 'email@example.com');
case 'phone':
return 'tel:' + ($scope.qrData.phone || '+1234567890');
case 'sms':
return 'sms:' + ($scope.qrData.smsNumber || '+1234567890') +
'?body=' + encodeURIComponent($scope.qrData.smsMessage || '');
case 'wifi':
return 'WIFI:T:' + ($scope.qrData.wifiSecurity || 'WPA') +
';S:' + ($scope.qrData.wifiSSID || 'MyNetwork') +
';P:' + ($scope.qrData.wifiPassword || '') + ';;';
default:
return 'https://example.com';
}
};
$scope.updateContent = function() {
if ($scope.qrGenerated) {
$scope.generateQRCode();
}
};
$scope.generateQRCode = function() {
var container = document.getElementById('qrcode');
container.innerHTML = '';
var content = $scope.getContent();
$scope.qrInstance = new QRCode(container, {
text: content,
width: parseInt($scope.qrSettings.size),
height: parseInt($scope.qrSettings.size),
colorDark: $scope.qrSettings.colorDark,
colorLight: $scope.qrSettings.colorLight,
correctLevel: parseInt($scope.qrSettings.correctLevel)
});
$scope.qrGenerated = true;
};
$scope.uploadLogo = function(event) {
var file = event.target.files[0];
if (file) {
var reader = new FileReader();
reader.onload = function(e) {
$scope.$apply(function() {
$scope.logoImage = e.target.result;
$scope.logoFileName = file.name;
});
};
reader.readAsDataURL(file);
}
};
$scope.downloadQRCode = function() {
var canvas = document.querySelector('#qrcode canvas');
var img = document.querySelector('#qrcode img');
var downloadCanvas = canvas || img;
if (canvas) {
var finalCanvas = document.createElement('canvas');
var ctx = finalCanvas.getContext('2d');
finalCanvas.width = canvas.width;
finalCanvas.height = canvas.height;
ctx.drawImage(canvas, 0, 0);
if ($scope.logoImage) {
var logoImg = new Image();
logoImg.onload = function() {
var logoSize = 60;
var x = (finalCanvas.width - logoSize) / 2;
var y = (finalCanvas.height - logoSize) / 2;
ctx.fillStyle = 'white';
ctx.fillRect(x - 5, y - 5, logoSize + 10, logoSize + 10);
ctx.drawImage(logoImg, x, y, logoSize, logoSize);
downloadCanvasAsImage(finalCanvas);
};
logoImg.src = $scope.logoImage;
} else {
downloadCanvasAsImage(finalCanvas);
}
} else if (img) {
var link = document.createElement('a');
link.download = 'qrcode.png';
link.href = img.src;
link.click();
}
};
function downloadCanvasAsImage(canvas) {
var link = document.createElement('a');
link.download = 'qrcode-with-logo.png';
link.href = canvas.toDataURL();
link.click();
}
$scope.getErrorLevel = function() {
var levels = ['Low', 'Medium', 'Quartile', 'High'];
return levels[$scope.qrSettings.correctLevel] || 'Medium';
};
// Generate initial QR code
$timeout(function() {
$scope.generateQRCode();
}, 100);
});
</script>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
.header {
text-align: center;
color: white;
margin-bottom: 40px;
}
.header h1 {
font-size: 36px;
margin-bottom: 10px;
font-weight: 600;
}
.header p {
font-size: 16px;
opacity: 0.9;
}
.content-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
}
.card {
background: white;
border-radius: 16px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 30px;
}
.card h2 {
font-size: 22px;
color: #1e3a8a;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
font-size: 14px;
font-weight: 600;
color: #333;
margin-bottom: 8px;
}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
width: 100%;
padding: 12px 15px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 15px;
font-family: inherit;
transition: border-color 0.3s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
outline: none;
border-color: #3b82f6;
}
.form-group textarea {
resize: vertical;
min-height: 80px;
}
.file-upload {
position: relative;
display: inline-block;
width: 100%;
}
.file-upload input[type="file"] {
position: absolute;
opacity: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
.file-upload-label {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
padding: 12px 20px;
background: #f0f9ff;
border: 2px dashed #3b82f6;
border-radius: 10px;
cursor: pointer;
transition: all 0.3s ease;
color: #1e3a8a;
font-weight: 600;
}
.file-upload-label:hover {
background: #dbeafe;
border-color: #1e3a8a;
}
.logo-preview {
margin-top: 15px;
text-align: center;
}
.logo-preview img {
max-width: 100px;
max-height: 100px;
border-radius: 8px;
border: 2px solid #e0e0e0;
}
.logo-preview-name {
margin-top: 8px;
font-size: 12px;
color: #666;
}
.color-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
}
.color-input-wrapper {
display: flex;
gap: 10px;
align-items: center;
}
input[type="color"] {
width: 50px;
height: 40px;
border: 2px solid #e0e0e0;
border-radius: 8px;
cursor: pointer;
}
.btn {
width: 100%;
padding: 14px 20px;
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.btn-primary {
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(30, 58, 138, 0.4);
}
.btn-secondary {
background: #10b981;
color: white;
margin-top: 15px;
}
.btn-secondary:hover {
background: #059669;
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}
.qr-display {
background: #f8f9fa;
padding: 30px;
border-radius: 12px;
text-align: center;
min-height: 350px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.qr-canvas {
display: inline-block;
position: relative;
background: white;
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
#qrcode {
display: inline-block;
}
#qrcode canvas,
#qrcode img {
display: block !important;
margin: 0 auto;
}
.logo-overlay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 5px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.logo-overlay img {
display: block;
max-width: 60px;
max-height: 60px;
border-radius: 4px;
}
.empty-state {
color: #999;
font-size: 16px;
}
.empty-state ion-icon {
font-size: 80px;
margin-bottom: 15px;
opacity: 0.3;
}
.info-box {
background: #fff9e6;
border-left: 4px solid #fbbf24;
padding: 15px;
border-radius: 8px;
margin-top: 20px;
font-size: 13px;
color: #666;
}
.info-box strong {
color: #92400e;
}
.stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin-top: 20px;
}
.stat-card {
background: #f0f9ff;
padding: 15px;
border-radius: 10px;
text-align: center;
}
.stat-value {
font-size: 24px;
font-weight: 700;
color: #1e3a8a;
}
.stat-label {
font-size: 12px;
color: #666;
margin-top: 5px;
}
@media (max-width: 768px) {
.content-grid {
grid-template-columns: 1fr;
}
.header h1 {
font-size: 28px;
}
.color-grid {
grid-template-columns: 1fr;
}
.stats {
grid-template-columns: 1fr;
}
}
No comments yet. Be the first!