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+
<script src="https://cdn.tailwindcss.com"></script>
|
| 6 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 7 |
+
<script src="https://cdn.jsdelivr.net/npm/roughjs@4.5.2/bundled/rough.cjs.js"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/perfect-freehand@1.0.0/dist/perfect-freehand.esm.js"></script>
|
| 9 |
+
</head>
|
| 10 |
+
<body class="bg-gray-100">
|
| 11 |
+
<div class="flex h-screen">
|
| 12 |
+
<!-- Tools Panel -->
|
| 13 |
+
<div class="w-48 bg-white p-4 border-r">
|
| 14 |
+
<div class="space-y-4">
|
| 15 |
+
<button id="pencil" class="tool-btn bg-blue-100">
|
| 16 |
+
<i class="fas fa-pencil-alt"></i>
|
| 17 |
+
</button>
|
| 18 |
+
<button id="chalk" class="tool-btn">
|
| 19 |
+
<i class="fas fa-chalkboard"></i>
|
| 20 |
+
</button>
|
| 21 |
+
<button id="paint" class="tool-btn">
|
| 22 |
+
<i class="fas fa-paint-brush"></i>
|
| 23 |
+
</button>
|
| 24 |
+
<button id="splatter" class="tool-btn">
|
| 25 |
+
<i class="fas fa-tint"></i>
|
| 26 |
+
</button>
|
| 27 |
+
<input type="color" id="color" class="w-full">
|
| 28 |
+
<input type="range" id="size" min="1" max="50" class="w-full">
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<!-- Canvas Container -->
|
| 33 |
+
<div class="flex-1 relative bg-white" id="canvasContainer">
|
| 34 |
+
<canvas id="mainCanvas" class="absolute top-0 left-0"></canvas>
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
<!-- Layers Panel -->
|
| 38 |
+
<div class="w-64 bg-white p-4 border-l">
|
| 39 |
+
<div class="flex justify-between mb-4">
|
| 40 |
+
<button onclick="addLayer()" class="bg-blue-500 text-white px-3 py-1 rounded">
|
| 41 |
+
<i class="fas fa-plus"></i> Add Layer
|
| 42 |
+
</button>
|
| 43 |
+
<div class="space-x-2">
|
| 44 |
+
<button onclick="undo()"><i class="fas fa-undo"></i></button>
|
| 45 |
+
<button onclick="redo()"><i class="fas fa-redo"></i></button>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
<div id="layersList" class="space-y-2"></div>
|
| 49 |
+
</div>
|
| 50 |
+
</div>
|
| 51 |
+
|
| 52 |
+
<script>
|
| 53 |
+
let currentTool = 'pencil';
|
| 54 |
+
let layers = [];
|
| 55 |
+
let history = [];
|
| 56 |
+
let historyIndex = -1;
|
| 57 |
+
|
| 58 |
+
class DrawingLayer {
|
| 59 |
+
constructor() {
|
| 60 |
+
this.canvas = document.createElement('canvas');
|
| 61 |
+
this.ctx = this.canvas.getContext('2d');
|
| 62 |
+
this.visible = true;
|
| 63 |
+
this.rough = Rough.canvas(this.canvas);
|
| 64 |
+
|
| 65 |
+
this.canvas.width = window.innerWidth - 312;
|
| 66 |
+
this.canvas.height = window.innerHeight;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
function setCurrentTool(tool) {
|
| 71 |
+
currentTool = tool;
|
| 72 |
+
document.querySelectorAll('.tool-btn').forEach(b => b.classList.remove('bg-blue-100'));
|
| 73 |
+
document.getElementById(tool).classList.add('bg-blue-100');
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
function drawChalkStroke(x, y) {
|
| 77 |
+
const ctx = getCurrentLayer().ctx;
|
| 78 |
+
ctx.strokeStyle = document.getElementById('color').value;
|
| 79 |
+
ctx.lineWidth = document.getElementById('size').value;
|
| 80 |
+
|
| 81 |
+
// Create chalk-like texture
|
| 82 |
+
ctx.shadowColor = ctx.strokeStyle;
|
| 83 |
+
ctx.shadowBlur = 5;
|
| 84 |
+
ctx.globalAlpha = 0.7;
|
| 85 |
+
|
| 86 |
+
ctx.beginPath();
|
| 87 |
+
ctx.lineTo(x, y);
|
| 88 |
+
ctx.stroke();
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
function addLayer() {
|
| 92 |
+
const layer = new DrawingLayer();
|
| 93 |
+
layers.push(layer);
|
| 94 |
+
updateLayersList();
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
function updateLayersList() {
|
| 98 |
+
const container = document.getElementById('layersList');
|
| 99 |
+
container.innerHTML = layers.map((layer, index) => `
|
| 100 |
+
<div class="flex items-center p-2 bg-gray-50 rounded">
|
| 101 |
+
<input type="checkbox" checked onchange="toggleLayer(${index})">
|
| 102 |
+
<span class="ml-2">Layer ${index + 1}</span>
|
| 103 |
+
<button onclick="deleteLayer(${index})" class="ml-auto">
|
| 104 |
+
<i class="fas fa-times text-red-500"></i>
|
| 105 |
+
</button>
|
| 106 |
+
</div>
|
| 107 |
+
`).join('');
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
// Additional functions for drawing tools, layer management,
|
| 111 |
+
// undo/redo, and texture generation would follow here...
|
| 112 |
+
|
| 113 |
+
// Initialize first layer
|
| 114 |
+
addLayer();
|
| 115 |
+
|
| 116 |
+
// Event listeners for canvas interaction
|
| 117 |
+
document.getElementById('mainCanvas').addEventListener('mousedown', startDrawing);
|
| 118 |
+
document.getElementById('mainCanvas').addEventListener('mousemove', draw);
|
| 119 |
+
document.getElementById('mainCanvas').addEventListener('mouseup', endDrawing);
|
| 120 |
+
</script>
|
| 121 |
+
|
| 122 |
+
<style>
|
| 123 |
+
.tool-btn {
|
| 124 |
+
@apply w-full p-2 rounded hover:bg-gray-100 transition-colors;
|
| 125 |
+
}
|
| 126 |
+
canvas {
|
| 127 |
+
touch-action: none;
|
| 128 |
+
}
|
| 129 |
+
</style>
|
| 130 |
+
</body>
|
| 131 |
</html>
|