NicheC commited on
Commit
f3b69f2
·
verified ·
1 Parent(s): 07fdc28

Upload 4 files

Browse files
Files changed (4) hide show
  1. DEPLOYMENT_INSTRUCTIONS.md +208 -0
  2. GITHUB_SETUP.md +144 -0
  3. README.md +62 -0
  4. app.py +397 -0
DEPLOYMENT_INSTRUCTIONS.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LUXBIN - Hugging Face Deployment Instructions
2
+
3
+ ## 📋 Complete Deployment Guide
4
+
5
+ Follow these steps to deploy your LUXBIN demo to Hugging Face Spaces.
6
+
7
+ ---
8
+
9
+ ## Prerequisites
10
+
11
+ 1. **Hugging Face Account**: Create one at [huggingface.co](https://huggingface.co)
12
+ 2. **Git Installed**: For uploading files (or use the web interface)
13
+
14
+ ---
15
+
16
+ ## Method 1: Web Upload (Easiest)
17
+
18
+ ### Step 1: Create New Space
19
+
20
+ 1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
21
+ 2. Click **"Create new Space"**
22
+ 3. Fill in:
23
+ - **Space name**: `luxbin-demo` (or your preferred name)
24
+ - **License**: `mit` or `apache-2.0`
25
+ - **SDK**: Select **Gradio**
26
+ - **Space hardware**: `CPU basic` (free tier works fine)
27
+ 4. Click **"Create Space"**
28
+
29
+ ### Step 2: Upload Files
30
+
31
+ You'll see an empty repository. Upload these 3 files:
32
+
33
+ **File 1: `app.py`**
34
+ - Click **"Files and versions"** → **"Add file"** → **"Upload files"**
35
+ - Upload: `/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO/app.py`
36
+
37
+ **File 2: `requirements.txt`**
38
+ - Click **"Add file"** → **"Upload files"** again
39
+ - Upload: `/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO/requirements.txt`
40
+
41
+ **File 3: `README.md`**
42
+ - The README.md is auto-created, but replace it with:
43
+ - Click on `README.md` → **"Edit"**
44
+ - Copy contents from `/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO/README.md`
45
+ - Click **"Commit changes to main"**
46
+
47
+ ### Step 3: Wait for Build
48
+
49
+ - Hugging Face will automatically build your Space
50
+ - Watch the build logs at the top of the page
51
+ - Should take 1-2 minutes
52
+ - When you see **"Running"** status, it's live!
53
+
54
+ ### Step 4: Test
55
+
56
+ 1. Visit your Space URL: `https://huggingface.co/spaces/YOUR_USERNAME/luxbin-demo`
57
+ 2. Try the encoder with "HELLO WORLD"
58
+ 3. Test different grammar settings
59
+ 4. View the alphabet wheel and grammar guide
60
+
61
+ ---
62
+
63
+ ## Method 2: Git Upload (Advanced)
64
+
65
+ ### Step 1: Create Space
66
+
67
+ Same as Method 1 - create the Space on Hugging Face website first.
68
+
69
+ ### Step 2: Clone Repository
70
+
71
+ ```bash
72
+ cd ~/Desktop
73
+ git clone https://huggingface.co/spaces/YOUR_USERNAME/luxbin-demo
74
+ cd luxbin-demo
75
+ ```
76
+
77
+ ### Step 3: Copy Files
78
+
79
+ ```bash
80
+ cp "/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO/app.py" .
81
+ cp "/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO/requirements.txt" .
82
+ cp "/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO/README.md" .
83
+ ```
84
+
85
+ ### Step 4: Push to Hugging Face
86
+
87
+ ```bash
88
+ git add .
89
+ git commit -m "Initial LUXBIN demo"
90
+ git push
91
+ ```
92
+
93
+ ### Step 5: Verify
94
+
95
+ Visit your Space URL and test the app.
96
+
97
+ ---
98
+
99
+ ## Troubleshooting
100
+
101
+ ### Build Fails with Gradio Import Error
102
+
103
+ **Error**: `ImportError: cannot import name 'HfFolder' from 'huggingface_hub'`
104
+
105
+ **Fix**: Make sure `requirements.txt` has:
106
+ ```txt
107
+ gradio>=5.9.1
108
+ huggingface-hub>=1.2.0
109
+ ```
110
+
111
+ **NOT**:
112
+ ```txt
113
+ gradio==4.44.1 ❌ (too old)
114
+ ```
115
+
116
+ ### Font Not Found Warnings
117
+
118
+ **Warning**: `Cannot open font resource`
119
+
120
+ **Impact**: Letters on hue wheel may not display perfectly, but app still works
121
+
122
+ **Fix** (optional): Add to `requirements.txt`:
123
+ ```txt
124
+ matplotlib>=3.7.0
125
+ ```
126
+
127
+ And update font path in `app.py`:
128
+ ```python
129
+ try:
130
+ font = ImageFont.truetype("DejaVuSans.ttf", 16)
131
+ except:
132
+ font = ImageFont.load_default()
133
+ ```
134
+
135
+ ### Space Shows "Building" Forever
136
+
137
+ 1. Check build logs for errors
138
+ 2. Most common: requirements.txt syntax error
139
+ 3. Fix: Make sure each package is on its own line, no trailing spaces
140
+
141
+ ---
142
+
143
+ ## Updating Your Space
144
+
145
+ ### Web Method:
146
+ 1. Go to your Space
147
+ 2. Click **"Files and versions"**
148
+ 3. Click on the file you want to edit
149
+ 4. Make changes
150
+ 5. Click **"Commit changes to main"**
151
+
152
+ ### Git Method:
153
+ ```bash
154
+ cd luxbin-demo
155
+ # Make your changes to app.py or other files
156
+ git add .
157
+ git commit -m "Updated encoder logic"
158
+ git push
159
+ ```
160
+
161
+ Space will automatically rebuild!
162
+
163
+ ---
164
+
165
+ ## Making Your Space Public
166
+
167
+ By default, Spaces are public. To change visibility:
168
+
169
+ 1. Go to your Space settings
170
+ 2. Scroll to **"Visibility"**
171
+ 3. Choose **"Public"** or **"Private"**
172
+
173
+ ---
174
+
175
+ ## Sharing Your Space
176
+
177
+ Your Space URL is:
178
+ ```
179
+ https://huggingface.co/spaces/YOUR_USERNAME/luxbin-demo
180
+ ```
181
+
182
+ Share this link! People can:
183
+ - Use the encoder without signing in
184
+ - See your README documentation
185
+ - Fork your Space to make their own version
186
+
187
+ ---
188
+
189
+ ## Next Steps
190
+
191
+ 1. **Customize**: Add more LUXBIN features (decoder, animations, sound)
192
+ 2. **Document**: Add examples and tutorials to README
193
+ 3. **Share**: Post on social media, forums, etc.
194
+ 4. **Improve**: Add temporal encoding visualization, sentence structure, etc.
195
+
196
+ ---
197
+
198
+ ## Support
199
+
200
+ - **Hugging Face Docs**: [huggingface.co/docs/hub/spaces](https://huggingface.co/docs/hub/spaces)
201
+ - **Gradio Docs**: [gradio.app/docs](https://www.gradio.app/docs)
202
+ - **LUXBIN Spec**: See `README.md` in this demo
203
+
204
+ ---
205
+
206
+ **Your LUXBIN demo is ready to deploy!** 🚀
207
+
208
+ Choose Method 1 (web upload) for simplicity, or Method 2 (git) if you're comfortable with command line.
GITHUB_SETUP.md ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GitHub Repository Setup for LUXBIN
2
+
3
+ ## ✅ Git Initialized & Ready
4
+
5
+ Your local git repository is ready with a clean commit!
6
+
7
+ **Important**: LUXBIN is a separate project from QuantumGameDevAI, so it needs its own repository.
8
+
9
+ ---
10
+
11
+ ## 🎯 Create New GitHub Repository for LUXBIN
12
+
13
+ ### Step 1: Create Repository on GitHub
14
+
15
+ 1. Go to [github.com/new](https://github.com/new)
16
+ 2. Fill in:
17
+ - **Repository name**: `LUXBIN-Demo` (or `luxbin-photonic-language`)
18
+ - **Description**: `⚛️ Photonic Binary Language - Colors are letters, shades are grammar`
19
+ - **Visibility**: ✅ **Public** (recommended for sharing)
20
+ - **Important**: ❌ **DON'T** initialize with README, .gitignore, or license
21
+ 3. Click **"Create repository"**
22
+
23
+ ### Step 2: Push Your Code
24
+
25
+ After creating the empty repo, run these commands:
26
+
27
+ ```bash
28
+ cd "/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO"
29
+
30
+ # Add your new GitHub repo as remote (replace YOUR_USERNAME)
31
+ git remote add origin https://github.com/YOUR_USERNAME/LUXBIN-Demo.git
32
+
33
+ # Push to GitHub
34
+ git branch -M main
35
+ git push -u origin main
36
+ ```
37
+
38
+ **Example** (if your username is "nichechristie"):
39
+ ```bash
40
+ git remote add origin https://github.com/nichechristie/LUXBIN-Demo.git
41
+ git branch -M main
42
+ git push -u origin main
43
+ ```
44
+
45
+ ---
46
+
47
+ ## ✨ What's Included
48
+
49
+ Your repository contains:
50
+
51
+ ```
52
+ LUXBIN_HF_DEMO/
53
+ ├── app.py # Complete Gradio demo app
54
+ ├── requirements.txt # Python dependencies (Gradio 5.9.1+)
55
+ ├── README.md # Hugging Face Space documentation
56
+ ├── DEPLOYMENT_INSTRUCTIONS.md # HF deployment guide
57
+ ├── GITHUB_SETUP.md # This file
58
+ └── .gitignore # Git ignore patterns
59
+
60
+ ✅ Commit: "Initial commit - LUXBIN Photonic Binary Language Demo"
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 🚀 After Pushing to GitHub
66
+
67
+ ### Option 1: Deploy to Hugging Face from GitHub (Easiest)
68
+
69
+ 1. Go to [huggingface.co/new-space](https://huggingface.co/new-space)
70
+ 2. Click **"Import from GitHub"**
71
+ 3. Select your `LUXBIN-Demo` repository
72
+ 4. Hugging Face automatically:
73
+ - Reads `README.md` for the Space card
74
+ - Installs packages from `requirements.txt`
75
+ - Runs `app.py` as the Gradio app
76
+ 5. Your demo goes live in 1-2 minutes! ✨
77
+
78
+ ### Option 2: Manual Hugging Face Upload
79
+
80
+ Follow the detailed instructions in `DEPLOYMENT_INSTRUCTIONS.md`
81
+
82
+ ---
83
+
84
+ ## 📊 Repository Description
85
+
86
+ For your GitHub repo, add this description:
87
+
88
+ ```
89
+ ⚛️ LUXBIN - Photonic Binary Language where colors are letters and shades are grammar.
90
+ Interactive Gradio demo for encoding text into photonic color sequences using HSL color space.
91
+ ```
92
+
93
+ ### Suggested Topics
94
+
95
+ Add these topics to your GitHub repo for discoverability:
96
+
97
+ - `photonics`
98
+ - `language`
99
+ - `gradio`
100
+ - `huggingface-spaces`
101
+ - `color-theory`
102
+ - `hsl-color`
103
+ - `binary`
104
+ - `communication`
105
+ - `python`
106
+ - `demo`
107
+
108
+ ---
109
+
110
+ ## 🔄 Future Updates
111
+
112
+ When you make changes:
113
+
114
+ ```bash
115
+ cd "/Users/nicholechristie/Documents/Unreal Projects/WWYD 5.7/LUXBIN_HF_DEMO"
116
+
117
+ # Make your changes to files...
118
+
119
+ git add .
120
+ git commit -m "Description of changes"
121
+ git push
122
+ ```
123
+
124
+ If you connected GitHub to Hugging Face, the Space auto-updates!
125
+
126
+ ---
127
+
128
+ ## 🎯 Two Separate Projects
129
+
130
+ You now have:
131
+
132
+ 1. **QuantumGameDevAI** - AI-powered game development toolkit
133
+ - Repo: `github.com/nichechristie/QuantumGameDevAI`
134
+
135
+ 2. **LUXBIN-Demo** - Photonic binary language demo
136
+ - Repo: `github.com/YOUR_USERNAME/LUXBIN-Demo` (create this now)
137
+
138
+ Keep them separate for better organization!
139
+
140
+ ---
141
+
142
+ **Create the new LUXBIN GitHub repository and push your code!** 🎨⚛️
143
+
144
+ Run the commands in Step 2 after creating the repo.
README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: LUXBIN - Photonic Binary Language
3
+ emoji: ⚛️
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: gradio
7
+ app_file: app.py
8
+ pinned: false
9
+ ---
10
+
11
+ # ⚛️ LUXBIN - Photonic Binary Language
12
+
13
+ **A language where colors are letters and shades are grammar**
14
+
15
+ ## What is LUXBIN?
16
+
17
+ LUXBIN is a photonic binary language where semantic information is encoded directly in the physical properties of light. Instead of using traditional text or binary digits, LUXBIN uses color and light to communicate.
18
+
19
+ ### Key Concepts
20
+
21
+ - **Hue (0°-360°)** = Letter identity (A-Z)
22
+ - **Saturation** = Part of speech (Noun, Verb, Adjective, etc.)
23
+ - **Lightness** = Tense/mode (Present, Past, Future, Conditional)
24
+ - **Timing** = Word and sentence boundaries
25
+
26
+ ### How It Works
27
+
28
+ 1. **26 Letters**: A-Z are mapped to hue values from 0° to 140.625° in 5.625° steps
29
+ 2. **Grammar Encoding**: Saturation and lightness encode grammatical information
30
+ 3. **Visual Output**: Text is converted to a sequence of colored blocks
31
+ 4. **Binary Foundation**: 6-bit indexing (64 total symbols possible)
32
+
33
+ ## Features
34
+
35
+ This demo lets you:
36
+
37
+ - 📤 **Encode Text**: Convert any text into LUXBIN color sequences
38
+ - 🎨 **Visual Alphabet**: See the complete hue wheel with all 26 letters
39
+ - 📚 **Grammar Guide**: Understand how saturation and lightness encode grammar
40
+ - ℹ️ **Learn More**: Explore the complete LUXBIN specification
41
+
42
+ ## Applications
43
+
44
+ - **Assistive Technology**: Non-verbal communication
45
+ - **Secure Communication**: Line-of-sight only, hard to intercept
46
+ - **Extreme Environments**: Underwater, space, RF-denied zones
47
+ - **Human-Machine Interfaces**: Direct photonic signaling
48
+
49
+ ## Technical Details
50
+
51
+ - **Alphabet Size**: 26 letters + 38 extended symbols (64 total)
52
+ - **Color Space**: HSL (Hue, Saturation, Lightness)
53
+ - **Binary Base**: 6-bit indexing
54
+ - **Temporal Encoding**: 100ms/letter, 200ms/word, 500ms/sentence
55
+
56
+ ## Created By
57
+
58
+ **Nicholechristie** - Open Specification Language
59
+
60
+ ## Try It
61
+
62
+ Use the encoder tab to convert text like "HELLO WORLD" into photonic sequences and see how grammar affects the colors!
app.py ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ LUXBIN - Photonic Binary Language Demo
3
+ A language where colors are letters and shades are grammar
4
+ """
5
+
6
+ import gradio as gr
7
+ import numpy as np
8
+ from PIL import Image, ImageDraw, ImageFont
9
+ import time
10
+
11
+ # LUXBIN Alphabet (26 letters A-Z)
12
+ ALPHABET = {
13
+ 'A': 0.0, 'B': 5.625, 'C': 11.25, 'D': 16.875, 'E': 22.5,
14
+ 'F': 28.125, 'G': 33.75, 'H': 39.375, 'I': 45.0, 'J': 50.625,
15
+ 'K': 56.25, 'L': 61.875, 'M': 67.5, 'N': 73.125, 'O': 78.75,
16
+ 'P': 84.375, 'Q': 90.0, 'R': 95.625, 'S': 101.25, 'T': 106.875,
17
+ 'U': 112.5, 'V': 118.125, 'W': 123.75, 'X': 129.375, 'Y': 135.0,
18
+ 'Z': 140.625
19
+ }
20
+
21
+ # Reverse mapping
22
+ REVERSE_ALPHABET = {v: k for k, v in ALPHABET.items()}
23
+
24
+ # Grammar mappings
25
+ PARTS_OF_SPEECH = {
26
+ 'Noun': 100,
27
+ 'Verb': 75,
28
+ 'Adjective': 50,
29
+ 'Modifier': 30,
30
+ 'Control': 0
31
+ }
32
+
33
+ TENSES = {
34
+ 'Present': 70,
35
+ 'Past': 40,
36
+ 'Future': 85,
37
+ 'Conditional': 90
38
+ }
39
+
40
+
41
+ def hsl_to_rgb(h, s, l):
42
+ """Convert HSL to RGB (0-255)"""
43
+ s = s / 100.0
44
+ l = l / 100.0
45
+
46
+ c = (1 - abs(2 * l - 1)) * s
47
+ x = c * (1 - abs((h / 60) % 2 - 1))
48
+ m = l - c / 2
49
+
50
+ if h < 60:
51
+ r, g, b = c, x, 0
52
+ elif h < 120:
53
+ r, g, b = x, c, 0
54
+ elif h < 180:
55
+ r, g, b = 0, c, x
56
+ elif h < 240:
57
+ r, g, b = 0, x, c
58
+ elif h < 300:
59
+ r, g, b = x, 0, c
60
+ else:
61
+ r, g, b = c, 0, x
62
+
63
+ return int((r + m) * 255), int((g + m) * 255), int((b + m) * 255)
64
+
65
+
66
+ def encode_text_to_luxbin(text, part_of_speech='Noun', tense='Present'):
67
+ """Encode text to LUXBIN color sequence"""
68
+ text = text.upper()
69
+ saturation = PARTS_OF_SPEECH.get(part_of_speech, 100)
70
+ lightness = TENSES.get(tense, 70)
71
+
72
+ colors = []
73
+ for char in text:
74
+ if char == ' ':
75
+ colors.append((0, 0, 0)) # Black for space
76
+ elif char in ALPHABET:
77
+ hue = ALPHABET[char]
78
+ rgb = hsl_to_rgb(hue, saturation, lightness)
79
+ colors.append(rgb)
80
+ else:
81
+ colors.append((128, 128, 128)) # Gray for unknown
82
+
83
+ return colors
84
+
85
+
86
+ def create_color_strip(colors, width=800, height=100):
87
+ """Create image showing color sequence"""
88
+ if not colors:
89
+ return Image.new('RGB', (width, height), 'black')
90
+
91
+ img = Image.new('RGB', (width, height))
92
+ draw = ImageDraw.Draw(img)
93
+
94
+ block_width = width // len(colors)
95
+
96
+ for i, color in enumerate(colors):
97
+ x1 = i * block_width
98
+ x2 = x1 + block_width
99
+ draw.rectangle([x1, 0, x2, height], fill=color)
100
+
101
+ return img
102
+
103
+
104
+ def create_hue_wheel(size=400):
105
+ """Create visual hue wheel showing alphabet"""
106
+ img = Image.new('RGB', (size, size), 'white')
107
+ draw = ImageDraw.Draw(img)
108
+
109
+ center = size // 2
110
+ radius = size // 2 - 20
111
+
112
+ # Draw color wheel
113
+ for i in range(360):
114
+ angle = i * np.pi / 180
115
+ hue = i
116
+ rgb = hsl_to_rgb(hue, 100, 70)
117
+
118
+ x1 = center + int((radius - 30) * np.cos(angle))
119
+ y1 = center + int((radius - 30) * np.sin(angle))
120
+ x2 = center + int(radius * np.cos(angle))
121
+ y2 = center + int(radius * np.sin(angle))
122
+
123
+ draw.line([x1, y1, x2, y2], fill=rgb, width=2)
124
+
125
+ # Add letter labels
126
+ try:
127
+ font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 16)
128
+ except:
129
+ font = ImageFont.load_default()
130
+
131
+ for letter, hue in ALPHABET.items():
132
+ angle = (hue - 90) * np.pi / 180 # Adjust for top = 0°
133
+ label_radius = radius + 30
134
+ x = center + int(label_radius * np.cos(angle))
135
+ y = center + int(label_radius * np.sin(angle))
136
+
137
+ # Draw letter
138
+ bbox = draw.textbbox((x, y), letter, font=font)
139
+ draw.text((x - (bbox[2] - bbox[0]) / 2, y - (bbox[3] - bbox[1]) / 2),
140
+ letter, fill='black', font=font)
141
+
142
+ return img
143
+
144
+
145
+ def encode_demo(text, pos, tense):
146
+ """Main encoding function"""
147
+ colors = encode_text_to_luxbin(text, pos, tense)
148
+ strip = create_color_strip(colors)
149
+
150
+ # Create description
151
+ desc = f"**LUXBIN Encoding**\n\n"
152
+ desc += f"Text: `{text}`\n\n"
153
+ desc += f"Grammar: {pos} (Saturation: {PARTS_OF_SPEECH[pos]}%), "
154
+ desc += f"{tense} (Lightness: {TENSES[tense]}%)\n\n"
155
+ desc += f"**Color Sequence:** {len(colors)} symbols\n\n"
156
+
157
+ # List each letter with its color
158
+ for i, char in enumerate(text.upper()):
159
+ if char == ' ':
160
+ desc += "` ` → Black (word boundary)\n\n"
161
+ elif char in ALPHABET:
162
+ desc += f"`{char}` → Hue {ALPHABET[char]:.1f}° (RGB: {colors[i]})\n\n"
163
+
164
+ return strip, desc
165
+
166
+
167
+ def create_grammar_guide():
168
+ """Create visual guide for grammar rules"""
169
+ img = Image.new('RGB', (600, 400), 'white')
170
+ draw = ImageDraw.Draw(img)
171
+
172
+ try:
173
+ font_title = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
174
+ font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
175
+ except:
176
+ font_title = font = ImageFont.load_default()
177
+
178
+ y = 20
179
+
180
+ # Title
181
+ draw.text((20, y), "LUXBIN Grammar Rules", fill='black', font=font_title)
182
+ y += 40
183
+
184
+ # Saturation (Parts of Speech)
185
+ draw.text((20, y), "Saturation → Part of Speech", fill='black', font=font)
186
+ y += 30
187
+
188
+ for pos, sat in PARTS_OF_SPEECH.items():
189
+ rgb = hsl_to_rgb(180, sat, 70) # Use cyan hue for demo
190
+ draw.rectangle([20, y, 70, y + 20], fill=rgb, outline='black')
191
+ draw.text((80, y + 3), f"{pos}: {sat}%", fill='black', font=font)
192
+ y += 30
193
+
194
+ y += 20
195
+
196
+ # Lightness (Tense)
197
+ draw.text((20, y), "Lightness → Tense/Mode", fill='black', font=font)
198
+ y += 30
199
+
200
+ for tense, light in TENSES.items():
201
+ rgb = hsl_to_rgb(180, 100, light) # Use cyan hue for demo
202
+ draw.rectangle([20, y, 70, y + 20], fill=rgb, outline='black')
203
+ draw.text((80, y + 3), f"{tense}: {light}%", fill='black', font=font)
204
+ y += 30
205
+
206
+ return img
207
+
208
+
209
+ # Create Gradio interface
210
+ with gr.Blocks(title="LUXBIN - Photonic Binary Language", theme=gr.themes.Soft()) as demo:
211
+ gr.Markdown("""
212
+ # ⚛️ LUXBIN - Photonic Binary Language
213
+
214
+ **A language where colors are letters and shades are grammar**
215
+
216
+ - **Hue (0°-360°)** = Letter identity (A-Z)
217
+ - **Saturation** = Part of speech (Noun, Verb, etc.)
218
+ - **Lightness** = Tense/mode (Present, Past, etc.)
219
+ - **Timing** = Word and sentence boundaries
220
+
221
+ ---
222
+ """)
223
+
224
+ with gr.Tabs():
225
+ # Tab 1: Encoder
226
+ with gr.Tab("📤 Encode Text to LUXBIN"):
227
+ gr.Markdown("### Convert text into photonic color sequences")
228
+
229
+ with gr.Row():
230
+ with gr.Column():
231
+ text_input = gr.Textbox(
232
+ label="Enter Text",
233
+ placeholder="HELLO WORLD",
234
+ value="HELLO"
235
+ )
236
+
237
+ pos_input = gr.Dropdown(
238
+ choices=list(PARTS_OF_SPEECH.keys()),
239
+ value="Noun",
240
+ label="Part of Speech (Saturation)"
241
+ )
242
+
243
+ tense_input = gr.Dropdown(
244
+ choices=list(TENSES.keys()),
245
+ value="Present",
246
+ label="Tense/Mode (Lightness)"
247
+ )
248
+
249
+ encode_btn = gr.Button("🎨 Encode to LUXBIN", variant="primary")
250
+
251
+ with gr.Column():
252
+ color_output = gr.Image(label="LUXBIN Color Sequence")
253
+ desc_output = gr.Markdown()
254
+
255
+ encode_btn.click(
256
+ fn=encode_demo,
257
+ inputs=[text_input, pos_input, tense_input],
258
+ outputs=[color_output, desc_output]
259
+ )
260
+
261
+ gr.Markdown("""
262
+ **How to read:**
263
+ - Each color block = one letter
264
+ - Black = space (word boundary)
265
+ - Hue = which letter (A-Z)
266
+ - Saturation = grammatical role
267
+ - Lightness = tense
268
+ """)
269
+
270
+ # Tab 2: Alphabet Reference
271
+ with gr.Tab("🎨 Alphabet & Hue Wheel"):
272
+ gr.Markdown("### Visual reference for the LUXBIN alphabet")
273
+
274
+ wheel_img = create_hue_wheel()
275
+ gr.Image(value=wheel_img, label="LUXBIN Hue Wheel (26 Letters)")
276
+
277
+ gr.Markdown("""
278
+ **How it works:**
279
+ - 360° hue spectrum divided into 64 symbols
280
+ - A-Z occupy first 26 positions
281
+ - Step size: 5.625° per symbol
282
+ - A = 0° (red), Z = 140.625° (greenish-blue)
283
+ """)
284
+
285
+ # Show alphabet table
286
+ gr.Markdown("### Complete Alphabet")
287
+
288
+ alphabet_html = "<table style='width:100%'><tr>"
289
+ for i, (letter, hue) in enumerate(ALPHABET.items()):
290
+ if i % 6 == 0 and i > 0:
291
+ alphabet_html += "</tr><tr>"
292
+ rgb = hsl_to_rgb(hue, 100, 70)
293
+ alphabet_html += f"<td style='background-color:rgb{rgb}; padding:10px; text-align:center; border:1px solid black;'><b>{letter}</b><br>{hue:.1f}°</td>"
294
+ alphabet_html += "</tr></table>"
295
+
296
+ gr.HTML(alphabet_html)
297
+
298
+ # Tab 3: Grammar Guide
299
+ with gr.Tab("📚 Grammar Rules"):
300
+ gr.Markdown("### LUXBIN grammar encoded in light properties")
301
+
302
+ grammar_img = create_grammar_guide()
303
+ gr.Image(value=grammar_img, label="Grammar Visual Guide")
304
+
305
+ gr.Markdown("""
306
+ ### Encoding Rules
307
+
308
+ **Binary Layer:**
309
+ - Each symbol = 6 bits (0-63)
310
+ - Binary indexes photonic states
311
+ - Not direct letter encoding
312
+
313
+ **Photonic Layer:**
314
+ - Hue = semantic identity (which letter/symbol)
315
+ - Saturation = grammatical role
316
+ - Lightness = temporal/modal information
317
+
318
+ **Temporal Layer:**
319
+ - 100ms = letter duration
320
+ - 200ms dark = word boundary
321
+ - 500ms dark = sentence end
322
+
323
+ **Modifiers:**
324
+ - +10% darker = plural
325
+ - -10% lighter = negation
326
+ - Rapid flicker = emphasis
327
+ - Smooth fade = completion
328
+ """)
329
+
330
+ # Tab 4: About
331
+ with gr.Tab("ℹ️ About LUXBIN"):
332
+ gr.Markdown("""
333
+ # About LUXBIN
334
+
335
+ **LUXBIN** is a photonic binary language where semantic information is encoded directly in the physical properties of light.
336
+
337
+ ## Key Concepts
338
+
339
+ 1. **Physics as Syntax**: Light parameters carry meaning
340
+ 2. **Parallel Channels**: Multiple layers of information in one photon
341
+ 3. **Non-Linear Encoding**: Not a cipher, but a genuine language
342
+
343
+ ## Applications
344
+
345
+ - **Assistive Technology**: Non-verbal communication
346
+ - **Secure Communication**: Line-of-sight only, hard to intercept
347
+ - **Extreme Environments**: Underwater, space, RF-denied zones
348
+ - **Human-Machine Interfaces**: Direct photonic signaling
349
+
350
+ ## Technical Details
351
+
352
+ - **Alphabet Size**: 26 letters + 38 extended symbols
353
+ - **Color Space**: HSL (Hue, Saturation, Lightness)
354
+ - **Binary Base**: 6-bit indexing (64 total symbols)
355
+ - **Grammar Layers**: Saturation, Lightness, Temporal
356
+
357
+ ## Implementation
358
+
359
+ - **Hardware**: ESP32 + WS2812 RGB LEDs
360
+ - **Software**: Python encoder/decoder
361
+ - **Perception**: Trainable by humans in ~30 minutes
362
+
363
+ ## Status
364
+
365
+ LUXBIN is a complete language specification ready for:
366
+ - Hardware prototyping
367
+ - Human perception testing
368
+ - Standardization
369
+ - Publication
370
+
371
+ ---
372
+
373
+ **Created by:** Nicholechristie
374
+ **Version:** 1.0
375
+ **License:** Open Specification
376
+ """)
377
+
378
+ # Examples
379
+ gr.Markdown("---")
380
+ gr.Markdown("### 🚀 Try These Examples")
381
+
382
+ gr.Examples(
383
+ examples=[
384
+ ["HELLO WORLD", "Noun", "Present"],
385
+ ["TEST", "Verb", "Past"],
386
+ ["AI LANGUAGE", "Noun", "Future"],
387
+ ["QUANTUM", "Adjective", "Present"],
388
+ ],
389
+ inputs=[text_input, pos_input, tense_input],
390
+ outputs=[color_output, desc_output],
391
+ fn=encode_demo,
392
+ cache_examples=True
393
+ )
394
+
395
+ # Launch
396
+ if __name__ == "__main__":
397
+ demo.launch()