imseldrith commited on
Commit
07c2a8b
·
verified ·
1 Parent(s): c6cf436

https://github.com/saurabhdaware/text-to-handwriting.git

Browse files
Files changed (6) hide show
  1. README.md +8 -5
  2. components/footer.js +114 -0
  3. components/navbar.js +83 -0
  4. index.html +72 -19
  5. script.js +64 -0
  6. style.css +18 -19
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Scribbletoscript Magic Wand
3
- emoji: 🏢
4
- colorFrom: blue
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: ScribbleToScript Magic Wand
3
+ colorFrom: red
4
+ colorTo: yellow
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
components/footer.js ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomFooter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ footer {
7
+ background: #1E1B4B;
8
+ color: white;
9
+ padding: 3rem 2rem;
10
+ text-align: center;
11
+ }
12
+ .footer-content {
13
+ max-width: 1200px;
14
+ margin: 0 auto;
15
+ display: grid;
16
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
17
+ gap: 2rem;
18
+ text-align: left;
19
+ }
20
+ .footer-section h3 {
21
+ font-size: 1.25rem;
22
+ margin-bottom: 1rem;
23
+ position: relative;
24
+ display: inline-block;
25
+ }
26
+ .footer-section h3::after {
27
+ content: '';
28
+ position: absolute;
29
+ bottom: -4px;
30
+ left: 0;
31
+ width: 40px;
32
+ height: 2px;
33
+ background: #8B5CF6;
34
+ }
35
+ .footer-section ul {
36
+ list-style: none;
37
+ padding: 0;
38
+ margin: 0;
39
+ }
40
+ .footer-section li {
41
+ margin-bottom: 0.5rem;
42
+ }
43
+ .footer-section a {
44
+ color: #E0E7FF;
45
+ text-decoration: none;
46
+ transition: color 0.2s;
47
+ }
48
+ .footer-section a:hover {
49
+ color: #A5B4FC;
50
+ }
51
+ .social-links {
52
+ display: flex;
53
+ gap: 1rem;
54
+ margin-top: 1rem;
55
+ }
56
+ .social-links a {
57
+ display: flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ width: 36px;
61
+ height: 36px;
62
+ border-radius: 50%;
63
+ background: rgba(255, 255, 255, 0.1);
64
+ transition: background 0.2s;
65
+ }
66
+ .social-links a:hover {
67
+ background: rgba(255, 255, 255, 0.2);
68
+ }
69
+ .copyright {
70
+ margin-top: 2rem;
71
+ padding-top: 2rem;
72
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
73
+ font-size: 0.875rem;
74
+ color: #A5B4FC;
75
+ }
76
+ </style>
77
+ <footer>
78
+ <div class="footer-content">
79
+ <div class="footer-section">
80
+ <h3>ScribbleToScript</h3>
81
+ <p>Transform your digital text into beautiful, realistic handwriting with just a few clicks.</p>
82
+ <div class="social-links">
83
+ <a href="#"><i data-feather="twitter"></i></a>
84
+ <a href="#"><i data-feather="github"></i></a>
85
+ <a href="#"><i data-feather="instagram"></i></a>
86
+ </div>
87
+ </div>
88
+ <div class="footer-section">
89
+ <h3>Quick Links</h3>
90
+ <ul>
91
+ <li><a href="#">Home</a></li>
92
+ <li><a href="#">Features</a></li>
93
+ <li><a href="#">About</a></li>
94
+ <li><a href="#">Contact</a></li>
95
+ </ul>
96
+ </div>
97
+ <div class="footer-section">
98
+ <h3>Resources</h3>
99
+ <ul>
100
+ <li><a href="#">Documentation</a></li>
101
+ <li><a href="#">API</a></li>
102
+ <li><a href="#">FAQ</a></li>
103
+ <li><a href="#">Blog</a></li>
104
+ </ul>
105
+ </div>
106
+ </div>
107
+ <div class="copyright">
108
+ &copy; ${new Date().getFullYear()} ScribbleToScript. All rights reserved.
109
+ </div>
110
+ </footer>
111
+ `;
112
+ }
113
+ }
114
+ customElements.define('custom-footer', CustomFooter);
components/navbar.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNavbar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ nav {
7
+ background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
8
+ padding: 1rem 2rem;
9
+ display: flex;
10
+ justify-content: space-between;
11
+ align-items: center;
12
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
13
+ }
14
+ .logo {
15
+ color: white;
16
+ font-weight: bold;
17
+ font-size: 1.5rem;
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 0.5rem;
21
+ }
22
+ ul {
23
+ display: flex;
24
+ gap: 1.5rem;
25
+ list-style: none;
26
+ margin: 0;
27
+ padding: 0;
28
+ }
29
+ a {
30
+ color: white;
31
+ text-decoration: none;
32
+ font-weight: 500;
33
+ padding: 0.5rem 1rem;
34
+ border-radius: 0.375rem;
35
+ transition: background-color 0.2s;
36
+ }
37
+ a:hover {
38
+ background-color: rgba(255, 255, 255, 0.1);
39
+ }
40
+ .github-btn {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 0.5rem;
44
+ background-color: rgba(255, 255, 255, 0.1);
45
+ padding: 0.5rem 1rem;
46
+ border-radius: 0.375rem;
47
+ }
48
+ .github-btn:hover {
49
+ background-color: rgba(255, 255, 255, 0.2);
50
+ }
51
+ @media (max-width: 768px) {
52
+ nav {
53
+ flex-direction: column;
54
+ gap: 1rem;
55
+ padding: 1rem;
56
+ }
57
+ ul {
58
+ flex-wrap: wrap;
59
+ justify-content: center;
60
+ }
61
+ }
62
+ </style>
63
+ <nav>
64
+ <a href="/" class="logo">
65
+ <i data-feather="pen-tool"></i>
66
+ ScribbleToScript
67
+ </a>
68
+ <ul>
69
+ <li><a href="/">Home</a></li>
70
+ <li><a href="#">Features</a></li>
71
+ <li><a href="#">About</a></li>
72
+ <li>
73
+ <a href="https://github.com/saurabhdaware/text-to-handwriting" target="_blank" class="github-btn">
74
+ <i data-feather="github"></i>
75
+ GitHub
76
+ </a>
77
+ </li>
78
+ </ul>
79
+ </nav>
80
+ `;
81
+ }
82
+ }
83
+ customElements.define('custom-navbar', CustomNavbar);
index.html CHANGED
@@ -1,19 +1,72 @@
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>ScribbleToScript - Convert Text to Handwriting</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ </head>
12
+ <body class="bg-gray-50 min-h-screen flex flex-col">
13
+ <custom-navbar></custom-navbar>
14
+
15
+ <main class="flex-grow container mx-auto px-4 py-12">
16
+ <div class="max-w-4xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden">
17
+ <div class="p-8">
18
+ <h1 class="text-4xl font-bold text-gray-800 mb-2">Turn Digital Text into<br>Beautiful Handwriting</h1>
19
+ <p class="text-gray-600 mb-8">Simply type your text below and watch it transform into realistic handwriting</p>
20
+
21
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
22
+ <div class="space-y-4">
23
+ <div class="flex items-center gap-3">
24
+ <i data-feather="edit-3" class="text-indigo-500"></i>
25
+ <h3 class="text-xl font-semibold text-gray-700">Input Text</h3>
26
+ </div>
27
+ <textarea id="inputText" rows="12" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="Type or paste your text here..."></textarea>
28
+
29
+ <div class="space-y-2">
30
+ <label class="flex items-center gap-2">
31
+ <input type="checkbox" id="showLines" class="rounded text-indigo-500">
32
+ <span class="text-gray-700">Show ruled lines</span>
33
+ </label>
34
+
35
+ <div class="flex items-center gap-4">
36
+ <button id="generateBtn" class="px-6 py-3 bg-indigo-600 text-white font-medium rounded-lg hover:bg-indigo-700 transition flex items-center gap-2">
37
+ <i data-feather="pen-tool"></i>
38
+ Generate
39
+ </button>
40
+ <button id="downloadBtn" class="px-6 py-3 bg-white border border-indigo-500 text-indigo-600 font-medium rounded-lg hover:bg-indigo-50 transition flex items-center gap-2">
41
+ <i data-feather="download"></i>
42
+ Download
43
+ </button>
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <div class="bg-gray-50 rounded-lg border border-gray-200 p-6">
49
+ <div class="flex items-center gap-3 mb-4">
50
+ <i data-feather="image" class="text-indigo-500"></i>
51
+ <h3 class="text-xl font-semibold text-gray-700">Handwritten Output</h3>
52
+ </div>
53
+ <div id="outputCanvas" class="bg-white border border-gray-200 rounded-lg p-4 min-h-64 flex items-center justify-center">
54
+ <p class="text-gray-400">Your handwritten text will appear here</p>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </main>
61
+
62
+ <custom-footer></custom-footer>
63
+
64
+ <script src="components/navbar.js"></script>
65
+ <script src="components/footer.js"></script>
66
+ <script src="script.js"></script>
67
+ <script>
68
+ feather.replace();
69
+ </script>
70
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
71
+ </body>
72
+ </html>
script.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const inputText = document.getElementById('inputText');
3
+ const generateBtn = document.getElementById('generateBtn');
4
+ const downloadBtn = document.getElementById('downloadBtn');
5
+ const outputCanvas = document.getElementById('outputCanvas');
6
+ const showLines = document.getElementById('showLines');
7
+
8
+ generateBtn.addEventListener('click', function() {
9
+ const text = inputText.value.trim();
10
+ if (!text) {
11
+ outputCanvas.innerHTML = '<p class="text-gray-400">Please enter some text first</p>';
12
+ return;
13
+ }
14
+
15
+ // Add loading state
16
+ generateBtn.innerHTML = '<i data-feather="loader" class="animate-spin"></i> Generating...';
17
+ feather.replace();
18
+
19
+ // Simulate generation (in a real app, this would use a handwriting API)
20
+ setTimeout(() => {
21
+ const lines = text.split('\n');
22
+ let html = '';
23
+
24
+ if (showLines.checked) {
25
+ html += '<div class="relative">';
26
+ html += '<div class="absolute inset-0 bg-cyan-50 bg-opacity-20" style="background-image: linear-gradient(to bottom, transparent 95%, rgba(0,0,0,0.1) 95%); background-size: 100% 28px;"></div>';
27
+ }
28
+
29
+ html += '<p class="handwriting text-2xl leading-loose" style="white-space: pre-wrap;">';
30
+
31
+ for (const line of lines) {
32
+ if (line.trim() === '') {
33
+ html += '<br>';
34
+ } else {
35
+ // Add slight variations to make it look more natural
36
+ const weightVariation = Math.random() * 0.4 - 0.2;
37
+ const sizeVariation = Math.random() * 0.4 - 0.2;
38
+
39
+ html += `<span style="font-weight: ${400 + weightVariation * 100}; font-size: ${1 + sizeVariation}em">${line}</span>`;
40
+ }
41
+ html += '\n';
42
+ }
43
+
44
+ html += '</p>';
45
+
46
+ if (showLines.checked) {
47
+ html += '</div>';
48
+ }
49
+
50
+ outputCanvas.innerHTML = html;
51
+
52
+ // Reset button
53
+ generateBtn.innerHTML = '<i data-feather="pen-tool"></i> Generate';
54
+ feather.replace();
55
+ }, 1000);
56
+ });
57
+
58
+ downloadBtn.addEventListener('click', function() {
59
+ alert('In a real implementation, this would download the generated handwriting as an image or PDF.');
60
+ });
61
+
62
+ // Initialize with some sample text
63
+ inputText.value = "Dear Diary,\n\nToday I discovered this amazing tool that turns my digital text into beautiful handwriting!\n\nIt's like magic ✨\n\nSincerely,\nMe";
64
+ });
style.css CHANGED
@@ -1,28 +1,27 @@
 
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
 
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }
 
1
+ /* Custom styles */
2
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
3
+
4
  body {
5
+ font-family: 'Inter', sans-serif;
 
6
  }
7
 
8
+ /* Custom handwriting font */
9
+ @font-face {
10
+ font-family: 'Handwriting';
11
+ src: url('https://fonts.gstatic.com/s/indieflower/v12/m8JVjfNVeKWVnh3QMuKkFcZVaUuH99GUDg.woff2') format('woff2');
12
  }
13
 
14
+ .handwriting {
15
+ font-family: 'Handwriting', cursive;
 
 
 
16
  }
17
 
18
+ /* Animation for the generate button */
19
+ @keyframes pulse {
20
+ 0% { transform: scale(1); }
21
+ 50% { transform: scale(1.05); }
22
+ 100% { transform: scale(1); }
 
23
  }
24
 
25
+ .animate-pulse {
26
+ animation: pulse 1.5s infinite;
27
+ }