openfree commited on
Commit
63ddb5f
·
verified ·
1 Parent(s): 0a95851

Upload index.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +172 -19
index.html CHANGED
@@ -1,19 +1,172 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Draw</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ body {
15
+ min-height: 100vh;
16
+ display: flex;
17
+ flex-direction: column;
18
+ align-items: center;
19
+ background: #f0f0f0;
20
+ padding: 20px;
21
+ font-family: Arial, sans-serif;
22
+ }
23
+
24
+ .toolbar {
25
+ background: white;
26
+ padding: 15px;
27
+ border-radius: 10px;
28
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
29
+ margin-bottom: 20px;
30
+ display: flex;
31
+ gap: 15px;
32
+ align-items: center;
33
+ }
34
+
35
+ #canvas {
36
+ background: white;
37
+ border-radius: 10px;
38
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
39
+ cursor: crosshair;
40
+ }
41
+
42
+ input[type="color"] {
43
+ -webkit-appearance: none;
44
+ width: 40px;
45
+ height: 40px;
46
+ border: none;
47
+ border-radius: 5px;
48
+ padding: 0;
49
+ cursor: pointer;
50
+ }
51
+
52
+ input[type="range"] {
53
+ width: 100px;
54
+ }
55
+
56
+ button {
57
+ padding: 8px 15px;
58
+ border: none;
59
+ border-radius: 5px;
60
+ background: #4CAF50;
61
+ color: white;
62
+ cursor: pointer;
63
+ transition: background 0.3s;
64
+ }
65
+
66
+ button:hover {
67
+ background: #45a049;
68
+ }
69
+
70
+ button.active {
71
+ background: #2196F3;
72
+ }
73
+
74
+ .size-display {
75
+ width: 40px;
76
+ height: 40px;
77
+ border-radius: 50%;
78
+ border: 2px solid #ccc;
79
+ display: flex;
80
+ align-items: center;
81
+ justify-content: center;
82
+ }
83
+ </style>
84
+ </head>
85
+ <body>
86
+ <div class="toolbar">
87
+ <input type="color" id="colorPicker" value="#000000">
88
+ <input type="range" id="brushSize" min="1" max="50" value="5">
89
+ <div class="size-display" id="sizeDisplay"></div>
90
+ <button id="eraser">지우개</button>
91
+ <button id="clear">전체 지우기</button>
92
+ <button id="save">저장</button>
93
+ </div>
94
+ <canvas id="canvas" width="800" height="600"></canvas>
95
+
96
+ <script>
97
+ const canvas = document.getElementById('canvas');
98
+ const ctx = canvas.getContext('2d');
99
+ const colorPicker = document.getElementById('colorPicker');
100
+ const brushSize = document.getElementById('brushSize');
101
+ const sizeDisplay = document.getElementById('sizeDisplay');
102
+ const eraserBtn = document.getElementById('eraser');
103
+ const clearBtn = document.getElementById('clear');
104
+ const saveBtn = document.getElementById('save');
105
+
106
+ let isDrawing = false;
107
+ let isEraser = false;
108
+ let lastX = 0;
109
+ let lastY = 0;
110
+
111
+ // Initialize
112
+ ctx.fillStyle = 'white';
113
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
114
+ updateSizeDisplay();
115
+
116
+ function updateSizeDisplay() {
117
+ const size = brushSize.value;
118
+ sizeDisplay.style.width = `${size}px`;
119
+ sizeDisplay.style.height = `${size}px`;
120
+ sizeDisplay.textContent = size;
121
+ }
122
+
123
+ function draw(e) {
124
+ if (!isDrawing) return;
125
+
126
+ const rect = canvas.getBoundingClientRect();
127
+ const x = e.clientX - rect.left;
128
+ const y = e.clientY - rect.top;
129
+
130
+ ctx.beginPath();
131
+ ctx.moveTo(lastX, lastY);
132
+ ctx.lineTo(x, y);
133
+ ctx.strokeStyle = isEraser ? 'white' : colorPicker.value;
134
+ ctx.lineWidth = brushSize.value;
135
+ ctx.lineCap = 'round';
136
+ ctx.lineJoin = 'round';
137
+ ctx.stroke();
138
+
139
+ [lastX, lastY] = [x, y];
140
+ }
141
+
142
+ canvas.addEventListener('mousedown', (e) => {
143
+ isDrawing = true;
144
+ const rect = canvas.getBoundingClientRect();
145
+ [lastX, lastY] = [e.clientX - rect.left, e.clientY - rect.top];
146
+ });
147
+
148
+ canvas.addEventListener('mousemove', draw);
149
+ canvas.addEventListener('mouseup', () => isDrawing = false);
150
+ canvas.addEventListener('mouseout', () => isDrawing = false);
151
+
152
+ brushSize.addEventListener('input', updateSizeDisplay);
153
+
154
+ eraserBtn.addEventListener('click', () => {
155
+ isEraser = !isEraser;
156
+ eraserBtn.classList.toggle('active');
157
+ });
158
+
159
+ clearBtn.addEventListener('click', () => {
160
+ ctx.fillStyle = 'white';
161
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
162
+ });
163
+
164
+ saveBtn.addEventListener('click', () => {
165
+ const link = document.createElement('a');
166
+ link.download = 'drawing.png';
167
+ link.href = canvas.toDataURL();
168
+ link.click();
169
+ });
170
+ </script>
171
+ </body>
172
+ </html>