Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +486 -19
- prompts.txt +1 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
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: draw-your-world
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: green
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,486 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>World Map Editor</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/chroma.min.js"></script>
|
9 |
+
<script src="https://unpkg.com/[email protected]/countries-110m.json"></script>
|
10 |
+
<script src="https://d3js.org/d3.v7.min.js"></script>
|
11 |
+
<script src="https://d3js.org/topojson.v3.min.js"></script>
|
12 |
+
<style>
|
13 |
+
.country {
|
14 |
+
stroke: #333;
|
15 |
+
stroke-width: 0.5px;
|
16 |
+
transition: all 0.3s ease;
|
17 |
+
}
|
18 |
+
.country:hover {
|
19 |
+
stroke-width: 1.5px;
|
20 |
+
stroke: #000;
|
21 |
+
}
|
22 |
+
.color-picker {
|
23 |
+
-webkit-appearance: none;
|
24 |
+
-moz-appearance: none;
|
25 |
+
appearance: none;
|
26 |
+
width: 40px;
|
27 |
+
height: 40px;
|
28 |
+
background-color: transparent;
|
29 |
+
border: none;
|
30 |
+
cursor: pointer;
|
31 |
+
}
|
32 |
+
.color-picker::-webkit-color-swatch {
|
33 |
+
border-radius: 8px;
|
34 |
+
border: 2px solid #ccc;
|
35 |
+
}
|
36 |
+
.color-picker::-moz-color-swatch {
|
37 |
+
border-radius: 8px;
|
38 |
+
border: 2px solid #ccc;
|
39 |
+
}
|
40 |
+
.tooltip {
|
41 |
+
position: absolute;
|
42 |
+
padding: 8px;
|
43 |
+
background: rgba(0, 0, 0, 0.8);
|
44 |
+
color: white;
|
45 |
+
border-radius: 4px;
|
46 |
+
pointer-events: none;
|
47 |
+
font-size: 12px;
|
48 |
+
z-index: 10;
|
49 |
+
}
|
50 |
+
.zoom-controls {
|
51 |
+
position: absolute;
|
52 |
+
top: 20px;
|
53 |
+
right: 20px;
|
54 |
+
z-index: 100;
|
55 |
+
display: flex;
|
56 |
+
flex-direction: column;
|
57 |
+
gap: 8px;
|
58 |
+
}
|
59 |
+
.zoom-btn {
|
60 |
+
width: 36px;
|
61 |
+
height: 36px;
|
62 |
+
border-radius: 50%;
|
63 |
+
background: white;
|
64 |
+
border: 1px solid #ddd;
|
65 |
+
display: flex;
|
66 |
+
align-items: center;
|
67 |
+
justify-content: center;
|
68 |
+
cursor: pointer;
|
69 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
70 |
+
font-size: 18px;
|
71 |
+
font-weight: bold;
|
72 |
+
}
|
73 |
+
.zoom-btn:hover {
|
74 |
+
background: #f0f0f0;
|
75 |
+
}
|
76 |
+
</style>
|
77 |
+
</head>
|
78 |
+
<body class="bg-gray-100 min-h-screen">
|
79 |
+
<div class="container mx-auto px-4 py-8">
|
80 |
+
<header class="mb-8">
|
81 |
+
<h1 class="text-4xl font-bold text-center text-blue-800 mb-2">World Map Editor</h1>
|
82 |
+
<p class="text-center text-gray-600">Customize your world map - color countries, adjust borders, and create your perfect visualization</p>
|
83 |
+
</header>
|
84 |
+
|
85 |
+
<div class="flex flex-col lg:flex-row gap-8">
|
86 |
+
<!-- Controls Panel -->
|
87 |
+
<div class="w-full lg:w-1/4 bg-white p-6 rounded-lg shadow-md">
|
88 |
+
<h2 class="text-xl font-semibold mb-4 text-gray-800">Controls</h2>
|
89 |
+
|
90 |
+
<div class="mb-6">
|
91 |
+
<h3 class="font-medium mb-2 text-gray-700">Borders</h3>
|
92 |
+
<div class="flex flex-wrap gap-2">
|
93 |
+
<button id="showAllBorders" class="px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600 transition">Show All</button>
|
94 |
+
<button id="hideAllBorders" class="px-3 py-1 bg-red-500 text-white rounded hover:bg-red-600 transition">Hide All</button>
|
95 |
+
<button id="toggleBorders" class="px-3 py-1 bg-gray-500 text-white rounded hover:bg-gray-600 transition">Toggle</button>
|
96 |
+
</div>
|
97 |
+
<div class="mt-3">
|
98 |
+
<label class="flex items-center">
|
99 |
+
<input type="range" id="borderWidth" min="0" max="5" step="0.5" value="0.5" class="w-full">
|
100 |
+
<span class="ml-2 text-sm text-gray-600">Border width: <span id="borderWidthValue">0.5</span>px</span>
|
101 |
+
</label>
|
102 |
+
</div>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<div class="mb-6">
|
106 |
+
<h3 class="font-medium mb-2 text-gray-700">Country Color</h3>
|
107 |
+
<div class="flex items-center gap-3 mb-3">
|
108 |
+
<input type="color" id="countryColor" value="#4CAF50" class="color-picker">
|
109 |
+
<button id="applyColor" class="px-3 py-1 bg-green-500 text-white rounded hover:bg-green-600 transition">Apply</button>
|
110 |
+
<button id="resetColors" class="px-3 py-1 bg-gray-500 text-white rounded hover:bg-gray-600 transition">Reset</button>
|
111 |
+
</div>
|
112 |
+
<div class="flex items-center gap-2">
|
113 |
+
<input type="checkbox" id="randomColors" class="h-4 w-4">
|
114 |
+
<label for="randomColors" class="text-sm text-gray-600">Random colors</label>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
|
118 |
+
<div class="mb-6">
|
119 |
+
<h3 class="font-medium mb-2 text-gray-700">Background</h3>
|
120 |
+
<input type="color" id="bgColor" value="#F3F4F6" class="color-picker">
|
121 |
+
<span class="ml-2 text-sm text-gray-600">Map background</span>
|
122 |
+
</div>
|
123 |
+
|
124 |
+
<div class="mb-6">
|
125 |
+
<h3 class="font-medium mb-2 text-gray-700">Selected Country</h3>
|
126 |
+
<div id="selectedCountryInfo" class="p-3 bg-gray-100 rounded text-sm text-gray-700">
|
127 |
+
Click on a country to select it
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<div>
|
132 |
+
<h3 class="font-medium mb-2 text-gray-700">Save/Load</h3>
|
133 |
+
<div class="flex flex-wrap gap-2">
|
134 |
+
<button id="saveMap" class="px-3 py-1 bg-purple-500 text-white rounded hover:bg-purple-600 transition">Save Map</button>
|
135 |
+
<button id="loadMap" class="px-3 py-1 bg-yellow-500 text-white rounded hover:bg-yellow-600 transition">Load Map</button>
|
136 |
+
<button id="exportPNG" class="px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600 transition">Export PNG</button>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
|
141 |
+
<!-- Map Container -->
|
142 |
+
<div class="w-full lg:w-3/4 relative">
|
143 |
+
<div class="bg-white p-4 rounded-lg shadow-md">
|
144 |
+
<div id="mapContainer" class="relative overflow-hidden border border-gray-300 rounded">
|
145 |
+
<svg id="map" width="100%" height="600"></svg>
|
146 |
+
<div id="tooltip" class="tooltip"></div>
|
147 |
+
<div class="zoom-controls">
|
148 |
+
<button id="zoomIn" class="zoom-btn">+</button>
|
149 |
+
<button id="zoomOut" class="zoom-btn">−</button>
|
150 |
+
<button id="resetZoom" class="zoom-btn">↻</button>
|
151 |
+
</div>
|
152 |
+
</div>
|
153 |
+
</div>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
|
158 |
+
<script>
|
159 |
+
// Initialize variables
|
160 |
+
let selectedCountry = null;
|
161 |
+
let countryColors = {};
|
162 |
+
let showBorders = true;
|
163 |
+
let borderWidth = 0.5;
|
164 |
+
let transform = d3.zoomIdentity;
|
165 |
+
let svg, g, projection, path;
|
166 |
+
|
167 |
+
// Wait for DOM to load
|
168 |
+
document.addEventListener('DOMContentLoaded', function() {
|
169 |
+
// Initialize map
|
170 |
+
initMap();
|
171 |
+
|
172 |
+
// Set up event listeners
|
173 |
+
setupEventListeners();
|
174 |
+
});
|
175 |
+
|
176 |
+
function initMap() {
|
177 |
+
const width = document.getElementById('mapContainer').clientWidth;
|
178 |
+
const height = 600;
|
179 |
+
|
180 |
+
// Create SVG
|
181 |
+
svg = d3.select("#map")
|
182 |
+
.attr("width", width)
|
183 |
+
.attr("height", height)
|
184 |
+
.call(d3.zoom()
|
185 |
+
.scaleExtent([1, 8])
|
186 |
+
.on("zoom", zoomed))
|
187 |
+
.on("click", stopped, true);
|
188 |
+
|
189 |
+
// Create group for all map elements
|
190 |
+
g = svg.append("g");
|
191 |
+
|
192 |
+
// Set up projection
|
193 |
+
projection = d3.geoMercator()
|
194 |
+
.scale(width / 2 / Math.PI)
|
195 |
+
.translate([width / 2, height / 2]);
|
196 |
+
|
197 |
+
// Create path generator
|
198 |
+
path = d3.geoPath().projection(projection);
|
199 |
+
|
200 |
+
// Load and draw world map
|
201 |
+
d3.json("https://unpkg.com/[email protected]/countries-110m.json").then(function(world) {
|
202 |
+
const countries = topojson.feature(world, world.objects.countries).features;
|
203 |
+
|
204 |
+
// Draw countries
|
205 |
+
g.selectAll(".country")
|
206 |
+
.data(countries)
|
207 |
+
.enter()
|
208 |
+
.append("path")
|
209 |
+
.attr("class", "country")
|
210 |
+
.attr("d", path)
|
211 |
+
.attr("id", d => "country-" + d.id)
|
212 |
+
.attr("fill", d => getRandomColor(d.id))
|
213 |
+
.attr("stroke", "#333")
|
214 |
+
.attr("stroke-width", borderWidth)
|
215 |
+
.on("mouseover", function(event, d) {
|
216 |
+
d3.select(this).attr("stroke-width", borderWidth * 2);
|
217 |
+
showTooltip(event, d);
|
218 |
+
})
|
219 |
+
.on("mouseout", function() {
|
220 |
+
if (selectedCountry !== this) {
|
221 |
+
d3.select(this).attr("stroke-width", borderWidth);
|
222 |
+
}
|
223 |
+
hideTooltip();
|
224 |
+
})
|
225 |
+
.on("click", function(event, d) {
|
226 |
+
// Reset previously selected country
|
227 |
+
if (selectedCountry) {
|
228 |
+
d3.select(selectedCountry).attr("stroke-width", borderWidth);
|
229 |
+
}
|
230 |
+
|
231 |
+
// Set new selected country
|
232 |
+
selectedCountry = this;
|
233 |
+
d3.select(this).attr("stroke-width", borderWidth * 3);
|
234 |
+
|
235 |
+
// Update selected country info
|
236 |
+
updateSelectedCountryInfo(d);
|
237 |
+
});
|
238 |
+
|
239 |
+
// Store country data for later use
|
240 |
+
window.countriesData = countries;
|
241 |
+
});
|
242 |
+
}
|
243 |
+
|
244 |
+
function setupEventListeners() {
|
245 |
+
// Border controls
|
246 |
+
document.getElementById('showAllBorders').addEventListener('click', function() {
|
247 |
+
showBorders = true;
|
248 |
+
updateBorders();
|
249 |
+
});
|
250 |
+
|
251 |
+
document.getElementById('hideAllBorders').addEventListener('click', function() {
|
252 |
+
showBorders = false;
|
253 |
+
updateBorders();
|
254 |
+
});
|
255 |
+
|
256 |
+
document.getElementById('toggleBorders').addEventListener('click', function() {
|
257 |
+
showBorders = !showBorders;
|
258 |
+
updateBorders();
|
259 |
+
});
|
260 |
+
|
261 |
+
document.getElementById('borderWidth').addEventListener('input', function() {
|
262 |
+
borderWidth = parseFloat(this.value);
|
263 |
+
document.getElementById('borderWidthValue').textContent = borderWidth;
|
264 |
+
updateBorders();
|
265 |
+
});
|
266 |
+
|
267 |
+
// Color controls
|
268 |
+
document.getElementById('applyColor').addEventListener('click', function() {
|
269 |
+
if (!selectedCountry) {
|
270 |
+
alert("Please select a country first");
|
271 |
+
return;
|
272 |
+
}
|
273 |
+
|
274 |
+
const color = document.getElementById('countryColor').value;
|
275 |
+
const countryId = selectedCountry.id.replace('country-', '');
|
276 |
+
|
277 |
+
// Store color for this country
|
278 |
+
countryColors[countryId] = color;
|
279 |
+
|
280 |
+
// Apply color to selected country
|
281 |
+
d3.select(selectedCountry).attr("fill", color);
|
282 |
+
|
283 |
+
// Update info panel
|
284 |
+
updateSelectedCountryInfo();
|
285 |
+
});
|
286 |
+
|
287 |
+
document.getElementById('resetColors').addEventListener('click', function() {
|
288 |
+
countryColors = {};
|
289 |
+
d3.selectAll(".country").attr("fill", d => getRandomColor(d.id));
|
290 |
+
updateSelectedCountryInfo();
|
291 |
+
});
|
292 |
+
|
293 |
+
document.getElementById('randomColors').addEventListener('change', function() {
|
294 |
+
if (this.checked) {
|
295 |
+
d3.selectAll(".country").attr("fill", d => getRandomColor(d.id));
|
296 |
+
}
|
297 |
+
});
|
298 |
+
|
299 |
+
// Background color
|
300 |
+
document.getElementById('bgColor').addEventListener('input', function() {
|
301 |
+
document.getElementById('mapContainer').style.backgroundColor = this.value;
|
302 |
+
});
|
303 |
+
|
304 |
+
// Zoom controls
|
305 |
+
document.getElementById('zoomIn').addEventListener('click', function() {
|
306 |
+
svg.transition().call(d3.zoom().scaleBy, 2);
|
307 |
+
});
|
308 |
+
|
309 |
+
document.getElementById('zoomOut').addEventListener('click', function() {
|
310 |
+
svg.transition().call(d3.zoom().scaleBy, 0.5);
|
311 |
+
});
|
312 |
+
|
313 |
+
document.getElementById('resetZoom').addEventListener('click', function() {
|
314 |
+
svg.transition().call(d3.zoom().transform, d3.zoomIdentity);
|
315 |
+
});
|
316 |
+
|
317 |
+
// Save/Load
|
318 |
+
document.getElementById('saveMap').addEventListener('click', saveMap);
|
319 |
+
document.getElementById('loadMap').addEventListener('click', loadMap);
|
320 |
+
document.getElementById('exportPNG').addEventListener('click', exportPNG);
|
321 |
+
}
|
322 |
+
|
323 |
+
function updateBorders() {
|
324 |
+
const strokeValue = showBorders ? "#333" : "none";
|
325 |
+
d3.selectAll(".country")
|
326 |
+
.attr("stroke", strokeValue)
|
327 |
+
.attr("stroke-width", showBorders ? borderWidth : 0);
|
328 |
+
|
329 |
+
if (selectedCountry) {
|
330 |
+
d3.select(selectedCountry).attr("stroke-width", showBorders ? borderWidth * 3 : 0);
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
function updateSelectedCountryInfo(d) {
|
335 |
+
const infoPanel = document.getElementById('selectedCountryInfo');
|
336 |
+
|
337 |
+
if (!selectedCountry) {
|
338 |
+
infoPanel.innerHTML = "Click on a country to select it";
|
339 |
+
return;
|
340 |
+
}
|
341 |
+
|
342 |
+
const countryId = selectedCountry.id.replace('country-', '');
|
343 |
+
const countryData = window.countriesData.find(c => c.id == countryId);
|
344 |
+
const countryName = countryData?.properties?.name || "Unknown Country";
|
345 |
+
const currentColor = countryColors[countryId] || d3.select(selectedCountry).attr("fill");
|
346 |
+
|
347 |
+
infoPanel.innerHTML = `
|
348 |
+
<strong>${countryName}</strong><br>
|
349 |
+
<div class="mt-1 flex items-center">
|
350 |
+
<span>Color: </span>
|
351 |
+
<div class="w-4 h-4 ml-2 border border-gray-300" style="background-color: ${currentColor}"></div>
|
352 |
+
<span class="ml-1">${currentColor}</span>
|
353 |
+
</div>
|
354 |
+
<div class="mt-1">ID: ${countryId}</div>
|
355 |
+
`;
|
356 |
+
}
|
357 |
+
|
358 |
+
function showTooltip(event, d) {
|
359 |
+
const tooltip = document.getElementById('tooltip');
|
360 |
+
const countryName = d.properties?.name || "Unknown Country";
|
361 |
+
|
362 |
+
tooltip.style.display = 'block';
|
363 |
+
tooltip.style.left = (event.pageX + 10) + 'px';
|
364 |
+
tooltip.style.top = (event.pageY + 10) + 'px';
|
365 |
+
tooltip.innerHTML = countryName;
|
366 |
+
}
|
367 |
+
|
368 |
+
function hideTooltip() {
|
369 |
+
document.getElementById('tooltip').style.display = 'none';
|
370 |
+
}
|
371 |
+
|
372 |
+
function getRandomColor(id) {
|
373 |
+
// If we have a stored color for this country, use it
|
374 |
+
if (countryColors[id]) {
|
375 |
+
return countryColors[id];
|
376 |
+
}
|
377 |
+
|
378 |
+
// Otherwise generate a random color or use default
|
379 |
+
if (document.getElementById('randomColors')?.checked) {
|
380 |
+
return chroma.random().hex();
|
381 |
+
}
|
382 |
+
return "#DDD";
|
383 |
+
}
|
384 |
+
|
385 |
+
function zoomed(event) {
|
386 |
+
transform = event.transform;
|
387 |
+
g.attr("transform", transform);
|
388 |
+
g.attr("stroke-width", borderWidth / transform.k);
|
389 |
+
}
|
390 |
+
|
391 |
+
function stopped() {
|
392 |
+
if (d3.event.defaultPrevented) return;
|
393 |
+
if (!d3.event.target.closest('.country')) {
|
394 |
+
// Clicked on empty space - deselect country
|
395 |
+
if (selectedCountry) {
|
396 |
+
d3.select(selectedCountry).attr("stroke-width", borderWidth);
|
397 |
+
selectedCountry = null;
|
398 |
+
updateSelectedCountryInfo();
|
399 |
+
}
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
function saveMap() {
|
404 |
+
const mapData = {
|
405 |
+
countryColors: countryColors,
|
406 |
+
showBorders: showBorders,
|
407 |
+
borderWidth: borderWidth,
|
408 |
+
bgColor: document.getElementById('bgColor').value,
|
409 |
+
transform: transform
|
410 |
+
};
|
411 |
+
|
412 |
+
const dataStr = JSON.stringify(mapData);
|
413 |
+
localStorage.setItem('worldMapEditorData', dataStr);
|
414 |
+
|
415 |
+
alert("Map saved successfully!");
|
416 |
+
}
|
417 |
+
|
418 |
+
function loadMap() {
|
419 |
+
const savedData = localStorage.getItem('worldMapEditorData');
|
420 |
+
if (!savedData) {
|
421 |
+
alert("No saved map found");
|
422 |
+
return;
|
423 |
+
}
|
424 |
+
|
425 |
+
try {
|
426 |
+
const mapData = JSON.parse(savedData);
|
427 |
+
|
428 |
+
// Apply saved settings
|
429 |
+
countryColors = mapData.countryColors || {};
|
430 |
+
showBorders = mapData.showBorders !== false;
|
431 |
+
borderWidth = mapData.borderWidth || 0.5;
|
432 |
+
|
433 |
+
document.getElementById('borderWidth').value = borderWidth;
|
434 |
+
document.getElementById('borderWidthValue').textContent = borderWidth;
|
435 |
+
document.getElementById('bgColor').value = mapData.bgColor || "#F3F4F6";
|
436 |
+
document.getElementById('mapContainer').style.backgroundColor = mapData.bgColor || "#F3F4F6";
|
437 |
+
|
438 |
+
// Apply colors to countries
|
439 |
+
d3.selectAll(".country").each(function() {
|
440 |
+
const countryId = this.id.replace('country-', '');
|
441 |
+
if (countryColors[countryId]) {
|
442 |
+
d3.select(this).attr("fill", countryColors[countryId]);
|
443 |
+
}
|
444 |
+
});
|
445 |
+
|
446 |
+
// Apply borders
|
447 |
+
updateBorders();
|
448 |
+
|
449 |
+
// Apply transform if available
|
450 |
+
if (mapData.transform) {
|
451 |
+
transform = mapData.transform;
|
452 |
+
g.attr("transform", transform);
|
453 |
+
g.attr("stroke-width", borderWidth / transform.k);
|
454 |
+
}
|
455 |
+
|
456 |
+
alert("Map loaded successfully!");
|
457 |
+
} catch (e) {
|
458 |
+
console.error("Error loading map:", e);
|
459 |
+
alert("Error loading saved map");
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
function exportPNG() {
|
464 |
+
const svgElement = document.getElementById('map');
|
465 |
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
466 |
+
const canvas = document.createElement('canvas');
|
467 |
+
const ctx = canvas.getContext('2d');
|
468 |
+
|
469 |
+
const img = new Image();
|
470 |
+
img.onload = function() {
|
471 |
+
canvas.width = img.width;
|
472 |
+
canvas.height = img.height;
|
473 |
+
ctx.drawImage(img, 0, 0);
|
474 |
+
|
475 |
+
const pngFile = canvas.toDataURL('image/png');
|
476 |
+
const downloadLink = document.createElement('a');
|
477 |
+
downloadLink.download = 'world-map.png';
|
478 |
+
downloadLink.href = pngFile;
|
479 |
+
downloadLink.click();
|
480 |
+
};
|
481 |
+
|
482 |
+
img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgData)));
|
483 |
+
}
|
484 |
+
</script>
|
485 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Kingrane/draw-your-world" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
486 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
website for making your world map: map with all countries with correct borders. Там чтоб можно было скрыть все границы или некоторые убрать а также покрасить страны в цвета, выбрать совершеннно любой цвет и покрасить любую страну
|