forked from vishanurag/Canvas-Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
507 lines (459 loc) · 20.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Creative Canvas Tool</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/5.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="./src/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="./src/Styles/Style.css">
<link rel="stylesheet" href="./src/Styles/contact_us_style.css">
<link rel="stylesheet" href="./src/Styles/Responsive.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
*{
/* overflow-x: hidden; */
}
body {
overflow-x: hidden;
background-color: #ffffff;
font-family: 'Arial', sans-serif;
}
.container {
max-width: 100vw;
margin: 0 auto;
color: rgb(0, 0, 0);
}
.header {
text-align: center;
margin-bottom: none ;
}
.canvas-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #000000;
color: #ffffff;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
padding: 20px;
}
#mainCanvas {
max-width: 100%;
height: 400px; /* Set a fixed height */
border: 2px solid #000000;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
background-color: #ffffff; /* Default background color */
}
.btn {
margin: 5px;
transition: background-color 0.3s, transform 0.2s;
}
.btn:hover {
background-color: #3abe57;
color: white;
transform: scale(1.05);
}
.btn:active {
transform: scale(0.95);
}
.palette {
margin: 15px 0;
text-align: center;
}
.form-control {
border-radius: 5px;
}
.edit{
display: flex;
}
.toolbar-item{
padding: 10px;
}
</style>
<style>
/* Circle styles */
.circle {
height: 24px;
width: 24px;
border-radius: 24px;
background-color: black;
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 99999999;
/* Stays on top of all elements */
}
</style>
</head>
<body>
<div class="container pt-2">
<div class="header">
<h1 class="display-4"><a href="/" style="color: inherit; text-decoration: none;">Creative Canvas Tool</a></h1>
<p class="lead">Design and create stunning visuals effortlessly!</p>
</div>
<div class="row">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Review</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Blog</a>
</li>
</ul>
</div>
<div class="row text-center p-5" style="background-color: cornflowerblue;">
<h2 style="color: white;">Welcome to the Canvas Editor!</h2>
<p style="color: white;">Unleash your creativity with our powerful and easy-to-use canvas editor. <i class="fa-light fa-face-party"></i></p>
</div>
<div class="canvas-container">
<canvas id="mainCanvas"></canvas>
<div class="p-3 bg-light rounded shadow">
<form id="userForm" class="d-flex flex-column">
<div class="d-flex gap-3 mb-2">
<label for="textSize" class="text-dark">Size:</label>
<select name="tSize" class="form-select" id="textSize">
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
<label for="colorPicker" class="text-dark">Color:</label>
<input type="color" name="colorPicker" class="form-control" id="colorPicker">
</div>
<div class="d-flex row gap-3">
<div class="col-sm-6">
<label for="bgImageUpload" class="text-dark">Background Image:</label>
<input type="file" id="bgImageUpload" accept="image/*">
</div>
<div class="col-sm-6">
<label for="bgColorPicker" class="text-dark">Background Color:</label>
<input type="color" id="bgColorPicker" class="form-control" value="#f0f0f0">
</div>
</div>
<div class="position-relative">
<button type="button" class="btn btn-primary w-25 mt-5 btn-font" id="fontBtn">Fonts</button>
<div class="position-absolute" style="width: 200px; height: 200px; top: -90px; left: -80px; display: none;" id="fontOptions">
<button type="button" class="btn btn-primary position-absolute font-option" style="transform: translate(80px, 0); left: -40px;" id="uppercase">A</button>
<button type="button" class="btn btn-primary position-absolute font-option" style="transform: translate(0, 80px); left:-35px;" id="lowercase">a</button>
<button type="button" class="btn btn-primary position-absolute font-option" style="transform: translate(80px, 160px); left:-15px;" id="bold">B</button>
<button type="button" class="btn btn-primary position-absolute font-option" style="transform: translate(160px, 80px); left: -5px; top:10px" id="italic">I</button>
</div>
</div>
<!-- <p >Shape Pallete</p> -->
<p class="text-center">Shape Palette</p
<div class="palette">
<button id="rectangleBtn" class="btn btn-success">Rectangle</button>
<button id="circleBtn" class="btn btn-success">Circle</button>
<button id="lineBtn" class="btn btn-success">Line</button>
<!-- Circles -->
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<header class="header">
<nav class="navbar">
<div class="title">
<h1 class="site-name">Canvas Editor</h1>
<i class="fa-solid fa-paintbrush"></i>
</div>
<div class="nav-links">
<a href="#home">Home</a>
<a href="#about">About</a>
<a href="#blogs">Blogs</a>
<a href="./edition.html">Draw</a>
</div>
</nav>
</header>
<div class="row text-center p-5" style="background-color: rgb(0, 0, 0);">
<h2 style="color: white;">Welcome to the Canvas Editor!</h2>
<p style="color: white;">Unleash your creativity with our powerful and easy-to-use canvas editor. <i class="fa-light fa-face-party"></i></p>
</div>
<div class="canvas-container">
<canvas id="mainCanvas"></canvas>
<div class="canvas-palette">
<form id="userForm" class="d-flex flex-column">
<div class="d-flex gap-3 mb-2">
<label for="brushSize" class="text-dark">Brush Size:</label>
<select name="brushSize" class="form-select" id="brushSize">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
</select>
<label for="colorPicker" class="text-dark">Color:</label>
<input type="color" name="colorPicker" class="form-control" id="colorPicker">
</div>
<div class="d-flex row gap-3 mb-2">
<div class="col-sm-6">
<label for="bgImageUpload" class="text-dark">Background Image:</label>
<input type="file" id="bgImageUpload" accept="image/*">
</div>
<div class="col-sm-6">
<label for="bgColorPicker" class="text-dark">Background Color:</label>
<input type="color" name="bgColorPicker" class="form-control" id="bgColorPicker">
</div>
</div>
<div class="edit">
<button type="button" class="btn btn-primary" id="drawTextBtn">Brush</button>
<button type="button" class="btn btn-secondary" id="clearCanvasBtn">Clear Canvas</button>
<button type="button" class="btn btn-danger" id="eraserBtn">Eraser</button>
</div>
</form>
<div class="d-md-flex justify-content-evenly gap-1">
<button class="btn btn-primary" id="capital">A</button>
<button class="btn btn-primary" id="small">a</button>
<button class="btn btn-primary" id="bold">B</button>
<button class="btn btn-primary" id="italic">I</button>
</div>
<div class="palette">
<button id="rectangleBtn" class="btn btn-success">Rectangle</button>
<button id="circleBtn" class="btn btn-success">Circle</button>
<button id="lineBtn" class="btn btn-success">Line</button>
</div>
<div class="d-md-flex justify-content-center gap-2 mb-3">
<input type="text" placeholder="Enter Text" name="textData" id="textData" class="form-control mw-100 w-75 mb-3">
<button type="button" class="btn btn-primary" id="save">Save</button>
<button type="button" class="btn btn-danger" id="clear">Clear</button>
<button type="button" class="btn btn-success" id="download" title="Download">Download</button>
</div>
</form>
</div>
</div>
<div class="container mt-5">
<!-- Contact Us Section -->
<section id="contact" class="contact-section text-center py-5">
<h2 class="mb-4">Contact Us</h2>
<form id="contactForm" class="row g-3 justify-content-center">
<!-- Name Field -->
<div class="col-md-4">
<div class="form-floating">
<input type="text" class="form-control" id="name" name="name" placeholder="Your Name" required>
<label for="name">Your Name</label>
</div>
</div>
<!-- Email Field -->
<div class="col-md-4">
<div class="form-floating">
<input type="email" class="form-control" id="email" name="email" placeholder="Your Email" required>
<label for="email">Your Email</label>
</div>
</div>
<!-- Subject Field -->
<div class="col-md-8">
<div class="form-floating">
<input type="text" class="form-control" id="subject" name="subject" placeholder="Subject" required>
<label for="subject">Subject</label>
</div>
</div>
<!-- Message Field -->
<div class="col-md-8">
<div class="form-floating">
<textarea class="form-control" id="message" name="message" placeholder="Your Message" style="height: 150px" required></textarea>
<label for="message">Your Message</label>
</div>
</div>
<!-- Submit Button -->
<div class="col-md-8">
<button type="submit" class="btn btn-primary w-100 py-2">Submit</button>
</div>
</form>
</section>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js" integrity="sha512-7eHRwcbYkK4d9g/6tD/mhkf++eoTHwpNM9woBxtPUBWm67zeAfFC+HrdoE2GanKeocly/VxeLvIqwvCdk7qScg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="./src/Scripts/edit.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const fontBtn = document.getElementById('fontBtn');
const fontOptions = document.getElementById('fontOptions');
const options = document.querySelectorAll('.font-option');
const radius = 100; // Increase this value to create more spacing between buttons
const startAngle = -30; // Adjust this for positioning of the arc
const offsetX = 300; // Move the arc further to the right
const offsetY = 70; // Adjust vertical position of the arc
fontBtn.addEventListener('click', function(e) {
e.preventDefault();
fontOptions.style.display = fontOptions.style.display === 'none' ? 'block' : 'none';
if (fontOptions.style.display === 'block') {
const totalOptions = options.length;
options.forEach((option, index) => {
const angle = (startAngle + index * (90 / (totalOptions - 1))) * (Math.PI / 180);
const x = Math.cos(angle) * radius + offsetX + 20;
const y = Math.sin(angle) * radius + offsetY + 50;
option.style.transform = `translate(${x}px, ${y}px)`;
});
} else {
options.forEach(option => {
option.style.transform = 'translate(0, 0)';
});
}
});
options.forEach(option => {
option.addEventListener('click', function(e) {
e.preventDefault(); // Prevent default button action
console.log(`${this.id} selected`);
});
});
});
</script>
<script>
const canvas = document.getElementById('mainCanvas');
const ctx = canvas.getContext('2d');
let drawing = false;
let brushColor = '#000000';
let brushSize = 5;
// Set initial canvas dimensions
function setCanvasDimensions() {
canvas.width = window.innerWidth - 40; // Adjust width
canvas.height = 400; // Keep height fixed
}
setCanvasDimensions();
// Brush size change
document.getElementById('brushSize').addEventListener('change', function() {
brushSize = this.value;
});
// Color picker change
document.getElementById('colorPicker').addEventListener('change', function() {
brushColor = this.value;
});
// Background color change
document.getElementById('bgColorPicker').addEventListener('change', function() {
canvas.style.backgroundColor = this.value;
});
// Background image upload
document.getElementById('bgImageUpload').addEventListener('change', function(event) {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = function(e) {
const img = new Image();
img.onload = function() {
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
};
img.src = e.target.result;
};
reader.readAsDataURL(file);
});
// Drawing on canvas
canvas.addEventListener('mousedown', (e) => {
drawing = true;
ctx.beginPath();
ctx.moveTo(e.offsetX, e.offsetY);
});
canvas.addEventListener('mousemove', (e) => {
if (drawing) {
ctx.lineWidth = brushSize;
ctx.lineCap = 'round';
ctx.strokeStyle = brushColor;
ctx.lineTo(e.offsetX, e.offsetY);
ctx.stroke();
}
});
canvas.addEventListener('mouseup', () => {
drawing = false;
ctx.closePath();
});
canvas.addEventListener('mouseout', () => {
drawing = false;
});
// Clear canvas button
document.getElementById('clearCanvasBtn').addEventListener('click', () => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
canvas.style.backgroundColor = '#f0f0f0'; // Reset background color
});
// Eraser button
document.getElementById('eraserBtn').addEventListener('click', () => {
brushColor = '#ffffff'; // Set brush color to white
});
// Resize canvas on window resize
window.addEventListener('resize', setCanvasDimensions);
</script>
</script>
<script>
// Coordinates for the cursor
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
// Colors for the circles
const colors = [
"#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d",
"#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d",
"#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060",
"#680060", "#60005f", "#48005f", "#3d005e"
];
// Assign colors and initial position to each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});
// Update the coordinates when the mouse moves
window.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;
});
// Animation function to move the circles
function animateCircles() {
let x = coords.x;
let y = coords.y;
circles.forEach(function (circle, index) {
// Update the position and scale of each circle
circle.style.left = x - 12 + "px";
circle.style.top = y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
circle.x = x;
circle.y = y;
// Get the next circle in the sequence
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
// Repeat the animation
requestAnimationFrame(animateCircles);
}
// Start the animation
animateCircles();
</script>
<section class="footer" id="footer">
<div class="share">
<a href="#" class="fab fa-facebook-f"></a>
<a href="#" class="fa-brands fa-x-twitter"></a> <!-- Updated X icon-->
<a href="#" class="fab fa-instagram"></a>
<a href="#" class="fa-brands fa-linkedin-in"></a>
<a href="#" class="fa-brands fa-pinterest"></a>
</div>
<div class="credit" style="font-size: 0.6rem;">
<p>
Created by <span>ANURAG VISHWAKARMA</span> | All rights reserved © 2024
</p>
<br>
</div>
</section>
</body>
</html>