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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa" dir="rtl">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>خلق تصاویر سبک میدجرنی</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 8 |
+
<style>
|
| 9 |
+
:root {
|
| 10 |
+
--app-font: 'Vazirmatn', sans-serif;
|
| 11 |
+
--app-bg: #F8F9FC;
|
| 12 |
+
--panel-bg: #FFFFFF;
|
| 13 |
+
--panel-border: #EAEFF7;
|
| 14 |
+
--input-bg: #F6F8FB;
|
| 15 |
+
--input-border: #E1E7EF;
|
| 16 |
+
--text-primary: #1A202C;
|
| 17 |
+
--text-secondary: #626F86;
|
| 18 |
+
--text-tertiary: #8A94A6;
|
| 19 |
+
--accent-primary: #8B5CF6; /* رنگ بنفش متناسب با میدجرنی */
|
| 20 |
+
--accent-primary-hover: #7C3AED;
|
| 21 |
+
--accent-primary-glow: rgba(139, 92, 246, 0.25);
|
| 22 |
+
--accent-secondary: #EC4899;
|
| 23 |
+
--shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03);
|
| 24 |
+
--shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04);
|
| 25 |
+
--shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05);
|
| 26 |
+
--shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05);
|
| 27 |
+
--radius-card: 24px;
|
| 28 |
+
--radius-btn: 14px;
|
| 29 |
+
--radius-input: 12px;
|
| 30 |
+
--transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
|
| 34 |
+
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
| 35 |
+
@keyframes pulse { 0% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.3); } 50% { box-shadow: 0 0 60px rgba(139, 92, 246, 0.7); } 100% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.3); } }
|
| 36 |
+
@keyframes glow-text { 0% { opacity: 0.7; } 50% { opacity: 1; } 100% { opacity: 0.7; } }
|
| 37 |
+
|
| 38 |
+
body { font-family: var(--app-font); background-color: var(--app-bg); color: var(--text-primary); margin: 0; padding: 2.5rem 1rem; display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; }
|
| 39 |
+
.container { max-width: 820px; width: 100%; }
|
| 40 |
+
|
| 41 |
+
header { position: relative; text-align: center; margin-bottom: 2.5rem; padding: 2rem 0; animation: fadeIn 0.8s 0.1s ease-out backwards; overflow: hidden; }
|
| 42 |
+
#neural-network-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
|
| 43 |
+
h1, .subtitle { position: relative; z-index: 2; }
|
| 44 |
+
h1 { font-size: 2.8rem; font-weight: 800; margin: 0 0 0.8rem 0; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; }
|
| 45 |
+
.subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0; max-width: 650px; margin-left: auto; margin-right: auto; line-height: 1.8; }
|
| 46 |
+
|
| 47 |
+
main { padding: 3rem; background-color: var(--panel-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-xl); border: 1px solid var(--panel-border); animation: fadeIn 0.8s 0.3s ease-out backwards; }
|
| 48 |
+
|
| 49 |
+
.form-group { margin-bottom: 2.5rem; }
|
| 50 |
+
.form-group:last-child { margin-bottom: 0; }
|
| 51 |
+
|
| 52 |
+
.form-label { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; color: var(--text-primary); font-size: 1.2em; margin-bottom: 1.2rem; }
|
| 53 |
+
.form-label svg { width: 24px; height: 24px; color: var(--accent-primary); }
|
| 54 |
+
|
| 55 |
+
textarea { width: 100%; padding: 1rem 1.2rem; border-radius: var(--radius-input); border: 1px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; transition: var(--transition-smooth); min-height: 90px; resize: vertical; }
|
| 56 |
+
textarea:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-sm) inset; background-color: var(--panel-bg); }
|
| 57 |
+
|
| 58 |
+
.aspect-ratio-selector { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
|
| 59 |
+
.ratio-option { background-color: var(--input-bg); border: 2px solid var(--input-border); border-radius: var(--radius-input); padding: 1rem; cursor: pointer; transition: var(--transition-smooth); text-align: center; }
|
| 60 |
+
.ratio-option:hover { border-color: var(--accent-primary); transform: translateY(-4px); box-shadow: var(--shadow-md); }
|
| 61 |
+
.ratio-option.active { border-color: var(--accent-primary); background-color: #fff; box-shadow: 0 0 0 3px var(--accent-primary-glow); }
|
| 62 |
+
.ratio-icon { height: 50px; display: flex; align-items: center; justify-content: center; margin: 0 auto 0.75rem; }
|
| 63 |
+
.ratio-icon > div, .ratio-icon > svg { background-color: var(--panel-bg); border: 2px solid var(--text-tertiary); border-radius: 6px; transition: var(--transition-smooth); box-sizing: border-box; }
|
| 64 |
+
.ratio-option.active .ratio-icon > div, .ratio-option.active .ratio-icon > svg { border-color: var(--accent-primary); background-color: var(--accent-primary-glow); }
|
| 65 |
+
.ratio-label { font-weight: 600; color: var(--text-secondary); font-size: 0.9rem; transition: color 0.2s; }
|
| 66 |
+
.ratio-option.active .ratio-label { color: var(--text-primary); }
|
| 67 |
+
|
| 68 |
+
#icon-portrait > div { width: 28px; height: 50px; }
|
| 69 |
+
#icon-landscape > div { width: 60px; height: 34px; }
|
| 70 |
+
#icon-square > div { width: 45px; height: 45px; }
|
| 71 |
+
#icon-custom > svg { width: 45px; height: 45px; padding: 8px; color: var(--text-tertiary); }
|
| 72 |
+
.ratio-option.active #icon-custom > svg { color: var(--accent-primary); }
|
| 73 |
+
.custom-ratio-value { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; height: 1em; }
|
| 74 |
+
|
| 75 |
+
#submit-btn { display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 1.1rem; font-size: 1.2rem; font-weight: 700; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease; box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px rgba(236, 72, 153, 0.3); margin-top: 1.5rem; }
|
| 76 |
+
#submit-btn svg { width: 24px; height: 24px; margin-left: 4px; filter: drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
|
| 77 |
+
#submit-btn:hover:not(:disabled) { transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px rgba(236, 72, 153, 0.4); }
|
| 78 |
+
#submit-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; opacity: 0.7; transform: none; }
|
| 79 |
+
#submit-btn .spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: none; }
|
| 80 |
+
|
| 81 |
+
#result-container { min-height: 250px; position: relative; padding: 1rem; background-color: var(--input-bg); border-radius: var(--radius-card); border: 2px dashed var(--input-border); box-shadow: var(--shadow-sm) inset; transition: var(--transition-smooth); display: flex; align-items: center; justify-content: center; flex-direction: column; box-sizing: border-box; }
|
| 82 |
+
#result-container.loading { padding: 0; border: none; background-color: transparent; box-shadow: none; }
|
| 83 |
+
#result-container.has-content { border-style: solid; border-color: var(--panel-border); padding: 1rem; }
|
| 84 |
+
|
| 85 |
+
.generator-container { position: relative; width: 100%; max-width: 500px; height: 200px; border: 2px solid #a78bfa; border-radius: 20px; overflow: hidden; box-shadow: 0 0 40px rgba(139, 92, 246, 0.3); animation: pulse 5s infinite cubic-bezier(0.4, 0, 0.6, 1); background-color: #161b22; color: #f0f6fc; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 1rem; }
|
| 86 |
+
.text-overlay { font-size: 18px; font-weight: 700; text-shadow: 0 0 20px rgba(139, 92, 246, 0.8); animation: glow-text 7s infinite ease-in-out; text-align: center; }
|
| 87 |
+
.progress-bar { position: absolute; bottom: 0; left: 0; width: 0%; height: 6px; background: linear-gradient(to right, #8B5CF6, #EC4899, #F59E0B); transition: width 1s linear; }
|
| 88 |
+
|
| 89 |
+
#result-image-wrapper { display: none; width: 100%; text-align: center; }
|
| 90 |
+
#result-container.has-content #result-image-wrapper { display: block; animation: fadeIn 0.5s; }
|
| 91 |
+
#result-image-display { max-width: 100%; max-height: 500px; object-fit: contain; border-radius: var(--radius-input); box-shadow: var(--shadow-md); border: 1px solid var(--panel-border); }
|
| 92 |
+
|
| 93 |
+
.download-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; max-width: 280px; margin: 1.5rem auto 0; padding: 0.9rem; font-size: 1rem; font-weight: 600; background: var(--accent-primary); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease; box-shadow: var(--shadow-md); text-decoration: none;}
|
| 94 |
+
.download-button svg { width: 20px; height: 20px; }
|
| 95 |
+
.download-button:hover { background: var(--accent-primary-hover); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
|
| 96 |
+
|
| 97 |
+
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(18, 24, 38, 0.6); backdrop-filter: blur(8px); display: none; justify-content: center; align-items: center; z-index: 1000; animation: fadeIn 0.3s; }
|
| 98 |
+
.modal-content-small { background: var(--panel-bg); padding: 2rem; border-radius: var(--radius-card); max-width: 350px; width: 90%; text-align: center; box-shadow: var(--shadow-xl); position: relative; }
|
| 99 |
+
.modal-content-small h3 { margin-top: 0; margin-bottom: 1.5rem; font-size: 1.5rem; color: var(--text-primary); }
|
| 100 |
+
.modal-content-small .input-group { margin-bottom: 1rem; text-align: right; }
|
| 101 |
+
.modal-content-small label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: var(--text-secondary); font-size: 0.9rem; }
|
| 102 |
+
.modal-content-small input { width: 100%; padding: 0.8rem 1rem; border-radius: var(--radius-input); border: 1px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; transition: var(--transition-smooth); }
|
| 103 |
+
.modal-content-small input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-sm) inset; background-color: var(--panel-bg); }
|
| 104 |
+
#confirm-custom-size-btn { width: 100%; padding: 0.9rem; margin-top: 1rem; font-size: 1rem; font-weight: 700; background-color: var(--accent-primary); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: var(--transition-smooth); }
|
| 105 |
+
#confirm-custom-size-btn:hover { background-color: var(--accent-primary-hover); }
|
| 106 |
+
#close-custom-modal-btn { position: absolute; top: 10px; left: 10px; background: transparent; border: none; font-size: 2rem; cursor: pointer; color: var(--text-tertiary); line-height: 1; padding: 0.5rem; }
|
| 107 |
+
|
| 108 |
+
@media (max-width: 768px) { main { padding: 1.5rem; } h1 { font-size: 2.2rem; } .aspect-ratio-selector { grid-template-columns: repeat(2, 1fr); } }
|
| 109 |
+
</style>
|
| 110 |
+
</head>
|
| 111 |
+
<body>
|
| 112 |
+
<div class="container">
|
| 113 |
+
<header>
|
| 114 |
+
<canvas id="neural-network-canvas"></canvas>
|
| 115 |
+
<h1>خلق تصاویر سبک میدجرنی</h1>
|
| 116 |
+
<p class="subtitle">ایدههای خود را با سبک واقعگرایانه و هنری Midjourney v6 به تصویر بکشید</p>
|
| 117 |
+
</header>
|
| 118 |
+
<main>
|
| 119 |
+
<div class="form-group">
|
| 120 |
+
<div class="form-label">
|
| 121 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
|
| 122 |
+
۱. ایده خود را توصیف کنید
|
| 123 |
+
</div>
|
| 124 |
+
<textarea id="prompt-input" rows="3" placeholder="مثال: پرتره یک پیرمرد با نورپردازی سینمایی، کیفیت بسیار بالا"></textarea>
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
<div class="form-group">
|
| 128 |
+
<div class="form-label">
|
| 129 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 9V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4"/><rect x="12" y="13" width="10" height="8" rx="2"/><path d="M17 12v-1a2 2 0 0 0-2-2h-1"/></svg>
|
| 130 |
+
۲. اندازه تصویر را انتخاب کنید
|
| 131 |
+
</div>
|
| 132 |
+
<div class="aspect-ratio-selector" id="aspect-ratio-selector">
|
| 133 |
+
<div class="ratio-option" data-ratio="9:16">
|
| 134 |
+
<div class="ratio-icon" id="icon-portrait"><div></div></div>
|
| 135 |
+
<div class="ratio-label">عمودی ۹:۱۶</div>
|
| 136 |
+
</div>
|
| 137 |
+
<div class="ratio-option" data-ratio="16:9">
|
| 138 |
+
<div class="ratio-icon" id="icon-landscape"><div></div></div>
|
| 139 |
+
<div class="ratio-label">افقی ۱۶:۹</div>
|
| 140 |
+
</div>
|
| 141 |
+
<div class="ratio-option" data-ratio="custom">
|
| 142 |
+
<div class="ratio-icon" id="icon-custom">
|
| 143 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 144 |
+
<path d="M21 16V8a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h8"/>
|
| 145 |
+
<circle cx="18" cy="18" r="3"/>
|
| 146 |
+
<path d="M18 15v-2"/><path d="M18 21v-2"/>
|
| 147 |
+
<path d="M15 18h-2"/><path d="M21 18h-2"/>
|
| 148 |
+
</svg>
|
| 149 |
+
</div>
|
| 150 |
+
<div class="ratio-label">
|
| 151 |
+
اندازه دلخواه
|
| 152 |
+
<div class="custom-ratio-value" id="custom-ratio-label-value"></div>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
<div class="ratio-option active" data-ratio="1:1">
|
| 156 |
+
<div class="ratio-icon" id="icon-square"><div></div></div>
|
| 157 |
+
<div class="ratio-label">مربع ۱:۱</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
+
<button id="submit-btn">
|
| 163 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/></svg>
|
| 164 |
+
<span id="btn-text">خلق کن!</span>
|
| 165 |
+
<div class="spinner" style="display: none;"></div>
|
| 166 |
+
</button>
|
| 167 |
+
|
| 168 |
+
<div class="form-group" style="margin-top: 3rem; margin-bottom: 0;">
|
| 169 |
+
<div class="form-label">
|
| 170 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/><path d="M21 14l-1.5 3-3-1.5 3-3 1.5 3z"/><path d="M19.5 2.5l-3 1.5 1.5 3 3-1.5-1.5-3z"/></svg>
|
| 171 |
+
۳. نتیجه را ببینید
|
| 172 |
+
</div>
|
| 173 |
+
<div id="result-container">
|
| 174 |
+
<p id="idle-text">برای شروع، ایده خود را نوشته و دکمه را بزنید.</p>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</main>
|
| 178 |
+
</div>
|
| 179 |
+
|
| 180 |
+
<!-- Modal for Custom Size -->
|
| 181 |
+
<div class="modal-overlay" id="custom-size-modal">
|
| 182 |
+
<div class="modal-content-small">
|
| 183 |
+
<button id="close-custom-modal-btn">×</button>
|
| 184 |
+
<h3>تنظیم اندازه دلخواه</h3>
|
| 185 |
+
<div class="input-group">
|
| 186 |
+
<label>عرض (Width)</label>
|
| 187 |
+
<input type="number" id="custom-width-input" value="1024" min="512" max="1536" step="8">
|
| 188 |
+
</div>
|
| 189 |
+
<div class="input-group">
|
| 190 |
+
<label>طول (Height)</label>
|
| 191 |
+
<input type="number" id="custom-height-input" value="1024" min="512" max="1536" step="8">
|
| 192 |
+
</div>
|
| 193 |
+
<button id="confirm-custom-size-btn">تایید و اعمال</button>
|
| 194 |
+
</div>
|
| 195 |
+
</div>
|
| 196 |
+
|
| 197 |
+
<script>
|
| 198 |
+
const promptInput = document.getElementById('prompt-input');
|
| 199 |
+
const submitBtn = document.getElementById('submit-btn');
|
| 200 |
+
const resultContainer = document.getElementById('result-container');
|
| 201 |
+
const ratioSelector = document.getElementById('aspect-ratio-selector');
|
| 202 |
+
const customSizeModal = document.getElementById('custom-size-modal');
|
| 203 |
+
|
| 204 |
+
let selectedRatio = '1:1';
|
| 205 |
+
let customWidth = 1024;
|
| 206 |
+
let customHeight = 1024;
|
| 207 |
+
let pollTimer = null;
|
| 208 |
+
|
| 209 |
+
const getDimensions = (ratio) => {
|
| 210 |
+
if (ratio === 'custom') return { width: customWidth, height: customHeight };
|
| 211 |
+
switch (ratio) {
|
| 212 |
+
case '9:16': return { width: 768, height: 1344 };
|
| 213 |
+
case '16:9': return { width: 1344, height: 768 };
|
| 214 |
+
case '1:1': return { width: 1024, height: 1024 };
|
| 215 |
+
default: return { width: 1024, height: 1024 };
|
| 216 |
+
}
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
const setLoadingState = (isLoading, message) => {
|
| 220 |
+
const spinner = submitBtn.querySelector('.spinner');
|
| 221 |
+
const icon = submitBtn.querySelector('svg');
|
| 222 |
+
const btnText = document.getElementById('btn-text');
|
| 223 |
+
|
| 224 |
+
if (isLoading) {
|
| 225 |
+
submitBtn.disabled = true;
|
| 226 |
+
icon.style.display = 'none';
|
| 227 |
+
spinner.style.display = 'inline-block';
|
| 228 |
+
btnText.textContent = message;
|
| 229 |
+
|
| 230 |
+
resultContainer.className = 'loading';
|
| 231 |
+
resultContainer.innerHTML = `
|
| 232 |
+
<div class="generator-container">
|
| 233 |
+
<div class="text-overlay" id="loading-status-text">${message}</div>
|
| 234 |
+
<div class="progress-bar" style="width: 50%;"></div>
|
| 235 |
+
</div>`;
|
| 236 |
+
} else {
|
| 237 |
+
submitBtn.disabled = false;
|
| 238 |
+
icon.style.display = 'inline-block';
|
| 239 |
+
spinner.style.display = 'none';
|
| 240 |
+
btnText.textContent = 'خلق کن!';
|
| 241 |
+
}
|
| 242 |
+
};
|
| 243 |
+
|
| 244 |
+
submitBtn.addEventListener('click', async () => {
|
| 245 |
+
const userPrompt = promptInput.value.trim();
|
| 246 |
+
if (!userPrompt) return alert('لطفاً ایده خود را بنویسید.');
|
| 247 |
+
|
| 248 |
+
setLoadingState(true, 'در حال ارتباط با سرور و ترجمه...');
|
| 249 |
+
const dims = getDimensions(selectedRatio);
|
| 250 |
+
|
| 251 |
+
try {
|
| 252 |
+
// ارسال درخواست به بکاند داکر
|
| 253 |
+
const res = await fetch('/api/generate', {
|
| 254 |
+
method: 'POST',
|
| 255 |
+
headers: {'Content-Type': 'application/json'},
|
| 256 |
+
body: JSON.stringify({
|
| 257 |
+
prompt: userPrompt,
|
| 258 |
+
width: dims.width,
|
| 259 |
+
height: dims.height,
|
| 260 |
+
action_name: "generate-midjourney" // وصل شدن به اکشن میدجرنی
|
| 261 |
+
})
|
| 262 |
+
});
|
| 263 |
+
|
| 264 |
+
const data = await res.json();
|
| 265 |
+
|
| 266 |
+
if (data.status === 'success') {
|
| 267 |
+
document.getElementById('loading-status-text').textContent = 'در حال ساخت تصویر ب�� مدل میدجرنی... (حدود ۴۵ ثانیه زمان میبرد)';
|
| 268 |
+
pollTimer = setInterval(() => checkResult(data.run_id), 3000);
|
| 269 |
+
} else {
|
| 270 |
+
alert('خطا در ارسال به گیتهاب!');
|
| 271 |
+
setLoadingState(false);
|
| 272 |
+
}
|
| 273 |
+
} catch (e) {
|
| 274 |
+
alert('خطای اتصال به سرور داکر!');
|
| 275 |
+
setLoadingState(false);
|
| 276 |
+
}
|
| 277 |
+
});
|
| 278 |
+
|
| 279 |
+
async function checkResult(run_id) {
|
| 280 |
+
try {
|
| 281 |
+
const res = await fetch(`/api/status/${run_id}`);
|
| 282 |
+
const data = await res.json();
|
| 283 |
+
|
| 284 |
+
if (data.status === 'ready') {
|
| 285 |
+
clearInterval(pollTimer);
|
| 286 |
+
setLoadingState(false);
|
| 287 |
+
|
| 288 |
+
resultContainer.className = 'has-content';
|
| 289 |
+
resultContainer.innerHTML = `
|
| 290 |
+
<div id="result-image-wrapper" style="display: block;">
|
| 291 |
+
<img id="result-image-display" src="${data.url}" alt="تصویر میدجرنی">
|
| 292 |
+
<div>
|
| 293 |
+
<a href="${data.url}" download="midjourney_image.webp" class="download-button">
|
| 294 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 295 |
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
|
| 296 |
+
<polyline points="7 10 12 15 17 10"></polyline>
|
| 297 |
+
<line x1="12" y1="15" x2="12" y2="3"></line>
|
| 298 |
+
</svg>
|
| 299 |
+
<span>دانلود تصویر</span>
|
| 300 |
+
</a>
|
| 301 |
+
</div>
|
| 302 |
+
</div>`;
|
| 303 |
+
}
|
| 304 |
+
} catch(e) {
|
| 305 |
+
console.log('در حال پیگیری...', e);
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// --- مدیریت انتخاب سایز ---
|
| 310 |
+
ratioSelector.addEventListener('click', (event) => {
|
| 311 |
+
const selectedOption = event.target.closest('.ratio-option');
|
| 312 |
+
if (!selectedOption) return;
|
| 313 |
+
const ratioValue = selectedOption.dataset.ratio;
|
| 314 |
+
|
| 315 |
+
if (ratioValue === 'custom') {
|
| 316 |
+
customSizeModal.style.display = 'flex';
|
| 317 |
+
} else {
|
| 318 |
+
ratioSelector.querySelectorAll('.ratio-option').forEach(opt => opt.classList.remove('active'));
|
| 319 |
+
selectedOption.classList.add('active');
|
| 320 |
+
selectedRatio = ratioValue;
|
| 321 |
+
}
|
| 322 |
+
});
|
| 323 |
+
|
| 324 |
+
document.getElementById('close-custom-modal-btn').addEventListener('click', () => { customSizeModal.style.display = 'none'; });
|
| 325 |
+
document.getElementById('confirm-custom-size-btn').addEventListener('click', () => {
|
| 326 |
+
customWidth = parseInt(document.getElementById('custom-width-input').value, 10);
|
| 327 |
+
customHeight = parseInt(document.getElementById('custom-height-input').value, 10);
|
| 328 |
+
|
| 329 |
+
selectedRatio = 'custom';
|
| 330 |
+
ratioSelector.querySelectorAll('.ratio-option').forEach(opt => opt.classList.remove('active'));
|
| 331 |
+
document.querySelector('.ratio-option[data-ratio="custom"]').classList.add('active');
|
| 332 |
+
document.getElementById('custom-ratio-label-value').textContent = `(${customWidth}x${customHeight})`;
|
| 333 |
+
customSizeModal.style.display = 'none';
|
| 334 |
+
});
|
| 335 |
+
|
| 336 |
+
// انیمیشن شبکه عصبی هدر
|
| 337 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 338 |
+
const canvas = document.getElementById('neural-network-canvas');
|
| 339 |
+
if(!canvas) return; const header = canvas.parentElement; const ctx = canvas.getContext('2d');
|
| 340 |
+
let particles = []; const particleCount = 20; const maxDistance = 100;
|
| 341 |
+
const particleColor = '#8B5CF6'; const lineColor = '#8A94A6';
|
| 342 |
+
function resizeCanvas() { canvas.width = header.clientWidth; canvas.height = header.clientHeight; init(); }
|
| 343 |
+
class Particle { constructor() { this.x = Math.random() * canvas.width; this.y = Math.random() * canvas.height; this.vx = (Math.random() - 0.5) * 0.3; this.vy = (Math.random() - 0.5) * 0.3; this.radius = 1.2; } update() { this.x += this.vx; this.y += this.vy; if (this.x < 0 || this.x > canvas.width) this.vx *= -1; if (this.y < 0 || this.y > canvas.height) this.vy *= -1; } draw() { ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fillStyle = particleColor; ctx.fill(); } }
|
| 344 |
+
function init() { particles = []; for (let i = 0; i < particleCount; i++) { particles.push(new Particle()); } }
|
| 345 |
+
function connectParticles() { for (let i = 0; i < particles.length; i++) { for (let j = i + 1; j < particles.length; j++) { const dx = particles[i].x - particles[j].x; const dy = particles[i].y - particles[j].y; const distance = Math.sqrt(dx * dx + dy * dy); if (distance < maxDistance) { ctx.beginPath(); ctx.moveTo(particles[i].x, particles[i].y); ctx.lineTo(particles[j].x, particles[j].y); ctx.strokeStyle = lineColor; ctx.lineWidth = 0.2; ctx.globalAlpha = 1 - distance / maxDistance; ctx.stroke(); } } } ctx.globalAlpha = 1; }
|
| 346 |
+
function animate() { if(!ctx) return; ctx.clearRect(0, 0, canvas.width, canvas.height); particles.forEach(particle => { particle.update(); particle.draw(); }); connectParticles(); requestAnimationFrame(animate); }
|
| 347 |
+
window.addEventListener('resize', resizeCanvas); resizeCanvas(); animate();
|
| 348 |
+
});
|
| 349 |
+
</script>
|
| 350 |
+
</body>
|
| 351 |
+
</html>
|