File size: 105,091 Bytes
6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c af8892d 6b1f31c 68c3bbb 6b1f31c af8892d 6b1f31c af8892d 6b1f31c 75a9c4f 6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c af8892d 6b1f31c af8892d 6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c af8892d 6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c af8892d 6b1f31c af8892d 6b1f31c af8892d 6b1f31c af8892d 6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c af8892d 6b1f31c af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 0357693 af8892d 0357693 af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d 0357693 af8892d 0357693 af8892d 0357693 af8892d 0357693 af8892d 0357693 af8892d 0357693 af8892d 7911c98 af8892d 7911c98 6b1f31c af8892d 75a9c4f 6b1f31c 75a9c4f 7911c98 75a9c4f 4b38fac 75a9c4f 6b1f31c 75a9c4f af8892d 6b1f31c af8892d 75a9c4f 6b1f31c 7911c98 af8892d 7911c98 af8892d 7911c98 75a9c4f af8892d 7911c98 6b1f31c 4b38fac 7911c98 af8892d 7911c98 af8892d 7911c98 de27712 af8892d de27712 7911c98 af8892d 7911c98 4b38fac 75a9c4f 6b1f31c 7911c98 af8892d 6b1f31c 4b38fac 6b1f31c af8892d 6b1f31c 4b38fac 6b1f31c 75a9c4f af8892d 75a9c4f 6b1f31c 4b38fac 6b1f31c 75a9c4f af8892d 75a9c4f 6b1f31c 4b38fac 6b1f31c af8892d 6b1f31c 4b38fac 6b1f31c 75a9c4f 6b1f31c 75a9c4f 6b1f31c 75a9c4f 6b1f31c 75a9c4f 6b1f31c 75a9c4f 6b1f31c 75a9c4f 6b1f31c 4b38fac 6b1f31c af8892d 6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c 75a9c4f 6b1f31c af8892d 6b1f31c 7911c98 6b1f31c 4b38fac 75a9c4f 4b38fac 75a9c4f af8892d 75a9c4f de27712 af8892d de27712 75a9c4f de27712 af8892d 75a9c4f de27712 af8892d de27712 af8892d de27712 6b1f31c 4b38fac 6b1f31c 75a9c4f af8892d 6b1f31c 4b38fac af8892d 75a9c4f 6b1f31c af8892d 0357693 6b1f31c 4b38fac 75a9c4f 6b1f31c 75a9c4f 7911c98 75a9c4f af8892d 6b1f31c 75a9c4f 6b1f31c 7911c98 af8892d 7911c98 af8892d 7911c98 75a9c4f 6b1f31c af8892d 6b1f31c 4b38fac 6b1f31c 75a9c4f af8892d 75a9c4f af8892d 75a9c4f af8892d de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d 75a9c4f af8892d 4b38fac af8892d 6b1f31c af8892d 4b38fac af8892d 4b38fac af8892d 6b1f31c af8892d 6b1f31c af8892d 4b38fac af8892d 6b1f31c af8892d 4b38fac af8892d 6b1f31c 7911c98 de27712 7911c98 de27712 7911c98 de27712 7911c98 de27712 7911c98 af8892d 7911c98 af8892d 7911c98 de27712 af8892d 7911c98 4b38fac af8892d 4b38fac af8892d 4b38fac af8892d 4b38fac 7911c98 de27712 af8892d 7911c98 de27712 7911c98 de27712 7911c98 de27712 af8892d de27712 7911c98 4b38fac af8892d 4b38fac af8892d 4b38fac de27712 4b38fac af8892d de27712 4b38fac af8892d 7911c98 1559ee1 4b38fac af8892d 1559ee1 4b38fac af8892d 7911c98 de27712 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 75a9c4f 7911c98 75a9c4f 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 57b0391 7911c98 57b0391 7911c98 57b0391 7911c98 57b0391 7911c98 af8892d 7911c98 6b1f31c 57b0391 7911c98 6b1f31c af8892d 6b1f31c 7911c98 6b1f31c af8892d 7911c98 8deed8c b1f73e5 8182211 b1f73e5 8deed8c 8182211 8deed8c 8182211 8deed8c 7911c98 96a9937 7911c98 b1f73e5 ddaa132 b1f73e5 ddaa132 b1f73e5 ddaa132 b1f73e5 ddaa132 b1f73e5 ddaa132 b1f73e5 7911c98 ddaa132 7911c98 ddaa132 b1f73e5 ddaa132 7911c98 01f6c29 7911c98 6b1f31c 7911c98 af8892d 7911c98 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 6b1f31c 7911c98 af8892d 7911c98 af8892d 7911c98 01f6c29 7911c98 0357693 7911c98 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 96a9937 0357693 6b1f31c 96a9937 de27712 af8892d de27712 af8892d de27712 7911c98 de27712 7911c98 af8892d 7911c98 6b1f31c 7911c98 af8892d 7911c98 01f6c29 7911c98 af8892d 7911c98 6b1f31c 7911c98 af8892d 7911c98 6b1f31c af8892d 7911c98 af8892d 7911c98 6b1f31c af8892d 7911c98 de27712 7911c98 4b38fac 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 6b1f31c 7911c98 af8892d 7911c98 75a9c4f 7911c98 af8892d 75a9c4f de27712 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 75a9c4f 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d de27712 af8892d de27712 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 4b38fac de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d de27712 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 af8892d 7911c98 75a9c4f 7911c98 af8892d 7911c98 de27712 4b38fac 7911c98 af8892d 7911c98 af8892d 7911c98 de27712 af8892d de27712 7911c98 af8892d de27712 7911c98 de27712 7911c98 af8892d 7911c98 de27712 7911c98 af8892d 7911c98 75a9c4f 7911c98 75a9c4f 7911c98 4b38fac af8892d 4b38fac af8892d 4b38fac de27712 4b38fac af8892d 4b38fac af8892d 4b38fac de27712 4b38fac af8892d 4b38fac de27712 af8892d de27712 af8892d de27712 af8892d de27712 4b38fac af8892d 6b1f31c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Thumbnail Creator</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<style>
@font-face {
font-family: 'Pyidaungsu';
src: url('https://github.com/myanmartools/pyidaungsu-font/raw/master/Pyidaungsu.ttf') format('truetype');
}
.myanmar-text {
font-family: 'Pyidaungsu', sans-serif;
}
.thumbnail-container {
position: relative;
width: 100%;
max-width: 1800px;
margin: 0 auto;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.thumbnail-canvas {
width: 100%;
height: auto;
border: 2px solid #e5e7eb;
display: block;
transition: all 0.3s ease;
}
.text-tool {
position: absolute;
cursor: move;
user-select: none;
}
.text-tool.active {
outline: 2px dashed #3b82f6;
}
.text-tool-handle {
position: absolute;
width: 10px;
height: 10px;
background: #3b82f6;
bottom: -5px;
right: -5px;
cursor: nwse-resize;
border-radius: 50%;
}
.color-picker {
width: 30px;
height: 30px;
border: 2px solid #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
cursor: pointer;
border-radius: 4px;
}
.tool-panel {
transition: all 0.3s ease;
}
.tool-panel.collapsed {
transform: translateX(100%);
opacity: 0;
pointer-events: none;
}
/* Gradient overlay styles */
.gradient-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Text stroke effect */
.text-stroke {
text-shadow: -1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
}
/* Multiple vertical gradient overlays */
.multi-gradient-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background: linear-gradient(rgba(0, 0, 0, 0.3) 0%,
rgba(0, 0, 0, 0.1) 20%,
rgba(0, 0, 0, 0) 40%,
rgba(0, 0, 0, 0) 60%,
rgba(0, 0, 0, 0.1) 80%,
rgba(0, 0, 0, 0.3) 100%);
}
/* Draggable handle */
.drag-handle {
width: 20px;
height: 20px;
background: #3b82f6;
border-radius: 50%;
position: absolute;
bottom: -10px;
right: -10px;
cursor: nwse-resize;
z-index: 10;
}
/* Rotation handle */
.rotate-handle {
width: 20px;
height: 20px;
background: #3b82f6;
border-radius: 50%;
position: absolute;
top: -10px;
right: -10px;
cursor: grab;
z-index: 10;
}
/* Scale handle */
.scale-handle {
width: 20px;
height: 20px;
background: #3b82f6;
border-radius: 50%;
position: absolute;
bottom: -10px;
left: -10px;
cursor: nesw-resize;
z-index: 10;
}
/* Tooltip styles */
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
font-size: 12px;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
/* Animated buttons */
.btn-animate {
transition: all 0.2s ease;
transform: translateY(0);
}
.btn-animate:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
/* Input range styling */
input[type="range"] {
-webkit-appearance: none;
height: 6px;
background: #e5e7eb;
border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #3b82f6;
border-radius: 50%;
cursor: pointer;
}
/* File upload styling */
.file-upload {
position: relative;
overflow: hidden;
}
.file-upload input {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
}
/* Panel transitions */
.panel-transition {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Loading spinner */
.spinner {
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* Transform controls */
.transform-controls {
position: absolute;
display: flex;
flex-direction: column;
background: rgba(255, 255, 255, 0.9);
border-radius: 4px;
padding: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
z-index: 20;
}
.transform-btn {
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
margin: 2px;
border-radius: 4px;
background: #f1f1f1;
cursor: pointer;
}
.transform-btn:hover {
background: #e5e5e5;
}
/* Text edit input */
.text-edit-input {
position: absolute;
background: transparent;
border: none;
outline: none;
resize: none;
overflow: hidden;
font-family: 'Pyidaungsu', sans-serif;
padding: 0;
margin: 0;
line-height: 1.2;
}
/* AI enhancement loading overlay */
.ai-loading-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: white;
z-index: 100;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-8">
<div class="text-center mb-8">
<h1 class="text-3xl font-bold text-blue-600 mb-2">Advanced Thumbnail Creator</h1>
<p class="text-gray-600">Create stunning thumbnails with AI enhancement and custom fonts</p>
</div>
<div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
<div class="flex flex-col lg:flex-row gap-6">
<!-- Left Panel - Tools -->
<div class="w-full lg:w-1/3 p-6 bg-gray-50">
<!-- Upload Section -->
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<h2 class="text-lg font-semibold mb-3 text-gray-800 flex items-center">
<i class="fas fa-cloud-upload-alt text-blue-500 mr-2"></i>
Upload Image
</h2>
<div
class="file-upload flex flex-col items-center justify-center border-2 border-dashed border-gray-300 rounded-lg p-6 bg-gray-50 hover:bg-gray-100 transition-colors">
<input type="file" id="imageUpload" accept="image/*" class="hidden">
<label for="imageUpload"
class="cursor-pointer flex flex-col items-center">
<i class="fas fa-image text-4xl text-blue-400 mb-2"></i>
<span class="text-gray-600 font-medium">Choose an image</span>
<span class="text-sm text-gray-400 mt-1">or drag and drop</span>
</label>
</div>
<div class="mt-3 grid grid-cols-3 gap-2">
<button id="removeImageBtn"
class="py-2 bg-red-50 text-red-600 rounded hover:bg-red-100 disabled:opacity-50 transition-colors"
disabled>
<i class="fas fa-trash mr-1"></i> Remove
</button>
<button id="fitImageBtn"
class="py-2 bg-blue-50 text-blue-600 rounded hover:bg-blue-100 disabled:opacity-50 transition-colors"
disabled>
<i class="fas fa-expand mr-1"></i> Fit
</button>
<button id="aiEnhanceBtn"
class="py-2 bg-purple-50 text-purple-600 rounded hover:bg-purple-100 disabled:opacity-50 transition-colors"
disabled>
<i class="fas fa-magic mr-1"></i> AI Enhance
</button>
</div>
</div>
<!-- Font Upload Section -->
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<h2 class="text-lg font-semibold mb-3 text-gray-800 flex items-center">
<i class="fas fa-font text-blue-500 mr-2"></i>
Custom Font
</h2>
<div
class="file-upload flex flex-col items-center justify-center border-2 border-dashed border-gray-300 rounded-lg p-4 bg-gray-50 hover:bg-gray-100 transition-colors">
<input type="file" id="fontUpload" accept=".ttf,.otf,.woff,.woff2" class="hidden">
<label for="fontUpload"
class="cursor-pointer flex flex-col items-center">
<i class="fas fa-file-upload text-2xl text-blue-400 mb-1"></i>
<span class="text-sm text-gray-600 font-medium">Upload Font</span>
<span class="text-xs text-gray-400 mt-1">.ttf, .otf, .woff</span>
</label>
</div>
<div id="fontLoadingIndicator" class="hidden text-center mt-2 text-sm text-gray-600 flex items-center justify-center">
<i class="fas fa-spinner spinner mr-2"></i> Loading font...
</div>
<div id="fontOptions" class="mt-3">
<div class="flex items-center mb-2 text-gray-600 text-sm hidden"
id="loadedFontNameContainer">
<i class="fas fa-check-circle text-green-500 mr-2"></i>
Custom font loaded: <span id="loadedFontName" class="font-medium ml-1"></span>
</div>
<label class="block text-sm font-medium text-gray-700 mb-1">Font Family</label>
<select id="fontFamily"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition">
<option value="Pyidaungsu">Pyidaungsu (Default)</option>
<option value="Arial">Arial</option>
<option value="Helvetica">Helvetica</option>
<option value="Times New Roman">Times New Roman</option>
<option value="Courier New">Courier New</option>
<option value="Georgia">Georgia</option>
<option value="Verdana">Verdana</option>
</select>
</div>
</div>
<!-- Text Tools Section -->
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<h2 class="text-lg font-semibold mb-3 text-gray-800 flex items-center">
<i class="fas fa-font text-blue-500 mr-2"></i>
Text Tools
</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Text Content</label>
<textarea id="myanmarText"
class="w-full px-3 py-2 border border-gray-300 rounded-lg myanmar-text focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"
placeholder="Enter your text here" rows="3"></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Font Size</label>
<input type="range" id="fontSize" min="10" max="100" value="24" class="w-full">
<div class="text-center text-sm text-gray-600 mt-1"><span
id="fontSizeValue">24</span>px</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Font Color</label>
<div class="flex items-center gap-2">
<input type="color" id="fontColor" value="#ffffff"
class="w-10 h-10 rounded cursor-pointer">
<button id="randomColorBtn"
class="px-2 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm">
<i class="fas fa-random text-gray-600"></i>
</button>
</div>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Background</label>
<div class="flex items-center gap-2">
<input type="color" id="bgColor" value="#00000000"
class="w-10 h-10 rounded cursor-pointer">
<button id="transparentBgBtn"
class="px-2 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm">
Clear
</button>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Opacity</label>
<input type="range" id="textOpacity" min="0" max="100" value="100" class="w-full">
<div class="text-center text-sm text-gray-600 mt-1"><span
id="opacityValue">100</span>%</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Font Style</label>
<div class="flex space-x-2">
<button id="boldBtn" class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 tooltip">
<i class="fas fa-bold"></i>
<span class="tooltiptext">Bold</span>
</button>
<button id="italicBtn" class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 tooltip">
<i class="fas fa-italic"></i>
<span class="tooltiptext">Italic</span>
</button>
<button id="underlineBtn" class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 tooltip">
<i class="fas fa-underline"></i>
<span class="tooltiptext">Underline</span>
</button>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Text Alignment</label>
<div class="flex space-x-2">
<button id="alignLeftBtn"
class="px-3 py-1 bg-blue-100 text-blue-600 rounded hover:bg-blue-200 tooltip">
<i class="fas fa-align-left"></i>
<span class="tooltiptext">Align Left</span>
</button>
<button id="alignCenterBtn"
class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 tooltip">
<i class="fas fa-align-center"></i>
<span class="tooltiptext">Align Center</span>
</button>
<button id="alignRightBtn"
class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 tooltip">
<i class="fas fa-align-right"></i>
<span class="tooltipttext">Align Right</span>
</button>
</div>
</div>
<div class="space-y-3">
<div class="flex items-center justify-between">
<label class="block text-sm font-medium text-gray-700">Text Effects</label>
<button id="toggleEffectsBtn" class="text-xs text-blue-500 hover:text-blue-600">
<i class="fas fa-chevron-down mr-1"></i> Show
</button>
</div>
<div id="effectsPanel" class="hidden space-y-3">
<div class="grid grid-cols-2 gap-4">
<div>
<div class="flex items-center mb-1">
<input type="checkbox" id="outlineCheck" class="h-4 w-4 mr-2">
<label for="outlineCheck" class="text-sm">Outline</label>
</div>
<div class="flex items-center space-x-2 pl-6">
<input type="color" id="outlineColor" value="#000000" class="w-8 h-8"
disabled>
<input type="range" id="outlineWidth" min="0" max="10" value="2"
class="w-full" disabled>
</div>
<div class="pl-6 mt-2">
<label class="block text-sm font-medium text-gray-700 mb-1">Outline
Style</label>
<select id="outlineStyle"
class="px-2 py-1 border border-gray-300 rounded text-sm"
disabled>
<option value="solid">Solid</option>
<option value="dashed">Dashed</option>
<option value="dotted">Dotted</option>
</select>
</div>
</div>
<div>
<div class="flex items-center mb-1">
<input type="checkbox" id="shadowCheck" class="h-4 w-4 mr-2">
<label for="shadowCheck" class="text-sm">Shadow</label>
</div>
<div class="flex items-center space-x-2 pl-6">
<label class="text-xs text-gray-600">Color</label>
<input type="color" id="shadowColor" value="#000000" class="w-8 h-8"
disabled>
</div>
<div class="pl-6 mt-2 grid grid-cols-2 gap-4">
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">Blur
Radius</label>
<input type="range" id="shadowBlur" min="0" max="20" value="5"
class="w-full" disabled>
</div>
<div>
<label class="block text-xs font-medium text-gray-700 mb-1">Offset
(X, Y)</label>
<div class="flex space-x-1"><input type="number" id="shadowOffsetX"
placeholder="X"
class="w-10 px-1 py-0.5 border rounded text-xs"
disabled><input type="number" id="shadowOffsetY"
placeholder="Y"
class="w-10 px-1 py-0.5 border rounded text-xs"
disabled></div>
</div>
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Max Width</label>
<input type="range" id="maxWidth" min="100" max="1800" value="800"
class="w-full">
<div class="text-center text-sm text-gray-600 mt-1"><span
id="maxWidthValue">800</span>px</div>
</div>
</div>
</div>
<button id="addTextBtn"
class="w-full py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 btn-animate flex items-center justify-center">
<i class="fas fa-plus mr-2"></i> Add Text to Thumbnail
</button>
<button id="updateTextBtn"
class="w-full py-2.5 bg-green-600 text-white rounded-lg hover:bg-green-700 btn-animate flex items-center justify-center hidden">
<i class="fas fa-save mr-2"></i> Update Text
</button>
</div>
</div>
<!-- Overlay Effects Section -->
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<h2 class="text-lg font-semibold mb-3 text-gray-800 flex items-center">
<i class="fas fa-layer-group text-blue-500 mr-2"></i>
Overlay Effects
</h2>
<div class="space-y-4">
<div>
<div class="flex items-center mb-1">
<input type="checkbox" id="gradientCheck" class="h-4 w-4 mr-2">
<label for="gradientCheck" class="text-sm">Gradient Overlay</label>
</div>
<div class="flex items-center space-x-2 pl-6">
<select id="gradientType"
class="px-2 py-1 border border-gray-300 rounded text-sm" disabled>
<option value="top">Top to Bottom</option>
<option value="bottom">Bottom to Top</option>
<option value="left">Left to Right</option>
<option value="right">Right to Left</option>
<option value="vignette">Vignette</option>
<option value="multi">Multiple Vertical</option>
</select>
</div>
</div>
<div class="pl-6 grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Color 1</label>
<input type="color" id="gradientColor1" value="#000000"
class="w-10 h-10 rounded cursor-pointer" disabled>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Color 2</label>
<input type="color" id="gradientColor2" value="#000000"
class="w-10 h-10 rounded cursor-pointer" disabled>
</div>
</div>
<div class="pl-6">
<label class="block text-sm font-medium text-gray-700 mb-1">Gradient Opacity</label>
<input type="range" id="gradientOpacity" min="0" max="100", value="50"
class="w-full" disabled>
<div class="text-center text-sm text-gray-600 mt-1"><span
id="gradientOpacityValue">50</span>%</div>
</div>
</div>
</div>
</div>
<!-- Right Panel - Thumbnail Preview -->
<div class="w-full lg:w-2/3 p-6">
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-semibold text-gray-800 flex items-center">
<i class="fas fa-image text-blue-500 mr-2"></i>
Thumbnail Preview
</h2>
<div class="flex items-center space-x-2">
<button id="clearAllBtn"
class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm disabled:opacity-50"
disabled>
<i class="fas fa-trash-alt mr-1"></i> Clear All
</button>
<button id="downloadBtn"
class="px-3 py-1 bg-green-500 text-white rounded hover:bg-green-600 btn-animate disabled:opacity-50"
disabled>
<i class="fas fa-download mr-1"></i> Download
</button>
<!-- Undo/Redo Buttons -->
<button id="undoBtn"
class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm disabled:opacity-50"
disabled>
<i class="fas fa-undo mr-1"></i> Undo
</button>
<button id="redoBtn"
class="px-3 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm disabled:opacity-50"
disabled>
<i class="fas fa-redo mr-1"></i> Redo
</button>
</div>
</div>
<!-- Text Reordering Controls -->
<div class="flex items-center justify-center space-x-2 mb-4 hidden" id="reorderControls">
<span class="text-sm text-gray-700">Layer:</span>
<button id="bringForwardBtn"
class="px-2 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm tooltip disabled:opacity-50"
disabled>
<i class="fas fa-arrow-up"></i>
<span class="tooltiptext">Bring Forward</span>
</button>
<button id="sendBackwardBtn"
class="px-2 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm tooltip disabled:opacity-50"
disabled>
<i class="fas fa-arrow-down"></i>
<span class="tooltiptext">Send Backward</span>
</button>
<button id="bringToFrontBtn"
class="px-2 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm tooltip disabled:opacity-50"
disabled>
<i class="fas fa-angle-double-up"></i>
<span class="tooltiptext">Bring to Front</span>
</button>
<button id="sendToBackBtn"
class="px-2 py-1 bg-gray-100 rounded hover:bg-gray-200 text-sm tooltip disabled:opacity-50"
disabled>
<i class="fas fa-angle-double-down"></i>
<span class="tooltiptext">Send to Back</span>
</button>
</div>
</div>
<div class="thumbnail-container">
<canvas id="thumbnailCanvas" class="thumbnail-canvas" width="800" height="450"></canvas>
<div id="aiLoadingOverlay" class="ai-loading-overlay hidden">
<i class="fas fa-spinner spinner text-4xl mb-2"></i>
<p>Enhancing image with AI...</p>
</div>
</div>
<div class="mt-4 flex flex-col sm:flex-row gap-4 items-center">
<div class="w-full sm:w-auto">
<label class="block text-sm font-medium text-gray-700 mb-1">Thumbnail Size</label>
<select id="thumbnailSize"
class="w-full px-3 py-2 border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500">
<option value="800x450">800x450 (16:9)</option>
<option value="1280x720">1280x720 (HD)</option>
<option value="1920x1080">1920x1080 (Full HD)</option>
<option value="custom">Custom</option>
</select>
</div>
<div id="customSizeContainer" class="hidden w-full sm:w-auto">
<label class="block text-sm font-medium text-gray-700 mb-1">Custom Size</label>
<div class="flex items-center space-x-2">
<input type="number" id="customWidth" placeholder="Width"
class="w-20 px-2 py-1 border border-gray-300 rounded" min="100" max="4000">
<span class="text-gray-500">×</span>
<input type="number" id="customHeight" placeholder="Height"
class="w-20 px-2 py-1 border border-gray-300 rounded" min="100" max="4000">
</div>
</div>
<button id="applySizeBtn"
class="w-full sm:w-auto px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 btn-animate mt-6 sm:mt-0">
<i class="fas fa-check mr-1"></i> Apply Size
</button>
</div>
</div>
<div class="bg-white rounded-lg shadow-sm p-4">
<h2 class="text-lg font-semibold mb-3 text-gray-800 flex items-center">
<i class="fas fa-list text-blue-500 mr-2"></i>
Text Elements
</h2>
<div class="space-y-2 max-h-60 overflow-y-auto" id="textElementsList">
<div class="text-center py-4 text-gray-500">
<i class="fas fa-info-circle mr-1"></i> No text elements added yet
</div>
</div>
</div>
</div>
</div>
</div>
<div class="text-center text-gray-500 text-sm mt-8">
<p>© 2023 Advanced Thumbnail Creator | Made with <i class="fas fa-heart text-red-400"></i></p>
</div>
</div>
<script>
// DOM Elements
const canvas = document.getElementById('thumbnailCanvas');
const ctx = canvas.getContext('2d');
const imageUpload = document.getElementById('imageUpload');
const removeImageBtn = document.getElementById('removeImageBtn');
const fitImageBtn = document.getElementById('fitImageBtn');
const aiEnhanceBtn = document.getElementById('aiEnhanceBtn');
const aiLoadingOverlay = document.getElementById('aiLoadingOverlay');
const downloadBtn = document.getElementById('downloadBtn');
const clearAllBtn = document.getElementById('clearAllBtn');
const myanmarText = document.getElementById('myanmarText');
const fontSize = document.getElementById('fontSize');
const fontSizeValue = document.getElementById('fontSizeValue');
const fontColor = document.getElementById('fontColor');
const randomColorBtn = document.getElementById('randomColorBtn');
const bgColor = document.getElementById('bgColor');
const transparentBgBtn = document.getElementById('transparentBgBtn');
const textOpacity = document.getElementById('textOpacity');
const opacityValue = document.getElementById('opacityValue');
const addTextBtn = document.getElementById('addTextBtn');
const updateTextBtn = document.getElementById('updateTextBtn');
const boldBtn = document.getElementById('boldBtn');
const italicBtn = document.getElementById('italicBtn');
const underlineBtn = document.getElementById('underlineBtn');
const alignLeftBtn = document.getElementById('alignLeftBtn');
const alignCenterBtn = document.getElementById('alignCenterBtn');
const alignRightBtn = document.getElementById('alignRightBtn');
const thumbnailSize = document.getElementById('thumbnailSize');
const customSizeContainer = document.getElementById('customSizeContainer');
const customWidth = document.getElementById('customWidth');
const customHeight = document.getElementById('customHeight');
const applySizeBtn = document.getElementById('applySizeBtn');
const outlineCheck = document.getElementById('outlineCheck');
const outlineColor = document.getElementById('outlineColor');
const outlineWidth = document.getElementById('outlineWidth');
const outlineStyle = document.getElementById('outlineStyle');
const shadowBlur = document.getElementById('shadowBlur');
const shadowOffsetX = document.getElementById('shadowOffsetX');
const shadowOffsetY = document.getElementById('shadowOffsetY');
const shadowCheck = document.getElementById('shadowCheck');
const shadowColor = document.getElementById('shadowColor');
const maxWidth = document.getElementById('maxWidth');
const maxWidthValue = document.getElementById('maxWidthValue');
const gradientCheck = document.getElementById('gradientCheck');
const gradientType = document.getElementById('gradientType');
const gradientColor1 = document.getElementById('gradientColor1');
const gradientColor2 = document.getElementById('gradientColor2');
const gradientOpacity = document.getElementById('gradientOpacity');
const gradientOpacityValue = document.getElementById('gradientOpacityValue');
const textElementsList = document.getElementById('textElementsList');
const toggleEffectsBtn = document.getElementById('toggleEffectsBtn');
const effectsPanel = document.getElementById('effectsPanel');
const fontUpload = document.getElementById('fontUpload');
const undoBtn = document.getElementById('undoBtn');
const redoBtn = document.getElementById('redoBtn');
const fontFamily = document.getElementById('fontFamily');
const fontLoadingIndicator = document.getElementById('fontLoadingIndicator');
const fontOptions = document.getElementById('fontOptions');
const loadedFontNameContainer = document.getElementById('loadedFontNameContainer');
const reorderControls = document.getElementById('reorderControls');
const bringForwardBtn = document.getElementById('bringForwardBtn');
const sendBackwardBtn = document.getElementById('sendBackwardBtn');
const bringToFrontBtn = document.getElementById('bringToFrontBtn');
// State variables
let uploadedImage = null;
let activeTextElement = null;
let textElements = [];
let isDragging = false;
let isResizing = false;
let isRotating = false;
let isScaling = false;
let isManipulating = false; // Flag to indicate any manipulation is in progress
let startX, startY;
let currentFontStyle = {
bold: false,
italic: false,
underline: false,
align: 'left',
outline: false,
outlineColor: '#000000',
outlineWidth: 2,
outlineStyle: 'solid',
shadowBlur: 5,
shadowOffset: {
x: 3,
y: 3
},
shadow: false,
shadowColor: '#000000',
maxWidth: 800,
fontFamily: 'Pyidaungsu'
};
let textEditInput = null;
let customFonts = {};
// Initialize canvas
let history = [];
let historyIndex = -1;
function initCanvas() {
ctx.fillStyle = 'white'; // Changed to white for better visibility
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#94a3b8';
ctx.font = '20px Arial';
ctx.textAlign = 'center';
ctx.fillText('Upload an image to start designing', canvas.width / 2, canvas.height / 2);
// Draw grid pattern
ctx.strokeStyle = '#e2e8f0';
ctx.lineWidth = 1;
// Vertical lines
for (let x = 0; x <= canvas.width; x += 20) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, canvas.height);
ctx.stroke();
}
// Horizontal lines
for (let y = 0; y <= canvas.width; y += 20) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(canvas.width, canvas.height);
ctx.stroke();
}
}
initCanvas();
// Event Listeners
imageUpload.addEventListener('change', handleImageUpload);
removeImageBtn.addEventListener('click', removeImage);
fitImageBtn.addEventListener('click', fitImageToCanvas);
aiEnhanceBtn.addEventListener('click', enhanceImageWithAI);
downloadBtn.addEventListener('click', downloadThumbnail);
clearAllBtn.addEventListener('click', clearAllElements);
fontSize.addEventListener('input', updateFontSizeValue);
textOpacity.addEventListener('input', updateOpacityValue);
addTextBtn.addEventListener('click', addTextToCanvas);
updateTextBtn.addEventListener('click', updateTextElement);
boldBtn.addEventListener('click', toggleBold);
italicBtn.addEventListener('click', toggleItalic);
underlineBtn.addEventListener('click', toggleUnderline);
alignLeftBtn.addEventListener('click', () => setTextAlign('left'));
alignCenterBtn.addEventListener('click', () => setTextAlign('center'));
alignRightBtn.addEventListener('click', () => setTextAlign('right'));
thumbnailSize.addEventListener('change', handleThumbnailSizeChange);
applySizeBtn.addEventListener('click', applyCanvasSize);
outlineCheck.addEventListener('change', toggleOutline);
outlineColor.addEventListener('input', updateOutlineColor);
outlineWidth.addEventListener('input', updateOutlineWidth);
outlineStyle.addEventListener('change', updateOutlineStyle);
shadowBlur.addEventListener('input', updateShadowBlur);
shadowOffsetX.addEventListener('input', updateShadowOffset);
shadowOffsetY.addEventListener('input', updateShadowOffset);
shadowCheck.addEventListener('change', toggleShadow);
shadowColor.addEventListener('input', updateShadowColor);
maxWidth.addEventListener('input', updateMaxWidth);
gradientCheck.addEventListener('change', toggleGradient);
gradientType.addEventListener('change', redrawCanvas);
gradientColor1.addEventListener('input', redrawCanvas);
gradientColor2.addEventListener('input', redrawCanvas);
gradientOpacity.addEventListener('input', updateGradientOpacity);
undoBtn.addEventListener('click', undo);
redoBtn.addEventListener('click', redo);
randomColorBtn.addEventListener('click', generateRandomColor);
bringForwardBtn.addEventListener('click', () => reorderTextElement('forward'));
sendBackwardBtn.addEventListener('click', () => reorderTextElement('backward'));
bringToFrontBtn.addEventListener('click', () => reorderTextElement('front'));
sendToBackBtn.addEventListener('click', () => reorderTextElement('back'));
transparentBgBtn.addEventListener('click', setTransparentBackground);
toggleEffectsBtn.addEventListener('click', toggleEffectsPanel);
fontUpload.addEventListener('change', handleFontUpload);
fontFamily.addEventListener('change', updateFontFamily);
// Canvas interaction
canvas.addEventListener('mousedown', handleCanvasMouseDown);
canvas.addEventListener('mousemove', handleCanvasMouseMove);
canvas.addEventListener('mouseup', handleCanvasMouseUp);
canvas.addEventListener('mouseleave', handleCanvasMouseUp);
// History Management
function saveState() {
// Limit history size (optional)
const maxHistorySize = 20;
if (history.length > maxHistorySize) {
history.shift();
historyIndex--;
}
history = history.slice(0, historyIndex + 1);
history.push(JSON.stringify({
uploadedImageSrc: uploadedImage ? uploadedImage.src : null,
textElements: textElements
}));
historyIndex = history.length - 1;
updateHistoryButtons();
}
// Functions
function handleImageUpload(e) {
const file = e.target.files[0];
if (!file) return;
// Show loading state
const originalText = downloadBtn.innerHTML;
downloadBtn.innerHTML = '<i class="fas fa-spinner spinner mr-2"></i> Loading...';
downloadBtn.disabled = true;
const reader = new FileReader();
reader.onload = function (event) {
const img = new Image();
img.onload = function () {
uploadedImage = img;
// Fit image to canvas size
try {
fitImageToCanvas();
removeImageBtn.disabled = false;
fitImageBtn.disabled = false;
saveState(); // Save state after image upload
aiEnhanceBtn.disabled = false;
downloadBtn.disabled = false;
} catch (error) {
console.error("Error during fitImageToCanvas:", error);
alert('Failed to draw image to canvas. See console for details.');
} finally {
downloadBtn.innerHTML = originalText;
downloadBtn.disabled = false;
}
};
img.onerror = function () {
let errorMessage = 'Error loading image.';
if (img.naturalWidth === 0) {
errorMessage += ' The file might be corrupted or not a valid image.';
} else {
errorMessage += ' Please try another file.';
}
showAlert(errorMessage, 'error');
downloadBtn.innerHTML = originalText;
downloadBtn.disabled = false;
};
img.src = event.target.result;
};
reader.onerror = function () {
downloadBtn.innerHTML = originalText;
downloadBtn.disabled = false;
};
reader.readAsDataURL(file);
}
function fitImageToCanvas() {
if (!uploadedImage) return;
// Clear canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Calculate scale to fill canvas while maintaining aspect ratio
const scale = Math.max(
canvas.width / uploadedImage.width,
canvas.height / uploadedImage.height
);
// Calculate dimensions to fill canvas
const width = uploadedImage.width * scale;
const height = uploadedImage.height * scale;
// Center the image
const x = (canvas.width - width) / 2;
const y = (canvas.height - height) / 2;
// Draw image
ctx.drawImage(uploadedImage, x, y, width, height);
// Apply gradient overlay if enabled
if (gradientCheck.checked) {
applyGradientOverlay();
}
// Redraw all text elements
redrawTextElements();
}
function removeImage() {
uploadedImage = null;
initCanvas();
saveState(); // Save state after image removal
redrawTextElements();
removeImageBtn.disabled = true;
fitImageBtn.disabled = true;
aiEnhanceBtn.disabled = true;
downloadBtn.disabled = textElements.length === 0;
}
function enhanceImageWithAI() {
if (!uploadedImage) return;
// Show loading overlay
aiLoadingOverlay.classList.remove('hidden');
// Simulate AI enhancement (in a real app, this would call an API)
setTimeout(() => {
// Create a temporary canvas for enhancement
const tempCanvas = document.createElement('canvas');
tempCanvas.width = uploadedImage.width;
tempCanvas.height = uploadedImage.height;
const tempCtx = tempCanvas.getContext('2d');
tempCtx.drawImage(uploadedImage, 0, 0);
// Apply some basic enhancements (simulated AI)
const imageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
const data = imageData.data;
// Simple contrast and brightness adjustment
for (let i = 0; i < data.length; i += 4) {
// Contrast adjustment
const factor = 1.5;
data[i] = factor * (data[i] - 128) + 128;
data[i + 1] = factor * (data[i + 1] - 128) + 128;
data[i + 2] = factor * (data[i + 2] - 128) + 128;
// Brightness adjustment
data[i] = Math.min(255, data[i] * 1.1);
data[i + 1] = Math.min(255, data[i + 1] * 1.1);
data[i + 2] = Math.min(255, data[i + 2] * 1.1);
// Slight sharpening
if (i > 0 && i < data.length - 8) {
data[i] = Math.min(255, data[i] * 1.2 - data[i - 4] * 0.2);
data[i + 1] = Math.min(255, data[i + 1] * 1.2 - data[i - 3] * 0.2);
data[i + 2] = Math.min(255, data[i + 2] * 1.2 - data[i - 2] * 0.2);
}
}
tempCtx.putImageData(imageData, 0, 0);
// Create new enhanced image
const enhancedImg = new Image();
enhancedImg.onload = function () {
uploadedImage = enhancedImg;
fitImageToCanvas();
saveState(); // Save state after AI enhancement
aiLoadingOverlay.classList.add('hidden');
showAlert('Image enhanced successfully!', 'success');
};
enhancedImg.src = tempCanvas.toDataURL('image/jpeg', 0.9);
}, 2000);
}
function redrawCanvas() {
if (uploadedImage) {
fitImageToCanvas();
} else {
initCanvas();
}
}
function applyGradientOverlay() {
const opacity = gradientOpacity.value / 100;
const color1 = hexToRgba(gradientColor1.value, opacity);
const color2 = hexToRgba(gradientColor2.value, opacity);
if (gradientType.value === 'multi') {
// Apply multiple vertical gradient overlay
ctx.save();
ctx.globalCompositeOperation = 'multiply';
// Create multiple gradient layers
const gradient1 = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient1.addColorStop(0, color1);
gradient1.addColorStop(0.5, `rgba(${hexToRgb(gradientColor1.value)}, ${opacity * 0.2})`);
gradient1.addColorStop(1, color1);
const gradient2 = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient2.addColorStop(0, `rgba(${hexToRgb(gradientColor2.value)}, ${opacity * 0.4})`);
gradient2.addColorStop(0.3, `rgba(${hexToRgb(gradientColor2.value)}, ${opacity * 0.1})`);
gradient2.addColorStop(0.7, `rgba(${hexToRgb(gradientColor2.value)}, ${opacity * 0.1})`);
gradient2.addColorStop(1, `rgba(${hexToRgb(gradientColor2.value)}, ${opacity * 0.4})`);
// Draw first gradient
ctx.fillStyle = gradient1;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw second gradient with offset
ctx.fillStyle = gradient2;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.restore();
} else {
let gradient;
switch (gradientType.value) {
case 'top':
gradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
break;
case 'bottom':
gradient = ctx.createLinearGradient(0, canvas.height, 0, 0);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
break;
case 'left':
gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
break;
case 'right':
gradient = ctx.createLinearGradient(canvas.width, 0, 0, 0);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
break;
case 'vignette':
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const radius = Math.max(canvas.width, canvas.height) / 2;
gradient = ctx.createRadialGradient(centerX, centerY, radius * 0.5, centerX, centerY, radius);
gradient.addColorStop(0, color2);
gradient.addColorStop(1, color1);
break;
}
ctx.save();
ctx.globalCompositeOperation = 'multiply';
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.restore();
}
}
function hexToRgba(hex, opacity) {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
}
function hexToRgb(hex) {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `${r}, ${g}, ${b}`;
}
function redrawTextElements(){
textElements.forEach(text =>{
drawTextElement(text);
});
updateTextElementsList();
}
function drawTextElement(text){
ctx.save();
// Set text alignment
ctx.textAlign = text.align;
// In drawTextElement function:
const lines = wrapText(ctx, text.content, text.maxWidth);
const lineHeight = text.size * 1.2;
const textHeight = lines.length * lineHeight;
// Calculate total width (max line width)
let totalWidth = 0;
lines.forEach(line =>{
const metrics = ctx.measureText(line);
if (metrics.width > totalWidth) {
totalWidth = metrics.width;
}
});
// Set font style
let fontStyle = '';
fontStyle += text.bold ? 'bold ' : '';
fontStyle += text.italic ? 'italic ' : '';
fontStyle += `${text.size}px `;
fontStyle += text.fontFamily || currentFontStyle.fontFamily;
ctx.font = fontStyle;
// Calculate position based on alignment
let x = text.x;
if (text.align === 'center') {
x = text.x + totalWidth / 2;
} else if (text.align === 'right') {
x = text.x + totalWidth;
}
// Draw background if needed
if (text.bgColor !== 'transparent') {
const bgAlpha = parseInt(text.bgColor.slice(-2), 16) / 255;
ctx.fillStyle = text.bgColor.slice(0, -2) + '00)';
ctx.globalAlpha = bgAlpha;
const padding = 10;
const bgWidth = totalWidth + padding * 2;
const bgHeight = textHeight + padding * 2;
let bgX = text.x;
if (text.align === 'center') {
bgX = text.x + (totalWidth - bgWidth) / 2;
} else if (text.align === 'right') {
bgX = text.x + totalWidth - bgWidth;
}
ctx.fillRect(bgX, text.y - textHeight - padding / 2, bgWidth, bgHeight);
}
// Draw text with effects
ctx.fillStyle = text.color;
ctx.globalAlpha = text.opacity / 100;
// Draw shadow if enabled
if (text.shadow) {
ctx.shadowColor = text.shadowColor;
ctx.shadowBlur = text.shadowBlur;
ctx.shadowOffsetX = text.shadowOffset.x;
ctx.shadowOffsetY = text.shadowOffset.y;
} else {
ctx.shadowColor = 'transparent';
ctx.shadowBlur = 0;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
}
// Draw outline if enabled
if (text.outline) {
ctx.strokeStyle = text.outlineColor;
ctx.lineWidth = text.outlineWidth;
// Set line dash for outline style
if (text.outlineStyle === 'dashed') {
ctx.setLineDash([5, 3]);
} else if (text.outlineStyle === 'dotted') {
ctx.setLineDash([1, 2]);
} else {
ctx.setLineDash([]);
}
}
// Draw each line
lines.forEach((line, i) => {
const y = text.y - (lines.length - 1 - i) * lineHeight;
// Calculate x position based on alignment
let x = text.x;
const metrics = ctx.measureText(line);
if (text.align === 'center') {
x = text.x - metrics.width / 2;
} else if (text.align === 'right') {
x = text.x - metrics.width;
}
// Draw outline first (if enabled)
if (text.outline) {
ctx.strokeText(line, x, y);
}
// Then draw the filled text
ctx.fillText(line, x, y);
});
// Reset line dash if outline was enabled
if (text.outline) {
ctx.setLineDash([]);
}
// Draw underline if enabled
if (text.underline) {
ctx.strokeStyle = text.color;
ctx.lineWidth = 2;
ctx.beginPath();
const lastLineY = text.y;
ctx.moveTo(x - totalWidth / 2, lastLineY + 2);
ctx.lineTo(x + totalWidth / 2, lastLineY + 2);
ctx.stroke();
}
ctx.restore();
// Draw outline and handles if active
if (text === activeTextElement) {
ctx.save();
ctx.strokeStyle = '#3b82f6';
ctx.lineWidth = 2;
ctx.setLineDash([5, 5]);
// Calculate bounding box with larger padding
const padding = 15;
const boxWidth = text.width + padding * 2;
const boxHeight = text.height + padding * 2;
let boxX = text.x;
if (text.align === 'center') {
boxX = text.x - boxWidth / 2;
} else if (text.align === 'right') {
boxX = text.x - boxWidth;
}
const boxY = text.y - text.height - padding;
// Draw the bounding box
ctx.strokeRect(boxX, boxY, boxWidth, boxHeight);
// Draw resize handle (bottom right) - larger and more visible
const handleSize = 20;
const resizeHandleX = boxX + boxWidth;
const resizeHandleY = boxY + boxHeight;
ctx.fillStyle = '#3b82f6';
ctx.beginPath();
ctx.arc(resizeHandleX, resizeHandleY, handleSize/2, 0, Math.PI * 2);
ctx.fill();
// Draw rotate handle (top right)
const rotateHandleX = boxX + boxWidth;
const rotateHandleY = boxY;
ctx.fillStyle = '#3b82f6';
ctx.beginPath();
ctx.arc(rotateHandleX, rotateHandleY, handleSize/2, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
}
}
// Function to wrap text based on max width
function wrapText(context, text, maxWidth) {
if (!text || text.trim() === '') return [''];
const words = text.split(/\s+/);
const lines = [];
let currentLine = '';
for (let i = 0; i < words.length; i++) {
const word = words[i];
// Test if adding this word would exceed the max width
const testLine = currentLine ? currentLine + ' ' + word : word;
const metrics = context.measureText(testLine);
if (metrics.width <= maxWidth || currentLine === '') {
// Word fits or it's the first word in line
currentLine = testLine;
} else {
// Word doesn't fit, push current line and start new line
lines.push(currentLine);
currentLine = word;
}
}
// Push the last line
if (currentLine !== '') {
lines.push(currentLine);
}
return lines;
}
function addTextToCanvas() {
const content = myanmarText.value.trim();
if (!content) {
showAlert('Please enter some text first', 'warning');
return;
}
const textSize = parseInt(fontSize.value);
const color = fontColor.value;
const bg = bgColor.value === '#00000000' ? 'transparent' : bgColor.value + '00)';
const opacity = parseInt(textOpacity.value);
const maxWidthValue = parseInt(maxWidth.value);
const fontFamilyValue = fontFamily.value;
// Calculate initial position (centered)
ctx.font = `${currentFontStyle.bold ? 'bold ' : ''}${currentFontStyle.italic ? 'italic ' : ''}${textSize}px ${fontFamilyValue}`;
// Calculate text metrics with word wrap
const lines = wrapText(ctx, content, maxWidthValue);
const lineHeight = textSize * 1.4;
const textHeight = lines.length * lineHeight;
// Calculate total width (max line width)
let totalWidth = 0;
lines.forEach(line => {
const metrics = ctx.measureText(line);
if (metrics.width > totalWidth) {
totalWidth = metrics.width;
}
});
const x = (canvas.width - totalWidth) / 2;
const y = (canvas.height + textHeight) / 2;
const textElement = {
id: Date.now(), // Unique ID for each text element
content,
x,
y,
width: totalWidth,
height: textHeight,
size: textSize,
color,
bgColor: bg,
opacity,
bold: currentFontStyle.bold,
italic: currentFontStyle.italic,
underline: currentFontStyle.underline,
align: currentFontStyle.align,
outline: outlineCheck.checked,
outlineColor: outlineColor.value,
outlineWidth: parseInt(outlineWidth.value),
outlineStyle: outlineStyle.value,
shadow: shadowCheck.checked,
shadowColor: shadowColor.value,
shadowBlur: parseInt(shadowBlur.value),
shadowOffset: {
x: parseInt(shadowOffsetX.value),
y: parseInt(shadowOffsetY.value)
},
maxWidth: maxWidthValue,
rotation: 0,
scale: 1,
fontFamily: fontFamilyValue
};
textElements.push(textElement);
activeTextElement = textElement;
redrawCanvas();
downloadBtn.disabled = false;
reorderControls.classList.remove('hidden');
saveState(); // Save state after adding text
clearAllBtn.disabled = false;
// Clear input
myanmarText.value = '';
// Show success message
showAlert('Text added to thumbnail!', 'success');
}
function updateTextElement() {
if (!activeTextElement) return;
const content = myanmarText.value.trim();
if (!content) {
showAlert('Please enter some text first', 'warning');
return;
}
// Update text element properties
activeTextElement.content = content;
activeTextElement.size = parseInt(fontSize.value);
activeTextElement.color = fontColor.value;
activeTextElement.bgColor = bgColor.value === '#00000000' ? 'transparent' : bgColor.value + '00)';
activeTextElement.opacity = parseInt(textOpacity.value);
activeTextElement.bold = currentFontStyle.bold;
activeTextElement.italic = currentFontStyle.italic;
activeTextElement.underline = currentFontStyle.underline;
activeTextElement.align = currentFontStyle.align;
activeTextElement.outline = outlineCheck.checked;
activeTextElement.outlineColor = outlineColor.value;
activeTextElement.outlineWidth = parseInt(outlineWidth.value);
activeTextElement.outlineStyle = outlineStyle.value;
activeTextElement.shadow = shadowCheck.checked;
activeTextElement.shadowColor = shadowColor.value;
activeTextElement.shadowBlur = parseInt(shadowBlur.value);
activeTextElement.shadowOffset = {
x: parseInt(shadowOffsetX.value),
y: parseInt(shadowOffsetY.value)
};
activeTextElement.maxWidth = parseInt(maxWidth.value);
activeTextElement.fontFamily = fontFamily.value;
// Recalculate dimensions
ctx.font = `${activeTextElement.bold ? 'bold ' : ''}${activeTextElement.italic ? 'italic ' : ''}${activeTextElement.size}px ${activeTextElement.fontFamily}`;
const lines = wrapText(ctx, activeTextElement.content, activeTextElement.maxWidth);
const lineHeight = activeTextElement.size * 1.4;
activeTextElement.height = lines.length * lineHeight;
// Calculate total width (max line width)
let totalWidth = 0;
lines.forEach(line => {
const metrics = ctx.measureText(line);
if (metrics.width > totalWidth) {
totalWidth = metrics.width;
}
});
activeTextElement.width = totalWidth;
// Redraw canvas
redrawCanvas();
// Hide updatebutton and show add button
updateTextBtn.classList.add('hidden');
addTextBtn.classList.remove('hidden');
// Clear input
saveState(); // Save state after updating text
myanmarText.value = '';
// Show success message
showAlert('Text updated successfully!', 'success');
}
function handleCanvasMouseDown(e) {
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
// Check if clicked on a text element
activeTextElement = null;
for (let i = textElements.length - 1; i >= 0; i--) {
const text = textElements[i];
const lineHeight = text.size * 1.2;
// Calculate bounding box for wrapped text with larger padding
const padding = 15; // Increased from 5 to make it easier to grab
const boxWidth = text.width + padding * 2;
const boxHeight = text.height + padding * 2;
let boxX = text.x;
if (text.align === 'center') {
boxX = text.x - boxWidth / 2;
} else if (text.align === 'right') {
boxX = text.x - boxWidth;
}
const boxY = text.y - text.height - padding;
// Check if clicked inside the expanded text box
if (x >= boxX && x <= boxX + boxWidth &&
y >= boxY && y <= boxY + boxHeight) {
activeTextElement = text;
// Check if clicked on resize handle (bottom right)
const handleSize = 20;
const resizeHandleX = boxX + boxWidth - handleSize / 2;
const resizeHandleY = boxY + boxHeight - handleSize / 2;
if (x >= resizeHandleX - handleSize && x <= resizeHandleX + handleSize &&
y >= resizeHandleY - handleSize && y <= resizeHandleY + handleSize) {
isResizing = true;
}
// Check if clicked on rotate handle (top right)
else if (x >= resizeHandleX - handleSize && x <= resizeHandleX + handleSize &&
y >= boxY - handleSize / 2 && y <= boxY + handleSize / 2) {
isRotating = true;
}
else {
isDragging = true;
// Double click to edit text
if (e.detail === 2) {
editTextElement(text);
}
}
startX = x;
startY = y;
break;
}
}
// Update UI controls based on active text element
if (activeTextElement) {
myanmarText.value = activeTextElement.content;
fontSize.value = activeTextElement.size;
fontSizeValue.textContent = activeTextElement.size;
fontColor.value = activeTextElement.color;
bgColor.value = activeTextElement.bgColor === 'transparent' ? '#00000000' : activeTextElement.bgColor;
textOpacity.value = activeTextElement.opacity;
opacityValue.textContent = activeTextElement.opacity;
// Update font style buttons
boldBtn.classList.toggle('bg-blue-200', activeTextElement.bold);
italicBtn.classList.toggle('bg-blue-200', activeTextElement.italic);
underlineBtn.classList.toggle('bg-blue-200', activeTextElement.underline);
// Update alignment buttons
setTextAlign(activeTextElement.align); // This function already toggles classes
// Update text effect controls
outlineCheck.checked = activeTextElement.outline;
outlineColor.value = activeTextElement.outlineColor;
outlineWidth.value = activeTextElement.outlineWidth;
outlineStyle.value = activeTextElement.outlineStyle;
shadowCheck.checked = activeTextElement.shadow;
shadowColor.value = activeTextElement.shadowColor;
shadowBlur.value = activeTextElement.shadowBlur;
shadowOffsetX.value = activeTextElement.shadowOffset.x;
shadowOffsetY.value = activeTextElement.shadowOffset.y;
maxWidth.value = activeTextElement.maxWidth;
maxWidthValue.textContent = activeTextElement.maxWidth;
toggleOutline(); // Update disabled state based on checkbox
toggleShadow(); // Update disabled state based on checkbox
}
redrawCanvas();
updateReorderButtons(); // Update reorder buttons state
}
function editTextElement(text) {
// Remove any existing edit input
if (textEditInput) {
textEditInput.remove();
textEditInput = null;
}
// Create text edit input
textEditInput = document.createElement('textarea');
textEditInput.className = 'text-edit-input';
textEditInput.style.fontFamily = text.fontFamily || currentFontStyle.fontFamily;
textEditInput.value = text.content;
textEditInput.style.fontSize = `${text.size}px`;
textEditInput.style.color = text.color;
textEditInput.style.fontWeight = text.bold ? 'bold' : 'normal';
textEditInput.style.fontStyle = text.italic ? 'italic' : 'normal';
textEditInput.style.textDecoration = text.underline ? 'underline' : 'none';
textEditInput.rows = 3; // Allow multiple lines
// Calculate position and size
const lineHeight = text.size * 1.4;
const lines = wrapText(ctx, text.content, text.maxWidth);
const textHeight = lines.length * lineHeight;
const padding = 5;
const boxWidth = text.width + padding * 2;
const boxHeight = textHeight + padding * 2;
let boxX = text.x;
if (text.align === 'center') {
boxX = text.x - boxWidth / 2;
} else if (text.align === 'right') {
boxX = text.x - boxWidth;
}
// Position the input
const canvasRect = canvas.getBoundingClientRect();
textEditInput.style.position = 'absolute';
textEditInput.style.left = `${canvasRect.left + boxX}px`;
textEditInput.style.top = `${canvasRect.top + text.y - textHeight - padding}px`;
textEditInput.style.width = `${boxWidth}px`;
textEditInput.style.height = `${boxHeight}px`;
// Add to document
document.body.appendChild(textEditInput);
textEditInput.focus();
// Handle input events
textEditInput.addEventListener('blur', function () {
if (textEditInput) {
text.content = textEditInput.value;
textEditInput.remove();
textEditInput = null;
redrawCanvas();
}
saveState(); // Save state after editing text
});
textEditInput.addEventListener('keydown', function (e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
text.content = textEditInput.value;
textEditInput.remove();
textEditInput = null;
redrawCanvas();
} else if (e.key === 'Escape') {
textEditInput.remove();
textEditInput = null;
redrawCanvas();
}
saveState(); // Save state after editing text
});
}
function handleCanvasMouseMove(e) {
if (!isDragging && !isResizing && !isRotating && !isScaling) return;
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
if (isDragging && activeTextElement) {
isManipulating = true;
// Move the text element
const dx = x - startX;
const dy = y - startY;
activeTextElement.x += dx;
activeTextElement.y += dy;
startX = x;
startY = y;
}
else if (isResizing && activeTextElement) {
isManipulating = true;
// Resize the text element (change font size proportionally)
const dy = startY - y;
const scale = 1 + dy / 50;
// Calculate new font size
let newSize = Math.max(10, Math.min(100, activeTextElement.size * scale));
if (newSize !== activeTextElement.size) {
activeTextElement.size = newSize;
const lines = wrapText(ctx, activeTextElement.content, activeTextElement.maxWidth);
const lineHeight = activeTextElement.size * 1.2;
activeTextElement.height = lines.length * lineHeight;
// Calculate total width (max line width)
let totalWidth = 0;
lines.forEach(line => {
const metrics = ctx.measureText(line);
if (metrics.width > totalWidth) {
totalWidth = metrics.width;
}
});
activeTextElement.width = totalWidth;
startY = y;
}
}
else if (isRotating && activeTextElement) {
isManipulating = true;
// Rotate the text element
const centerX = activeTextElement.x + activeTextElement.width / 2;
const centerY = activeTextElement.y - activeTextElement.height / 2;
const angle = Math.atan2(y - centerY, x - centerX) - Math.atan2(startY - centerY, startX - centerY);
activeTextElement.rotation += angle * (180 / Math.PI); // Convert to degrees
startX = x;
startY = y;
redrawCanvas(); // Redraw bounding box during rotate
}
else if (isScaling && activeTextElement) {
isManipulating = true;
// Scale the text element (change width proportionally)
const dx = x - startX;
const scale = 1 + dx / 100;
// Calculate new max width
let newMaxWidth = Math.max(50, Math.min(1800, activeTextElement.maxWidth * scale));
if (newMaxWidth !== activeTextElement.maxWidth) {
activeTextElement.maxWidth = newMaxWidth;
// Update font and recalculate width with word wrap
ctx.font = `${activeTextElement.bold ? 'bold ' : ''}${activeTextElement.italic ? 'italic ' : ''}${activeTextElement.size}px ${activeTextElement.fontFamily}`;
const lines = wrapText(ctx, activeTextElement.content, activeTextElement.maxWidth);
const lineHeight = activeTextElement.size * 1.2;
activeTextElement.height = lines.length * lineHeight;
// Calculate total width (max line width)
let totalWidth = 0;
lines.forEach(line => {
const metrics = ctx.measureText(line);
if (metrics.width > totalWidth) {
totalWidth = metrics.width;
}
});
activeTextElement.width = totalWidth;
startX = x;
redrawCanvas(); // Redraw bounding box during scale
}
}
redrawCanvas(); // Redraw canvas during manipulation (only bounding box)
}
function handleCanvasMouseUp() {
isManipulating = false;
isDragging = false;
isResizing = false;
isRotating = false;
isScaling = false;
saveState(); // Save the state after the manipulation ends
}
canvas.addEventListener('mouseup', redrawCanvas); // Redraw the full canvas after manipulation ends
// Redraw canvas on mouseup to show full text element
function downloadThumbnail() {
// Show loading state
const originalText = downloadBtn.innerHTML;
downloadBtn.innerHTML = '<i class="fas fa-spinner spinner mr-2"></i> Processing...';
downloadBtn.disabled = true;
// Create a temporary link
setTimeout(() => {
const link = document.createElement('a');
link.download = 'thumbnail-' + Date.now() + '.png';
link.href = canvas.toDataURL('image/png');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Restore button state
downloadBtn.innerHTML = originalText;
downloadBtn.disabled = false;
// Show success message
showAlert('Thumbnail downloaded successfully!', 'success');
}, 100);
}
function clearAllElements() {
if (confirm('Are you sure you want to remove all text elements?')) {
textElements = [];
activeTextElement = null;
saveState(); // Save state after clearing all elements
redrawCanvas();
reorderControls.classList.add('hidden'); // Hide reorder controls
downloadBtn.disabled = !uploadedImage;
clearAllBtn.disabled = true;
// Show success message
showAlert('All text elements removed', 'info');
}
}
function updateFontSizeValue() {
fontSizeValue.textContent = fontSize.value;
}
function updateOpacityValue() {
opacityValue.textContent = textOpacity.value;
}
function toggleBold() {
currentFontStyle.bold = !currentFontStyle.bold;
boldBtn.classList.toggle('bg-blue-200', currentFontStyle.bold);
// If an element is active, update it immediately
if (activeTextElement) {
activeTextElement.bold = currentFontStyle.bold;
}
}
function toggleItalic() {
currentFontStyle.italic = !currentFontStyle.italic;
italicBtn.classList.toggle('bg-blue-200', currentFontStyle.italic);
// If an element is active, update it immediately
if (activeTextElement) {
activeTextElement.italic = currentFontStyle.italic;
}
}
function toggleUnderline() {
currentFontStyle.underline = !currentFontStyle.underline;
underlineBtn.classList.toggle('bg-blue-200', currentFontStyle.underline);
// If an element is active, update it immediately
if (activeTextElement) {
activeTextElement.underline = currentFontStyle.underline;
}
}
function setTextAlign(align) {
currentFontStyle.align = align;
// Update button states
alignLeftBtn.classList.remove('bg-blue-200');
alignCenterBtn.classList.remove('bg-blue-200');
alignRightBtn.classList.remove('bg-blue-200');
if (align === 'left') {
alignLeftBtn.classList.add('bg-blue-200');
} else if (align === 'center') {
alignCenterBtn.classList.add('bg-blue-200');
} else if (align === 'right') {
alignRightBtn.classList.add('bg-blue-200');
}
// If an element is active, update it immediately
if (activeTextElement) {
activeTextElement.align = align;
}
}
function toggleOutline() {
const enabled = outlineCheck.checked;
outlineColor.disabled = !enabled;
outlineWidth.disabled = !enabled;
currentFontStyle.outline = enabled;
outlineStyle.disabled = !enabled;
// If an element is active, update it immediately
if (activeTextElement) {
activeTextElement.outline = enabled;
activeTextElement.outlineColor = outlineColor.value;
activeTextElement.outlineWidth = parseInt(outlineWidth.value);
activeTextElement.outlineStyle = outlineStyle.value;
}
}
function updateOutlineColor() {
currentFontStyle.outlineColor = outlineColor.value;
if (activeTextElement) {
activeTextElement.outlineColor = outlineColor.value;
}
}
function updateOutlineWidth() {
currentFontStyle.outlineWidth = parseInt(outlineWidth.value);
if (activeTextElement) {
activeTextElement.outlineWidth = parseInt(outlineWidth.value);
}
}
function toggleShadow() {
const enabled = shadowCheck.checked;
shadowColor.disabled = !enabled;
shadowBlur.disabled = !enabled;
shadowOffsetX.disabled = !enabled;
shadowOffsetY.disabled = !enabled;
currentFontStyle.shadow = enabled;
// If an element is active, update it immediately
if (activeTextElement) {
activeTextElement.shadow = enabled;
activeTextElement.shadowColor = shadowColor.value;
activeTextElement.shadowBlur = parseInt(shadowBlur.value);
activeTextElement.shadowOffset = {
x: parseInt(shadowOffsetX.value),
y: parseInt(shadowOffsetY.value)
};
}
}
function updateOutlineStyle() {
currentFontStyle.outlineStyle = outlineStyle.value;
if (activeTextElement) {
activeTextElement.outlineStyle = outlineStyle.value;
}
}
function updateShadowBlur() {
console.log('Updating shadow blur', shadowBlur.value);
currentFontStyle.shadowBlur = parseInt(shadowBlur.value);
if (activeTextElement) {
activeTextElement.shadowBlur = parseInt(shadowBlur.value);
}
}
function updateShadowOffset(e) {
console.log('Updating shadow offset');
currentFontStyle.shadowOffset.x = parseInt(shadowOffsetX.value);
currentFontStyle.shadowOffset.y = parseInt(shadowOffsetY.value);
console.log('New offset:', currentFontStyle.shadowOffset);
if (isNaN(currentFontStyle.shadowOffset.x)) currentFontStyle.shadowOffset.x = 0;
if (isNaN(currentFontStyle.shadowOffset.y)) currentFontStyle.shadowOffset.y = 0;
if (activeTextElement) {
activeTextElement.shadowOffset = {
x: parseInt(shadowOffsetX.value),
y: parseInt(shadowOffsetY.value)
};
updateTextElement();
}
}
function updateShadowColor() {
currentFontStyle.shadowColor = shadowColor.value;
if (activeTextElement) {
activeTextElement.shadowColor = shadowColor.value;
}
}
function updateMaxWidth() {
maxWidthValue.textContent = maxWidth.value;
currentFontStyle.maxWidth = parseInt(maxWidth.value);
}
function toggleGradient() {
const enabled = gradientCheck.checked;
gradientType.disabled = !enabled;
gradientColor1.disabled = !enabled;
gradientColor2.disabled = !enabled;
gradientOpacity.disabled = !enabled;
redrawCanvas();
}
function updateGradientOpacity() {
gradientOpacityValue.textContent = gradientOpacity.value;
redrawCanvas();
}
function generateRandomColor() {
const randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
fontColor.value = randomColor;
}
function setTransparentBackground() {
bgColor.value = '#00000000';
}
function toggleEffectsPanel() {
effectsPanel.classList.toggle('hidden');
const icon = toggleEffectsBtn.querySelector('i');
if (effectsPanel.classList.contains('hidden')) {
toggleEffectsBtn.innerHTML = '<i class="fas fa-chevron-down mr-1"></i> Show';
} else {
toggleEffectsBtn.innerHTML = '<i class="fas fa-chevron-up mr-1"></i> Hide';
}
}
function handleFontUpload(e) {
const file = e.target.files[0];
if (!file) return;
// Show loading indicator
fontLoadingIndicator.classList.remove('hidden');
fontFamily.disabled = true;
addTextBtn.disabled = true;
updateTextBtn.disabled = true;
loadedFontNameContainer.classList.add('hidden');
saveState(); // Save state before font upload (in case of error)
const reader = new FileReader();
reader.onload = function (event) {
const fontName = file.name.replace(/\.[^/.]+$/, ""); // Remove file extension
const fontFace = new FontFace(fontName, `url(${event.target.result})`);
fontFace.load().then(function (loadedFace) {
document.fonts.add(loadedFace);
customFonts[fontName] = loadedFace;
// Add to font family dropdown
const option = document.createElement('option');
option.value = fontName;
option.textContent = fontName;
fontFamily.appendChild(option);
// Select the new font if no text elements are selected
if (!activeTextElement) {
fontFamily.value = fontName;
currentFontStyle.fontFamily = fontName; // Update state
}
// Show loaded font name
document.getElementById('loadedFontName').textContent = fontName;
loadedFontNameContainer.classList.remove('hidden');
showAlert('Font loaded successfully!', 'success');
fontLoadingIndicator.classList.add('hidden');
fontFamily.disabled = false;
addTextBtn.disabled = false;
updateTextBtn.disabled = false;
}).catch(function (error) {
fontLoadingIndicator.classList.add('hidden');
fontFamily.disabled = false;
addTextBtn.disabled = false;
updateTextBtn.disabled = false;
let errorMessage = 'Error loading font.';
if (error.message.includes('network')) {
errorMessage += ' Please check the font file URL or your network connection.';
}
showAlert('Error loading font: ' + error.message, 'error');
});
};
reader.readAsDataURL(file);
// Re-enable buttons after font load attempt
}
function updateFontFamily() {
currentFontStyle.fontFamily = fontFamily.value;
// If an element is selected, apply the font immediately
if (activeTextElement) {
updateTextElement(); // This will also redraw
} else {
}
}
function updateTextElementsList() {
textElementsList.innerHTML = '';
if (textElements.length === 0) {
textElementsList.innerHTML = `
<div class="text-center py-4 text-gray-500">
<i class="fas fa-info-circle mr-1"></i> No text elements added yet
</div>
`;
return;
}
textElements.forEach((text, index) => {
const element = document.createElement('div');
element.className = 'flex items-center justify-between p-3 bg-gray-50 rounded-lg border border-gray-200 mb-2';
const preview = document.createElement('div');
preview.className = 'truncate flex-1';
preview.style.fontFamily = text.fontFamily || currentFontStyle.fontFamily;
preview.textContent = text.content;
preview.style.fontSize = `${Math.min(16, text.size)}px`;
preview.style.color = text.color;
if (text.bold) preview.style.fontWeight = 'bold';
if (text.italic) preview.style.fontStyle = 'italic';
if (text.underline) preview.style.textDecoration = 'underline';
const buttons = document.createElement('div');
buttons.className = 'flex space-x-2';
const editBtn = document.createElement('button');
editBtn.className = 'px-2 py-1 bg-blue-100 text-blue-600 rounded hover:bg-blue-200 tooltip';
editBtn.innerHTML = '<i class="fas fa-edit"></i>';
editBtn.title = 'Edit';
editBtn.addEventListener('click', () => {
activeTextElement = text;
redrawCanvas();
// Update form with selected text properties
myanmarText.value = text.content;
fontSize.value = text.size;
fontSizeValue.textContent = text.size;
fontColor.value = text.color;
bgColor.value = text.bgColor === 'transparent' ? '#00000000' : text.bgColor;
textOpacity.value = text.opacity;
opacityValue.textContent = text.opacity;
// Update font styles
currentFontStyle.bold = text.bold;
currentFontStyle.italic = text.italic;
currentFontStyle.underline = text.underline;
currentFontStyle.align = text.align;
boldBtn.classList.toggle('bg-blue-200', text.bold);
italicBtn.classList.toggle('bg-blue-200', text.italic);
underlineBtn.classList.toggle('bg-blue-200', text.underline);
setTextAlign(text.align);
// Update text effects
outlineCheck.checked = text.outline;
outlineColor.value = text.outlineColor;
outlineWidth.value = text.outlineWidth;
outlineStyle.value = text.outlineStyle;
shadowCheck.checked = text.shadow;
shadowColor.value = text.shadowColor;
shadowBlur.value = text.shadowBlur;
shadowOffsetX.value = text.shadowOffset.x;
shadowOffsetY.value = text.shadowOffset.y;
maxWidth.value = text.maxWidth;
maxWidthValue.textContent = text.maxWidth;
toggleOutline();
toggleShadow();
// Hide add button and show update button
addTextBtn.classList.add('hidden');
updateTextBtn.classList.remove('hidden');
});
const deleteBtn = document.createElement('button');
deleteBtn.className = 'px-2 py-1 bg-red-100 text-red-600 rounded hover:bg-red-200 tooltip';
deleteBtn.innerHTML = '<i class="fas fa-trash-alt"></i>';
deleteBtn.title = 'Delete';
deleteBtn.addEventListener('click', () => {
if (confirm('Are you sure you want to delete this text element?')) {
textElements = textElements.filter(t => t.id !== text.id);
if (activeTextElement === text) {
activeTextElement = null;
}
updateReorderButtons(); // Update reorder buttons state
saveState(); // Save state after deleting text
redrawCanvas();
showAlert('Text element deleted successfully!', 'info');
}
});
buttons.appendChild(editBtn);
buttons.appendChild(deleteBtn);
element.appendChild(preview);
element.appendChild(buttons);
textElementsList.appendChild(element);
});
}
function handleThumbnailSizeChange() {
const selectedSize = thumbnailSize.value;
if (selectedSize === 'custom') {
customSizeContainer.classList.remove('hidden');
} else {
customSizeContainer.classList.add('hidden');
// Extract width and height from selected size
const [width, height] = selectedSize.split('x').map(Number);
canvas.width = width;
canvas.height = height;
redrawCanvas();
}
}
function applyCanvasSize() {
const selectedSize = thumbnailSize.value;
if (selectedSize === 'custom') {
const width = parseInt(customWidth.value);
const height = parseInt(customHeight.value);
if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0) {
showAlert('Please enter valid custom dimensions.', 'warning');
return;
}
canvas.width = width;
canvas.height = height;
saveState(); // Save state after applying custom size
redrawCanvas();
} else {
handleThumbnailSizeChange();
}
}
// Utility function to show alerts
function showAlert(message, type = 'info') {
const alertContainer = document.createElement('div');
alertContainer.className = `fixed top-4 right-4 z-50 bg-${type === 'success' ? 'green' : type === 'warning' ? 'yellow' : 'blue'}-100 border border-${type === 'success' ? 'green' : type === 'warning' ? 'yellow' : 'blue'}-500 text-${type === 'success' ? 'green' : type === 'warning' ? 'yellow' : 'blue'}-700 px-4 py-3 rounded relative`;
alertContainer.innerHTML = `
<strong class="font-bold">${type.toUpperCase()}:</strong>
<span class="block sm:inline">${message}</span>
`;
document.body.appendChild(alertContainer);
// Automatically remove the alert after 3 seconds
setTimeout(() => {
document.body.removeChild(alertContainer);
}, 3000);
}
// Undo Functionality
function undo() {
if (historyIndex > 0) {
historyIndex--;
loadState(history[historyIndex]);
updateHistoryButtons();
}
}
// Redo Functionality
function redo() {
if (historyIndex < history.length - 1) {
historyIndex++;
loadState(history[historyIndex]);
updateHistoryButtons();
}
}
// Load State from History
function loadState(stateJson) {
const state = JSON.parse(stateJson);
textElements = state.textElements;
activeTextElement = null; // Deselect active element
// Reload background image if it exists
if (state.uploadedImageSrc) {
uploadedImage = new Image();
uploadedImage.onload = redrawCanvas;
uploadedImage.src = state.uploadedImageSrc;
} else {
uploadedImage = null;
redrawCanvas();
}
updateTextElementsList(); // Update the list display
}
// Update Undo/Redo button states
function reorderTextElement(action) {
if (!activeTextElement) return;
const currentIndex = textElements.indexOf(activeTextElement);
if (currentIndex === -1) return; // Should not happen
let newIndex = currentIndex;
switch (action) {
case 'forward':
newIndex = Math.min(textElements.length - 1, currentIndex + 1);
break;
case 'backward':
newIndex = Math.max(0, currentIndex - 1);
break;
case 'front':
newIndex = textElements.length - 1;
break;
case 'back':
newIndex = 0;
break;
}
if (newIndex !== currentIndex) {
// Remove the element from its current position
const [elementToMove] = textElements.splice(currentIndex, 1);
// Insert the element at the new position
textElements.splice(newIndex, 0, elementToMove);
saveState(); // Save state after reordering
redrawCanvas();
updateReorderButtons(); // Update button states after reordering
}
}
function updateReorderButtons() {
if (!activeTextElement) {
bringForwardBtn.disabled = true;
sendBackwardBtn.disabled = true;
bringToFrontBtn.disabled = true;
sendToBackBtn.disabled = true;
return;
}
const currentIndex = textElements.indexOf(activeTextElement);
if (currentIndex === -1) {
// Should not happen if activeTextElement is set correctly
bringForwardBtn.disabled = true;
sendBackwardBtn.disabled = true;
bringToFrontBtn.disabled = true;
sendToBackBtn.disabled = true;
return;
}
// Enable/disable buttons based on current index
bringForwardBtn.disabled = currentIndex === textElements.length - 1;
sendBackwardBtn.disabled = currentIndex === 0;
bringToFrontBtn.disabled = currentIndex === textElements.length - 1;
sendToBackBtn.disabled = currentIndex === 0;
// Show reorder controls if there is an active element
reorderControls.classList.remove('hidden');
}
// Update Undo/Redo button states
function updateHistoryButtons() {
undoBtn.disabled = historyIndex <= 0;
redoBtn.disabled = historyIndex >= history.length - 1;
}
// Initial save for the empty state
saveState();
// Initial redraw to show the grid
redrawCanvas();
</script>
</body>
</html> |