<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>اسپرت سوار ۲ مود شده</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Tahoma, sans-serif;
background: #080808;
color: white;
}
header {
background: #111;
padding: 25px 10px;
text-align: center;
border-bottom: 3px solid #ff3030;
}
header h1 {
color: #ff3030;
margin-bottom: 10px;
}
nav {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 10px;
padding: 15px;
background: #181818;
}
nav a {
color: white;
text-decoration: none;
background: #292929;
padding: 12px 17px;
border-radius: 9px;
}
nav a:hover {
background: #e52222;
}
.hero {
text-align: center;
padding: 65px 15px;
background: linear-gradient(135deg, #151515, #4b0808);
}
.hero h2 {
color: #ff3939;
font-size: 28px;
margin-bottom: 15px;
}
.hero p {
line-height: 2;
color: #ddd;
}
.btn {
display: inline-block;
background: #ed2525;
color: white;
border: none;
padding: 13px 20px;
border-radius: 9px;
text-decoration: none;
cursor: pointer;
margin: 8px 3px;
font-size: 14px;
}
.btn:hover {
background: #bd1010;
}
section {
max-width: 950px;
padding: 35px 15px;
margin: auto;
}
section h2 {
text-align: center;
color: #ff3535;
margin-bottom: 22px;
}
.card {
background: #171717;
padding: 22px;
border-radius: 14px;
text-align: center;
border: 1px solid #333;
margin-bottom: 20px;
}
.card p {
color: #ccc;
line-height: 2;
}
.editor {
background: #151515;
border: 1px solid #333;
border-radius: 15px;
padding: 15px;
}
label {
display: block;
margin: 14px 0 8px;
color: #eee;
}
input[type="text"] {
width: 100%;
padding: 13px;
border: 1px solid #444;
background: #080808;
color: white;
border-radius: 8px;
outline: none;
}
input[type="color"] {
width: 100%;
height: 45px;
border: none;
background: transparent;
cursor: pointer;
}
input[type="range"] {
width: 100%;
accent-color: #ff3030;
}
input[type="file"] {
width: 100%;
padding: 12px;
background: #252525;
border-radius: 8px;
color: white;
}
.color-preview {
display: flex;
align-items: center;
gap: 10px;
background: #242424;
padding: 10px;
border-radius: 8px;
}
.color-preview span {
width: 28px;
height: 28px;
border-radius: 50%;
border: 2px solid white;
}
.canvas-area {
background: #000;
padding: 12px;
border-radius: 12px;
margin-top: 20px;
}
.canvas-title {
text-align: center;
color: #aaa;
font-size: 13px;
margin-bottom: 10px;
}
canvas {
width: 100%;
display: block;
border: 2px solid #555;
border-radius: 5px;
background-color: #fff;
background-image:
linear-gradient(45deg, #333 25%, transparent 25%),
linear-gradient(-45deg, #333 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #333 75%),
linear-gradient(-45deg, transparent 75%, #333 75%);
background-size: 32px 32px;
background-position:
0 0,
0 16px,
16px -16px,
-16px 0;
touch-action: none;
}
.tools {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-top: 15px;
}
.tools button {
padding: 13px 5px;
border: none;
border-radius: 8px;
color: white;
background: #292929;
cursor: pointer;
}
.tools button:hover {
background: #e52222;
}
.download {
width: 100%;
padding: 16px;
margin-top: 15px;
background: #159b48;
color: white;
border: none;
border-radius: 10px;
font-size: 16px;
cursor: pointer;
}
.download:hover {
background: #087c34;
}
#toast {
position: fixed;
bottom: 25px;
left: 50%;
transform: translateX(-50%);
background: #159b48;
color: white;
padding: 15px 22px;
border-radius: 10px;
display: none;
z-index: 999;
text-align: center;
width: max-content;
max-width: 90%;
}
footer {
background: #151515;
text-align: center;
padding: 25px;
color: #aaa;
line-height: 2;
}
footer a {
color: #ff3939;
text-decoration: none;
}
@media (max-width: 500px) {
.hero h2 {
font-size: 22px;
}
}
</style>
</head>
<body>
<header>
<h1>🏎️ اسپرت سوار ۲ مود شده</h1>
<p>دنیای ماشین های اسپرت</p>
</header>
<nav>
<a href="#home">صفحه اصلی</a>
<a href="#sticker">ساخت برچسب</a>
<a href="#support">پشتیبانی</a>
</nav>
<div class="hero" id="home">
<h2>به دنیای اسپرت خوش آمدی!</h2>
<p>برچسب اختصاصی خودت رو بساز و طرح های جذاب درست کن.</p>
<a class="btn" href="https://rubika.ir/Sport1407" target="_blank"> ورود به کانال روبیکا </a>
<a class="btn" href="#sticker">ساخت برچسب</a>
</div>
<section>
<div class="card">
<h2>🔥 درباره سایت</h2>
<p>
این سایت مخصوص طرفداران بازی اسپرت سوار ۲ است. می توانی عکس و نوشته دلخواهت را به برچسب
تبدیل کنی.
</p>
</div>
</section>
<section id="sticker">
<h2>🎨 ساخت برچسب اختصاصی</h2>
<div class="editor">
<label>✏️ متن دلخواه خودت را بنویس:</label>
<input type="text" id="textInput" placeholder="متن برچسب را اینجا بنویس..." />
<label>رنگ نوشته:</label>
<div class="color-preview">
<input type="color" id="textColor" value="#ff0000" />
<span id="colorSample"></span>
</div>
<label>اندازه نوشته:</label>
<input type="range" id="fontSize" min="15" max="100" value="45" />
<button class="btn" onclick="addText()">➕ افزودن متن به برچسب</button>
<label>🖼️ عکس دلخواهت را انتخاب کن:</label>
<input type="file" id="imageInput" accept="image/*" />
<div class="canvas-area">
<div class="canvas-title">محدوده طراحی برچسب</div>
<canvas id="canvas" width="600" height="350"></canvas>
</div>
<div class="tools">
<button onclick="moveFront()">⬆️ آوردن به جلو</button>
<button onclick="deleteSelected()">🗑 حذف طرح انتخابی</button>
<button onclick="rotateItem()">🔄 چرخش طرح</button>
<button onclick="clearCanvas()">پاک کردن همه</button>
</div>
<button class="download" onclick="downloadSticker()">⬇️ دانلود برچسب</button>
<p style="text-align: center; color: #aaa; margin-top: 15px; font-size: 12px">
برای جابه جایی عکس یا نوشته، آن را با انگشت بکش.
</p>
</div>
</section>
<section id="support">
<div class="card">
<h2>📞 پشتیبانی</h2>
<p>برای ارتباط با پشتیبانی سایت روی دکمه زیر بزن.</p>
<a class="btn" href="https://rubika.ir/BENIRAN___6" target="_blank"> ارتباط با پشتیبانی </a>
</div>
</section>
<footer>
ساخته شده برای طرفداران اسپرت سوار ۲ 🏎️
<br />
کانال روبیکا:
<a href="https://rubika.ir/Sport1407">@Sport1407</a>
</footer>
<div id="toast">برچسب به گالری اضافه شد ✅</div>
<script>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let items = [];
let selected = -1;
let dragging = false;
let offsetX = 0;
let offsetY = 0;
const textInput = document.getElementById("textInput");
const textColor = document.getElementById("textColor");
const fontSize = document.getElementById("fontSize");
const colorSample = document.getElementById("colorSample");
function updateColor() {
colorSample.style.background = textColor.value;
if (selected >= 0 && items[selected] && items[selected].type === "text") {
items[selected].color = textColor.value;
draw();
}
}
textColor.addEventListener("input", updateColor);
function addText() {
const text = textInput.value.trim();
if (!text) {
alert("لطفاً اول متن خودت را بنویس!");
textInput.focus();
return;
}
items.push({
type: "text",
text: text,
x: 300,
y: 175,
size: Number(fontSize.value),
color: textColor.value,
angle: 0,
});
selected = items.length - 1;
draw();
}
document.getElementById("imageInput").addEventListener("change", function (event) {
const file = event.target.files[0];
if (!file) return;
if (!file.type.startsWith("image/")) {
alert("لطفاً یک عکس انتخاب کن.");
return;
}
const reader = new FileReader();
reader.onload = function (e) {
const img = new Image();
img.onload = function () {
items.push({
type: "image",
img: img,
x: 300,
y: 175,
width: 180,
height: 140,
angle: 0,
});
selected = items.length - 1;
draw();
};
img.src = e.target.result;
};
reader.readAsDataURL(file);
event.target.value = "";
});
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
items.forEach((item, index) => {
ctx.save();
ctx.translate(item.x, item.y);
ctx.rotate(((item.angle || 0) * Math.PI) / 180);
if (item.type === "text") {
ctx.font = "bold " + item.size + "px Tahoma";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.lineWidth = 5;
ctx.strokeStyle = "#000";
ctx.strokeText(item.text, 0, 0);
ctx.fillStyle = item.color;
ctx.fillText(item.text, 0, 0);
} else if (item.type === "image") {
const ratio = Math.min(item.width / item.img.width, item.height / item.img.height);
const w = item.img.width * ratio;
const h = item.img.height * ratio;
ctx.drawImage(item.img, -w / 2, -h / 2, w, h);
}
if (index === selected) {
ctx.setLineDash([6, 4]);
ctx.strokeStyle = "#00d9ff";
ctx.lineWidth = 2;
const w = item.type === "image" ? item.width : item.size * 2;
const h = item.type === "image" ? item.height : item.size * 1.5;
ctx.strokeRect(-w / 2 - 8, -h / 2 - 8, w + 16, h + 16);
}
ctx.restore();
});
}
function hitTest(item, x, y) {
const w = item.type === "image" ? item.width : item.size * 2;
const h = item.type === "image" ? item.height : item.size * 1.5;
return Math.abs(x - item.x) < w / 2 + 10 && Math.abs(y - item.y) < h / 2 + 10;
}
function getPosition(e) {
const rect = canvas.getBoundingClientRect();
return {
x: ((e.clientX - rect.left) * canvas.width) / rect.width,
y: ((e.clientY - rect.top) * canvas.height) / rect.height,
};
}
canvas.addEventListener("pointerdown", function (e) {
const pos = getPosition(e);
selected = -1;
for (let i = items.length - 1; i >= 0; i--) {
if (hitTest(items[i], pos.x, pos.y)) {
selected = i;
dragging = true;
offsetX = pos.x - items[i].x;
offsetY = pos.y - items[i].y;
break;
}
}
canvas.setPointerCapture(e.pointerId);
draw();
});
canvas.addEventListener("pointermove", function (e) {
if (!dragging || selected < 0) return;
const pos = getPosition(e);
items[selected].x = pos.x - offsetX;
items[selected].y = pos.y - offsetY;
draw();
});
function stopDragging() {
dragging = false;
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
function deleteSelected() {
if (selected < 0) {
alert("اول یک طرح را انتخاب کن.");
return;
}
items.splice(selected, 1);
selected = -1;
draw();
}
function rotateItem() {
if (selected < 0) {
alert("اول یک طرح را انتخاب کن.");
return;
}
items[selected].angle = (items[selected].angle || 0) + 15;
draw();
}
function moveFront() {
if (selected < 0) return;
const item = items.splice(selected, 1)[0];
items.push(item);
selected = items.length - 1;
draw();
}
function clearCanvas() {
if (items.length === 0) return;
if (confirm("همه طرح ها پاک شوند؟")) {
items = [];
selected = -1;
draw();
}
}
// نسخه اصلاح شده دانلود برچسب
function downloadSticker() {
if (items.length === 0) {
alert("اول یک عکس یا متن به برچسب اضافه کن!");
return;
}
const oldSelected = selected;
selected = -1;
draw();
try {
canvas.toBlob(function (blob) {
selected = oldSelected;
draw();
if (!blob) {
alert("ساخت فایل برچسب ناموفق بود!");
return;
}
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "Sport-Sticker.png";
document.body.appendChild(link);
link.click();
link.remove();
showToast();
setTimeout(function () {
URL.revokeObjectURL(url);
}, 10000);
}, "image/png");
} catch (error) {
selected = oldSelected;
draw();
alert("دانلود انجام نشد. دوباره امتحان کن.");
}
}
function showToast() {
const toast = document.getElementById("toast");
toast.style.display = "block";
setTimeout(function () {
toast.style.display = "none";
}, 3000);
}
updateColor();
draw();
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>اسپرت سوار ۲ مود شده</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Tahoma, sans-serif;
background: #080808;
color: white;
}
header {
background: #111;
padding: 25px 10px;
text-align: center;
border-bottom: 3px solid #ff3030;
}
header h1 {
color: #ff3030;
margin-bottom: 10px;
}
nav {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 10px;
padding: 15px;
background: #181818;
}
nav a {
color: white;
text-decoration: none;
background: #292929;
padding: 12px 17px;
border-radius: 9px;
}
nav a:hover {
background: #e52222;
}
.hero {
text-align: center;
padding: 65px 15px;
background: linear-gradient(135deg, #151515, #4b0808);
}
.hero h2 {
color: #ff3939;
font-size: 28px;
margin-bottom: 15px;
}
.hero p {
line-height: 2;
color: #ddd;
}
.btn {
display: inline-block;
background: #ed2525;
color: white;
border: none;
padding: 13px 20px;
border-radius: 9px;
text-decoration: none;
cursor: pointer;
margin: 8px 3px;
font-size: 14px;
}
.btn:hover {
background: #bd1010;
}
section {
max-width: 950px;
padding: 35px 15px;
margin: auto;
}
section h2 {
text-align: center;
color: #ff3535;
margin-bottom: 22px;
}
.card {
background: #171717;
padding: 22px;
border-radius: 14px;
text-align: center;
border: 1px solid #333;
margin-bottom: 20px;
}
.card p {
color: #ccc;
line-height: 2;
}
.editor {
background: #151515;
border: 1px solid #333;
border-radius: 15px;
padding: 15px;
}
label {
display: block;
margin: 14px 0 8px;
color: #eee;
}
input[type="text"] {
width: 100%;
padding: 13px;
border: 1px solid #444;
background: #080808;
color: white;
border-radius: 8px;
outline: none;
}
input[type="color"] {
width: 100%;
height: 45px;
border: none;
background: transparent;
cursor: pointer;
}
input[type="range"] {
width: 100%;
accent-color: #ff3030;
}
input[type="file"] {
width: 100%;
padding: 12px;
background: #252525;
border-radius: 8px;
color: white;
}
.color-preview {
display: flex;
align-items: center;
gap: 10px;
background: #242424;
padding: 10px;
border-radius: 8px;
}
.color-preview span {
width: 28px;
height: 28px;
border-radius: 50%;
border: 2px solid white;
}
.canvas-area {
background: #000;
padding: 12px;
border-radius: 12px;
margin-top: 20px;
}
.canvas-title {
text-align: center;
color: #aaa;
font-size: 13px;
margin-bottom: 10px;
}
canvas {
width: 100%;
display: block;
border: 2px solid #555;
border-radius: 5px;
background-color: #fff;
background-image:
linear-gradient(45deg, #333 25%, transparent 25%),
linear-gradient(-45deg, #333 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #333 75%),
linear-gradient(-45deg, transparent 75%, #333 75%);
background-size: 32px 32px;
background-position:
0 0,
0 16px,
16px -16px,
-16px 0;
touch-action: none;
}
.tools {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-top: 15px;
}
.tools button {
padding: 13px 5px;
border: none;
border-radius: 8px;
color: white;
background: #292929;
cursor: pointer;
}
.tools button:hover {
background: #e52222;
}
.download {
width: 100%;
padding: 16px;
margin-top: 15px;
background: #159b48;
color: white;
border: none;
border-radius: 10px;
font-size: 16px;
cursor: pointer;
}
.download:hover {
background: #087c34;
}
#toast {
position: fixed;
bottom: 25px;
left: 50%;
transform: translateX(-50%);
background: #159b48;
color: white;
padding: 15px 22px;
border-radius: 10px;
display: none;
z-index: 999;
text-align: center;
width: max-content;
max-width: 90%;
}
footer {
background: #151515;
text-align: center;
padding: 25px;
color: #aaa;
line-height: 2;
}
footer a {
color: #ff3939;
text-decoration: none;
}
@media (max-width: 500px) {
.hero h2 {
font-size: 22px;
}
}
</style>
</head>
<body>
<header>
<h1>🏎️ اسپرت سوار ۲ مود شده</h1>
<p>دنیای ماشین های اسپرت</p>
</header>
<nav>
<a href="#home">صفحه اصلی</a>
<a href="#sticker">ساخت برچسب</a>
<a href="#support">پشتیبانی</a>
</nav>
<div class="hero" id="home">
<h2>به دنیای اسپرت خوش آمدی!</h2>
<p>برچسب اختصاصی خودت رو بساز و طرح های جذاب درست کن.</p>
<a class="btn" href="https://rubika.ir/Sport1407" target="_blank"> ورود به کانال روبیکا </a>
<a class="btn" href="#sticker">ساخت برچسب</a>
</div>
<section>
<div class="card">
<h2>🔥 درباره سایت</h2>
<p>
این سایت مخصوص طرفداران بازی اسپرت سوار ۲ است. می توانی عکس و نوشته دلخواهت را به برچسب
تبدیل کنی.
</p>
</div>
</section>
<section id="sticker">
<h2>🎨 ساخت برچسب اختصاصی</h2>
<div class="editor">
<label>✏️ متن دلخواه خودت را بنویس:</label>
<input type="text" id="textInput" placeholder="متن برچسب را اینجا بنویس..." />
<label>رنگ نوشته:</label>
<div class="color-preview">
<input type="color" id="textColor" value="#ff0000" />
<span id="colorSample"></span>
</div>
<label>اندازه نوشته:</label>
<input type="range" id="fontSize" min="15" max="100" value="45" />
<button class="btn" onclick="addText()">➕ افزودن متن به برچسب</button>
<label>🖼️ عکس دلخواهت را انتخاب کن:</label>
<input type="file" id="imageInput" accept="image/*" />
<div class="canvas-area">
<div class="canvas-title">محدوده طراحی برچسب</div>
<canvas id="canvas" width="600" height="350"></canvas>
</div>
<div class="tools">
<button onclick="moveFront()">⬆️ آوردن به جلو</button>
<button onclick="deleteSelected()">🗑 حذف طرح انتخابی</button>
<button onclick="rotateItem()">🔄 چرخش طرح</button>
<button onclick="clearCanvas()">پاک کردن همه</button>
</div>
<button class="download" onclick="downloadSticker()">⬇️ دانلود برچسب</button>
<p style="text-align: center; color: #aaa; margin-top: 15px; font-size: 12px">
برای جابه جایی عکس یا نوشته، آن را با انگشت بکش.
</p>
</div>
</section>
<section id="support">
<div class="card">
<h2>📞 پشتیبانی</h2>
<p>برای ارتباط با پشتیبانی سایت روی دکمه زیر بزن.</p>
<a class="btn" href="https://rubika.ir/BENIRAN___6" target="_blank"> ارتباط با پشتیبانی </a>
</div>
</section>
<footer>
ساخته شده برای طرفداران اسپرت سوار ۲ 🏎️
<br />
کانال روبیکا:
<a href="https://rubika.ir/Sport1407">@Sport1407</a>
</footer>
<div id="toast">برچسب به گالری اضافه شد ✅</div>
<script>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
let items = [];
let selected = -1;
let dragging = false;
let offsetX = 0;
let offsetY = 0;
const textInput = document.getElementById("textInput");
const textColor = document.getElementById("textColor");
const fontSize = document.getElementById("fontSize");
const colorSample = document.getElementById("colorSample");
function updateColor() {
colorSample.style.background = textColor.value;
if (selected >= 0 && items[selected] && items[selected].type === "text") {
items[selected].color = textColor.value;
draw();
}
}
textColor.addEventListener("input", updateColor);
function addText() {
const text = textInput.value.trim();
if (!text) {
alert("لطفاً اول متن خودت را بنویس!");
textInput.focus();
return;
}
items.push({
type: "text",
text: text,
x: 300,
y: 175,
size: Number(fontSize.value),
color: textColor.value,
angle: 0,
});
selected = items.length - 1;
draw();
}
document.getElementById("imageInput").addEventListener("change", function (event) {
const file = event.target.files[0];
if (!file) return;
if (!file.type.startsWith("image/")) {
alert("لطفاً یک عکس انتخاب کن.");
return;
}
const reader = new FileReader();
reader.onload = function (e) {
const img = new Image();
img.onload = function () {
items.push({
type: "image",
img: img,
x: 300,
y: 175,
width: 180,
height: 140,
angle: 0,
});
selected = items.length - 1;
draw();
};
img.src = e.target.result;
};
reader.readAsDataURL(file);
event.target.value = "";
});
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
items.forEach((item, index) => {
ctx.save();
ctx.translate(item.x, item.y);
ctx.rotate(((item.angle || 0) * Math.PI) / 180);
if (item.type === "text") {
ctx.font = "bold " + item.size + "px Tahoma";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.lineWidth = 5;
ctx.strokeStyle = "#000";
ctx.strokeText(item.text, 0, 0);
ctx.fillStyle = item.color;
ctx.fillText(item.text, 0, 0);
} else if (item.type === "image") {
const ratio = Math.min(item.width / item.img.width, item.height / item.img.height);
const w = item.img.width * ratio;
const h = item.img.height * ratio;
ctx.drawImage(item.img, -w / 2, -h / 2, w, h);
}
if (index === selected) {
ctx.setLineDash([6, 4]);
ctx.strokeStyle = "#00d9ff";
ctx.lineWidth = 2;
const w = item.type === "image" ? item.width : item.size * 2;
const h = item.type === "image" ? item.height : item.size * 1.5;
ctx.strokeRect(-w / 2 - 8, -h / 2 - 8, w + 16, h + 16);
}
ctx.restore();
});
}
function hitTest(item, x, y) {
const w = item.type === "image" ? item.width : item.size * 2;
const h = item.type === "image" ? item.height : item.size * 1.5;
return Math.abs(x - item.x) < w / 2 + 10 && Math.abs(y - item.y) < h / 2 + 10;
}
function getPosition(e) {
const rect = canvas.getBoundingClientRect();
return {
x: ((e.clientX - rect.left) * canvas.width) / rect.width,
y: ((e.clientY - rect.top) * canvas.height) / rect.height,
};
}
canvas.addEventListener("pointerdown", function (e) {
const pos = getPosition(e);
selected = -1;
for (let i = items.length - 1; i >= 0; i--) {
if (hitTest(items[i], pos.x, pos.y)) {
selected = i;
dragging = true;
offsetX = pos.x - items[i].x;
offsetY = pos.y - items[i].y;
break;
}
}
canvas.setPointerCapture(e.pointerId);
draw();
});
canvas.addEventListener("pointermove", function (e) {
if (!dragging || selected < 0) return;
const pos = getPosition(e);
items[selected].x = pos.x - offsetX;
items[selected].y = pos.y - offsetY;
draw();
});
function stopDragging() {
dragging = false;
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
function deleteSelected() {
if (selected < 0) {
alert("اول یک طرح را انتخاب کن.");
return;
}
items.splice(selected, 1);
selected = -1;
draw();
}
function rotateItem() {
if (selected < 0) {
alert("اول یک طرح را انتخاب کن.");
return;
}
items[selected].angle = (items[selected].angle || 0) + 15;
draw();
}
function moveFront() {
if (selected < 0) return;
const item = items.splice(selected, 1)[0];
items.push(item);
selected = items.length - 1;
draw();
}
function clearCanvas() {
if (items.length === 0) return;
if (confirm("همه طرح ها پاک شوند؟")) {
items = [];
selected = -1;
draw();
}
}
// نسخه اصلاح شده دانلود برچسب
function downloadSticker() {
if (items.length === 0) {
alert("اول یک عکس یا متن به برچسب اضافه کن!");
return;
}
const oldSelected = selected;
selected = -1;
draw();
try {
canvas.toBlob(function (blob) {
selected = oldSelected;
draw();
if (!blob) {
alert("ساخت فایل برچسب ناموفق بود!");
return;
}
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "Sport-Sticker.png";
document.body.appendChild(link);
link.click();
link.remove();
showToast();
setTimeout(function () {
URL.revokeObjectURL(url);
}, 10000);
}, "image/png");
} catch (error) {
selected = oldSelected;
draw();
alert("دانلود انجام نشد. دوباره امتحان کن.");
}
}
function showToast() {
const toast = document.getElementById("toast");
toast.style.display = "block";
setTimeout(function () {
toast.style.display = "none";
}, 3000);
}
updateColor();
draw();
</script>
</body>
</html>