A web-based drawing app
git clone git://soophie.de/outline
23
<title>Outline - App</title>24
<link href="./asset/img/favicon.png" rel="shortcut icon" type="image/png">25
<link href="./css/style.css" rel="stylesheet">26
<script src="https://www.gstatic.com/firebasejs/7.21.0/firebase-app.js"></script>27
<script src="https://www.gstatic.com/firebasejs/7.21.0/firebase-analytics.js"></script>28
<script src="./js/index.js" type="module"></script>29
</head>30
<body class="app">31
<div class="cookie hidden">32
<p data-lang="main.cookie.info">We use cookies to give you the best possible user experience.</p>33
<div class="group">34
<button class="button accept" data-lang="main.cookie.submit">Accept</button>35
<a href="https://typable.dev/terms" data-lang="main.cookie.more">Learn more</a>36
</div>37
</div>38
<a id="download" target="_blank" download=""></a>39
<div class="wrapper"></div>40
<canvas id="canvas"></canvas>
8
main.terms=Nutzungsbedingungen9
main.upcoming=Outline ist derzeit nur als Webversion verfügbar. Die App-Funktionalität ist für die nächste kommende Version v1.2.0 geplant.11
main.cookie.info=Wir verwenden Cookies, um Ihnen die bestmögliche Benutzererfahrung zu bieten.12
main.cookie.submit=Akzeptieren13
main.cookie.more=Mehr erfahren15
tool.colors=Farben16
tool.pencil=Stift17
tool.scale=Skalierung
8
main.terms=Terms9
main.upcoming=Outline is currently only available as a web version. The app functionality is scheduled for the next upcoming version v1.2.0.11
main.cookie.info=We use cookies to give you the best possible user experience.12
main.cookie.submit=Accept13
main.cookie.more=Learn more15
tool.colors=Colors16
tool.pencil=Pencil17
tool.scale=Scale
8
main.terms=Conditions d'utilisation9
main.upcoming=Outline n'est actuellement disponible qu'en version Web. La fonctionnalité de l'application est prévue pour la prochaine version à venir v1.2.0.11
main.cookie.info=Nous utilisons des cookies pour vous offrir la meilleure expérience utilisateur possible.12
main.cookie.submit=J'accepte13
main.cookie.more=Apprendre encore plus15
tool.colors=Couleurs16
tool.pencil=Crayon17
tool.scale=Échelle
8
main.terms=服务条款9
main.upcoming=大纲目前仅以网络版本提供。 该应用程序功能计划在下一个即将发布的v1.2.0版本中使用。11
main.cookie.info=我们使用cookie为您提供最佳的用户体验。12
main.cookie.submit=接受13
main.cookie.more=学到更多15
tool.colors=色彩16
tool.pencil=铅笔17
tool.scale=规模
1
*{margin:0;padding:0;font-family:Roboto,sans-serif;box-sizing:border-box;-webkit-tap-highlight-color:transparent}:focus,:hover{outline:0}html{position:relative;overflow-x:hidden;min-height:100vh}body{width:100%;font-size:14px;min-height:100vh}img{pointer-events:none;user-select:none}input{-webkit-appearance:none}button{user-select:none;cursor:pointer}.hidden{display:none!important}.transparent{opacity:0!important}.ico{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga';user-select:none;pointer-events:none}.tooltip{position:relative;display:flex;justify-content:center;align-items:center}.tooltip:hover::before{opacity:.95;transition-delay:.6s}.tooltip:hover::after{opacity:.95;transition-delay:.6s}.tooltip::after{display:flex;opacity:0;content:attr(data-title);justify-content:center;align-items:center;position:absolute;background:#24292E;color:#fff;min-height:24px;padding:0 12px;border-radius:999px;font-size:12px;top:auto;bottom:-64%;white-space:nowrap;z-index:9999;pointer-events:none}body.home button.button{display:inline-flex;justify-content:center;align-items:center;box-shadow:0 0 20px 0 rgba(0,0,0,.05);border:none;border-radius:5px;height:48px;max-height:48px;min-width:180px;font-size:16px}body.home button.button:hover{box-shadow:0 0 20px 0 rgba(0,0,0,.08)}body.home button.button.button-prime-light{height:40px;max-height:40px;min-width:110px}body.home .caption{display:flex;flex-wrap:nowrap;gap:40px}body.home .caption h2.caption-headline{flex:35%;font-weight:500;font-size:30px;white-space:nowrap}body.home .caption h2.caption-headline b{font-weight:inherit}body.home .caption .caption-info{flex:65%;display:flex;flex-direction:column;align-items:flex-start;gap:30px}body.home .caption .caption-info p{font-size:18px;font-weight:400;line-height:28px}body.home .badge-version{padding:3px 6px;text-decoration:none;border-radius:3px;font-weight:500;font-size:16px;user-select:none}@media (max-width:1024px){body.home header .logo{width:140px;height:140px;min-width:140px;min-height:140px;max-width:140px;max-height:140px;background-size:160px 160px;margin-bottom:25px}body.home header h1.headline{font-size:50px}body.home header p.description{font-size:18px;line-height:26px;margin-bottom:20px}body.home header .badge.badge-version{margin-bottom:40px}body.home .caption{flex-wrap:wrap}}@media (max-width:768px){body.home header p.description{padding:0!important}}@media (max-width:425px){body.home header{padding:0 30px!important}body.home header h1.headline{font-size:40px}body.home header .row{flex-direction:column;justify-content:flex-start;align-items:center;gap:20px}body.home header .row button{min-width:240px}body.home main{padding:0 30px!important}body.home main .container{padding:100px 0!important;padding-top:60px!important;gap:80px!important}body.home main .caption{gap:30px}body.home main .caption h2.caption-headline{font-size:28px}body.home main .caption .caption-info p{font-size:16px;line-height:26px}body.home footer{padding:0 30px!important}body.home footer .footer-item{font-size:14px!important}body.home footer .footer-group{gap:15px!important}}@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(../asset/font/material-icons.woff2) format('woff2')}@font-face{font-family:Roboto;font-style:normal;font-weight:100;src:url(../asset/font/roboto-thin.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:300;src:url(../asset/font/roboto-light.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:400;src:url(../asset/font/roboto-regular.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:500;src:url(../asset/font/roboto-medium.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:600;src:url(../asset/font/roboto-bold.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:900;src:url(../asset/font/roboto-black.ttf) format('truetype')}@media (prefers-color-scheme:light){body.home{background:#fff}body.home header{background-image:url(../asset/img/background.png)}body.home header .brand-logo a{background-image:url(../asset/img/brand-logo.png)}body.home header .logo{background-image:url(../asset/img/logo.png);background-position:center}body.home header h1.headline{color:#2D3842}body.home header p.description{color:#9FA2AD}body.home header p.description b{color:#0372EF}body.home main{background:#fff}body.home footer{background:#F5F5F5}body.home footer .footer-item{color:#9FA2AD}body.home button.button.button-prime{background:#0372EF;color:#fafafa}body.home button.button.button-prime:hover{background:#036de5;color:#fff}body.home button.button.button-default{background:#fff;color:#838796}body.home button.button.button-default:hover{color:#767a8a}body.home button.button.button-prime-light{background:rgba(3,114,239,.1);color:#1f87fc}body.home button.button.button-prime-light:hover{background:rgba(3,114,239,.13);color:#0372EF}body.home .badge-version{background:#e4e5e8;color:#2D3842}body.home .caption h2.caption-headline{color:#2D3842}body.home .caption h2.caption-headline b{color:#0372EF}body.home .caption .caption-info p{color:#9FA2AD}}@media (prefers-color-scheme:dark){body.home{background:#333C41}body.home header{background-image:url(../asset/img/background-dark.png)}body.home header .brand-logo a{background-image:url(../asset/img/brand-logo-dark.png)}body.home header .logo{background-image:url(../asset/img/logo-dark.png);background-position:center}body.home header h1.headline{color:#fff}body.home header p.description{color:#E0E0E0}body.home header p.description b{color:#0372EF}body.home main{background:#333C41}body.home footer{background:#2D353A}body.home footer .footer-item{color:#adadad}body.home button.button.button-prime{background:#0372EF;color:#fafafa}body.home button.button.button-prime:hover{background:#036de5;color:#fff}body.home button.button.button-default{background:#1d2326;color:#E0E0E0}body.home button.button.button-default:hover{background:#1b2023;color:#fafafa}body.home button.button.button-prime-light{background:rgba(3,114,239,.1);color:#1f87fc}body.home button.button.button-prime-light:hover{background:rgba(3,114,239,.13);color:#3392fc}body.home .badge-version{background:#2D353A;color:#E0E0E0}body.home .caption h2.caption-headline{color:#fff}body.home .caption h2.caption-headline b{color:#0372EF}body.home .caption .caption-info p{color:#E0E0E0}}body.app,html.app{overflow:hidden}a#download{opacity:0;width:0;height:0;user-select:none;pointer-events:none}.wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:#fff;z-index:999}.header-list{width:100%;height:60px;background:#fff;border-bottom:1px solid #F1F1F1;display:flex;flex-direction:column;pointer-events:all}.header-list .mainbar,.header-list .sidebar{width:100%;display:flex;justify-content:space-between;padding:8px 14px;min-height:60px;height:60px}.header-list .mainbar.inactive .action-item,.header-list .mainbar.inactive .option-item,.header-list .mainbar.inactive .tool-item,.header-list .sidebar.inactive .action-item,.header-list .sidebar.inactive .option-item,.header-list .sidebar.inactive .tool-item{pointer-events:none!important}.header-list .mainbar .action ul,.header-list .mainbar .option ul,.header-list .mainbar .tool ul,.header-list .sidebar .action ul,.header-list .sidebar .option ul,.header-list .sidebar .tool ul{list-style-type:none;display:flex;gap:10px}.header-list .mainbar .action ul li,.header-list .mainbar .option ul li,.header-list .mainbar .tool ul li,.header-list .sidebar .action ul li,.header-list .sidebar .option ul li,.header-list .sidebar .tool ul li{width:44px;height:44px;padding:10px;border-radius:22px;cursor:pointer;pointer-events:all}.header-list .mainbar .action ul li.placeholder,.header-list .mainbar .option ul li.placeholder,.header-list .mainbar .tool ul li.placeholder,.header-list .sidebar .action ul li.placeholder,.header-list .sidebar .option ul li.placeholder,.header-list .sidebar .tool ul li.placeholder{pointer-events:none}.header-list .mainbar .action ul li:not(.inactive):not(.active):hover,.header-list .mainbar .option ul li:not(.inactive):not(.active):hover,.header-list .mainbar .tool ul li:not(.inactive):not(.active):hover,.header-list .sidebar .action ul li:not(.inactive):not(.active):hover,.header-list .sidebar .option ul li:not(.inactive):not(.active):hover,.header-list .sidebar .tool ul li:not(.inactive):not(.active):hover{background:rgba(250,250,250,.95)}.header-list .mainbar .action ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .mainbar .option ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .mainbar .tool ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .sidebar .action ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .sidebar .option ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .sidebar .tool ul li:not(.inactive):not(.active):hover.ripple.ripple-active{background:rgba(245,245,245,.95)}.header-list .mainbar .action ul li.active,.header-list .mainbar .option ul li.active,.header-list .mainbar .tool ul li.active,.header-list .sidebar .action ul li.active,.header-list .sidebar .option ul li.active,.header-list .sidebar .tool ul li.active{background:rgba(238,238,238,.95)}.header-list .mainbar .action ul li.active.ripple.ripple-active,.header-list .mainbar .option ul li.active.ripple.ripple-active,.header-list .mainbar .tool ul li.active.ripple.ripple-active,.header-list .sidebar .action ul li.active.ripple.ripple-active,.header-list .sidebar .option ul li.active.ripple.ripple-active,.header-list .sidebar .tool ul li.active.ripple.ripple-active{background:rgba(233,233,233,.95)}.header-list .mainbar .action ul li.inactive i.ico,.header-list .mainbar .option ul li.inactive i.ico,.header-list .mainbar .tool ul li.inactive i.ico,.header-list .sidebar .action ul li.inactive i.ico,.header-list .sidebar .option ul li.inactive i.ico,.header-list .sidebar .tool ul li.inactive i.ico{color:#E0E0E0}.header-list .mainbar .action ul li i.ico,.header-list .mainbar .option ul li i.ico,.header-list .mainbar .tool ul li i.ico,.header-list .sidebar .action ul li i.ico,.header-list .sidebar .option ul li i.ico,.header-list .sidebar .tool ul li i.ico{color:#555}#canvas,#overlay,.controls{position:fixed;top:0;left:0;right:0;bottom:0}#overlay{pointer-events:none}.badge{display:inline-block;margin-top:-1px;margin-left:5px;padding:2px 4px;border-radius:2px;font-weight:500;font-size:12px;color:#fff!important}.badge.prime{background:#0372EF}.badge.beta{background:#388E3C}.key{display:inline-block;padding:3px 8px;border-radius:3px;color:#757575;font-weight:500;background:#FAFAFA;border:1px solid #E0E0E0}.key.round{border-radius:999px}.key.ico{padding:2px;max-width:28px;max-height:27px;display:flex;justify-content:center;align-items:center}.key.ico i.ico{padding:2px;max-width:28px}.button{display:block;height:44px;padding:0 22px;border:none;border-radius:4px;background:#F5F5F5;color:#24292E;font-size:16px}.button:hover.ripple-active{background:#f0f0f0}.button.outline{border:1px solid #F1F1F1;background:0 0}.button.outline:hover.ripple-active{background:#fafafa}.button.prime{background:#0372EF;color:#fff}.button.prime:hover.ripple-active{background:#036de5}.button.danger{background:#E53935;color:#fff}.button.danger:hover.ripple-active{background:#e4302c}.notification{top:90px;position:fixed;display:flex;justify-content:center;width:100%;opacity:0;text-align:center;padding:0 30px}.notification p{display:inline-block;padding:10px 24px;border-radius:24px;background:#24292E;color:#fff;opacity:.95;user-select:none;pointer-events:none}.controls{pointer-events:none}.controls .hotbar{display:flex;position:fixed;left:calc(50% - 216px);bottom:30px;z-index:-1}.controls .hotbar.inactive .color{pointer-events:none!important}.controls .hotbar .color{margin:6px;width:60px;height:60px;border-radius:30px;background:#EEE;cursor:pointer;transition:transform .2s;transform:scale(.9);pointer-events:all}.controls .hotbar .color:not(.active):hover{transform:scale(1)}.controls .hotbar .color.focus{transform:scale(1)}.controls .hotbar .color.active{transform:scale(1.1)}.controls .pencil-modal{top:75px;left:120px}.controls .scale-modal{top:75px;left:70px;width:400px;height:60px}.controls .scale-modal input[type=range]{-webkit-appearance:none;width:calc(400px - 54px);margin-top:21px;margin-left:27px;height:6px;background:#EEE;border:none;border-radius:4px}.controls .scale-modal input[type=range]::-webkit-slider-runnable-track{-webkit-appearance:none}.controls .scale-modal input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;height:20px;width:20px;margin-top:0;background:#9E9E9E;border-radius:10px;cursor:pointer}.controls .scale-modal input[type=range]::-webkit-slider-thumb:hover{background:#757575}.controls .clear-modal{top:calc(50% - 75.5px);left:calc(50% - 175px);width:350px;padding:25px;display:flex;flex-direction:column}.controls .clear-modal .info{width:100%;font-size:20px;text-align:center;margin-bottom:25px;color:#24292E;user-select:none}.controls .clear-modal .align{display:flex;gap:15px}.controls .clear-modal .align .btn-cancel{width:50%;height:48px;border:none;border-radius:3px;font-size:16px;padding-top:1px}.controls .clear-modal .align .btn-apply{width:50%;height:48px;border:none;border-radius:3px;border-color:grey;font-size:16px;padding-top:1px}.controls .capture-modal{top:75px;left:15px}.controls .colors-modal{flex-wrap:wrap;min-width:418px;width:418px;max-width:418px;padding:30px!important;top:75px;left:15px;display:flex;gap:12px;max-height:calc(100vh - 90px);overflow-y:auto}.controls .colors-modal::-webkit-scrollbar{width:8px}.controls .colors-modal::-webkit-scrollbar-thumb{width:8px;background:#F1F1F1}.controls .colors-modal::-webkit-scrollbar-thumb:active,.controls .colors-modal::-webkit-scrollbar-thumb:hover{background:#E0E0E0}.controls .colors-modal .color{width:60px;height:60px;border-radius:30px;background:#EEE;cursor:pointer;transition:transform .2s;transform:scale(.9)}.controls .colors-modal .color:not(.active):hover{transform:scale(1)}.controls .colors-modal .color.active{transform:scale(1.1)}.controls .colors-modal .color.focus{transform:scale(1)}.controls .multiplayer-modal{top:75px;right:120px}.controls .account-modal{top:75px;right:70px}.controls .more-modal{top:75px;right:15px}.controls .help-modal{top:calc(50% - 250px);left:calc(50% - 400px);width:800px;height:500px;display:flex;padding:0}.controls .help-modal .side{border-right:1px solid #F1F1F1;width:230px;min-width:230px;overflow:hidden}.controls .help-modal .side ul.item-list{width:100%;padding:6px 0}.controls .help-modal .side ul.item-list li.item{display:flex;flex-direction:column}.controls .help-modal .side ul.item-list li.item .info{font-size:16px;width:100%;max-width:100%;margin-left:0}.controls .help-modal .content{padding:6px 0;overflow-y:auto}.controls .help-modal .content::-webkit-scrollbar{width:8px}.controls .help-modal .content::-webkit-scrollbar-thumb{width:8px;background:#F1F1F1}.controls .help-modal .content::-webkit-scrollbar-thumb:active,.controls .help-modal .content::-webkit-scrollbar-thumb:hover{background:#E0E0E0}.controls .help-modal .content ul.content-list{list-style-type:none;pointer-events:none}.controls .help-modal .content ul.content-list li.content-item{pointer-events:none;padding:15px 20px;padding-top:25px}.controls .help-modal .content ul.content-list li.content-item p{font-size:16px;color:#757575;line-height:20px;user-select:none;pointer-events:none;margin-bottom:40px}.controls .help-modal .content ul.content-list li.content-item h2{font-size:24px;font-weight:500;margin-bottom:20px;user-select:none;pointer-events:none;color:#555}.controls .help-modal .content ul.content-list li.content-item h3{font-size:22px;font-weight:500;margin-bottom:20px;user-select:none;pointer-events:none;color:#555}.modal{width:250px;position:fixed;background:#fff;border:1px solid #F1F1F1;border-radius:4px;padding:6px 0;pointer-events:all;overflow:hidden;z-index:-1;display:flex}.modal .main{width:248px;min-width:248px;7max-width:248px}.modal ul.tab-list{width:248px;min-width:248px;max-width:248px}.modal .header{display:flex;margin-bottom:3px}.modal .header .back{margin:10px;margin-top:15px;margin-right:3px;width:36px;height:36px;border-radius:18px;padding:6px;padding-left:5px;cursor:pointer}.modal .header .back i.ico{color:#424242}.modal .header .back:hover{background:#FAFAFA}.modal .header .back.ripple.ripple-active{background:#f5f5f5}.modal .header .info{display:flex;flex-direction:column;margin-top:15px;max-width:calc(100% - 24px - 10px - 35px)}.modal .header .info p{display:flex;align-items:center;font-weight:500;color:#555;user-select:none;pointer-events:none}.modal .header .info span{display:block;margin-top:3px;font-size:12px;color:#9E9E9E;user-select:none;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.modal ul.item-list .separator{margin:6px 0;width:100%;height:1px;background:#F1F1F1}.modal ul.item-list li.caption{padding:2px 15px;padding-top:12px;list-style:none}.modal ul.item-list li.caption p{color:#9E9E9E;user-select:none;pointer-events:none}.modal ul.item-list li.item{display:flex;align-items:center;padding:15px;cursor:pointer}.modal ul.item-list li.item.empty p{display:block;width:100%;color:#9E9E9E;text-align:center;user-select:none;pointer-events:none}.modal ul.item-list li.item:not(.active):not(.inactive):hover{background:#FAFAFA}.modal ul.item-list li.item:not(.active):not(.inactive).ripple.ripple-active{background:#f5f5f5}.modal ul.item-list li.item i.ico{color:#555;user-select:none;pointer-events:none}.modal ul.item-list li.item i.lang{display:flex;justify-content:center;align-items:center;font-style:normal;font-weight:600;width:24px;height:24px;color:#555;user-select:none;pointer-events:none}.modal ul.item-list li.item .info{display:flex;flex-direction:column;margin-left:10px;max-width:calc(100% - 24px - 10px)}.modal ul.item-list li.item .info p{display:flex;align-items:center;font-weight:500;color:#555;user-select:none;pointer-events:none}.modal ul.item-list li.item .info span{display:block;margin-top:3px;font-size:12px;color:#9E9E9E;user-select:none;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.modal ul.item-list li.item.active{background:#EEE}.modal ul.item-list li.item.active.ripple.ripple-active{background:#e9e9e9}.modal ul.item-list li.item.inactive i.ico{color:#E0E0E0}.modal ul.item-list li.item.inactive .info p{color:#9E9E9E}.modal ul.item-list li.item.inactive .info span{color:#9E9E9E}body.home .notification{top:50px;z-index:2}body.home .notification p.content{padding:10px 16px;border-radius:10px}body.home .row{display:flex;justify-content:center;gap:60px}body.home .container{max-width:1200px;margin:0 auto}body.home header{display:flex;justify-content:center;align-items:center;background-size:cover;height:calc(100vh - 54px);min-height:750px;padding:0 50px}body.home header .container .header-info{display:flex;flex-direction:column;align-items:center}body.home main{padding:0 50px}body.home main .container{display:flex;flex-direction:column;gap:100px;padding:200px 0}body.home footer{display:flex;align-items:center;justify-content:space-between;height:54px;padding:0 30px}body.home footer .footer-item{font-size:16px}body.home footer a.footer-item{text-decoration:none}body.home footer a.footer-item:hover{text-decoration:underline}body.home footer .footer-group{display:flex;gap:25px}body.home .brand-logo{display:none;position:fixed;top:50px;left:50px}body.home .brand-logo a{display:inline-block;width:44px;height:44px}body.home .logo{width:200px;height:200px;min-width:200px;min-height:200px;max-width:200px;max-height:200px;border-radius:100px;box-shadow:0 0 15px 0 rgba(0,0,0,.1);margin:0 auto;margin-bottom:35px}body.home h1.headline{font-size:70px;font-weight:600;text-align:center;margin-bottom:15px}body.home p.description{font-size:20px;font-weight:400;text-align:center;max-width:550px;margin-bottom:20px;line-height:28px}body.home p.description b{font-weight:inherit}body.home .badge-version{margin-bottom:60px}1
\ No newline at end of file1
*{margin:0;padding:0;font-family:Roboto,sans-serif;box-sizing:border-box;-webkit-tap-highlight-color:transparent}:focus,:hover{outline:0}html{position:relative;overflow-x:hidden;min-height:100vh}body{width:100%;font-size:14px;min-height:100vh}img{pointer-events:none;user-select:none}input{-webkit-appearance:none}button{user-select:none;cursor:pointer}.hidden{display:none!important}.transparent{opacity:0!important}.ico{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga';user-select:none;pointer-events:none}.tooltip{position:relative;display:flex;justify-content:center;align-items:center}.tooltip:hover::before{opacity:.95;transition-delay:.6s}.tooltip:hover::after{opacity:.95;transition-delay:.6s}.tooltip::after{display:flex;opacity:0;content:attr(data-title);justify-content:center;align-items:center;position:absolute;background:#24292E;color:#fff;min-height:24px;padding:0 12px;border-radius:999px;font-size:12px;top:auto;bottom:-64%;white-space:nowrap;z-index:9999;pointer-events:none}body.home button.button:not(.accept){display:inline-flex;justify-content:center;align-items:center;box-shadow:0 0 20px 0 rgba(0,0,0,.05);border:none;border-radius:5px;height:48px;max-height:48px;min-width:180px;font-size:16px}body.home button.button:not(.accept):hover{box-shadow:0 0 20px 0 rgba(0,0,0,.08)}body.home button.button:not(.accept).button-prime-light{height:40px;max-height:40px;min-width:110px}body.home .caption{display:flex;flex-wrap:nowrap;gap:40px}body.home .caption h2.caption-headline{flex:35%;font-weight:500;font-size:30px;white-space:nowrap}body.home .caption h2.caption-headline b{font-weight:inherit}body.home .caption .caption-info{flex:65%;display:flex;flex-direction:column;align-items:flex-start;gap:30px}body.home .caption .caption-info p{font-size:18px;font-weight:400;line-height:28px}body.home .badge-version{padding:3px 6px;text-decoration:none;border-radius:3px;font-weight:500;font-size:16px;user-select:none}@media (max-width:1024px){body.home header .logo{width:140px;height:140px;min-width:140px;min-height:140px;max-width:140px;max-height:140px;background-size:160px 160px;margin-bottom:25px}body.home header h1.headline{font-size:50px}body.home header p.description{font-size:18px;line-height:26px;margin-bottom:20px}body.home header .badge.badge-version{margin-bottom:40px}body.home .caption{flex-wrap:wrap}}@media (max-width:768px){body.home header p.description{padding:0!important}}@media (max-width:425px){body.home header{padding:0 30px!important}body.home header h1.headline{font-size:40px}body.home header .row{flex-direction:column;justify-content:flex-start;align-items:center;gap:20px}body.home header .row button{min-width:240px}body.home main{padding:0 30px!important}body.home main .container{padding:100px 0!important;padding-top:60px!important;gap:80px!important}body.home main .caption{gap:30px}body.home main .caption h2.caption-headline{font-size:28px}body.home main .caption .caption-info p{font-size:16px;line-height:26px}body.home footer{padding:0 30px!important}body.home footer .footer-item{font-size:14px!important}body.home footer .footer-group{gap:15px!important}}@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(../asset/font/material-icons.woff2) format('woff2')}@font-face{font-family:Roboto;font-style:normal;font-weight:100;src:url(../asset/font/roboto-thin.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:300;src:url(../asset/font/roboto-light.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:400;src:url(../asset/font/roboto-regular.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:500;src:url(../asset/font/roboto-medium.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:600;src:url(../asset/font/roboto-bold.ttf) format('truetype')}@font-face{font-family:Roboto;font-style:normal;font-weight:900;src:url(../asset/font/roboto-black.ttf) format('truetype')}@media (prefers-color-scheme:light){body.home{background:#fff}body.home header{background-image:url(../asset/img/background.png)}body.home header .brand-logo a{background-image:url(../asset/img/brand-logo.png)}body.home header .logo{background-image:url(../asset/img/logo.png);background-position:center}body.home header h1.headline{color:#2D3842}body.home header p.description{color:#9FA2AD}body.home header p.description b{color:#0372EF}body.home main{background:#fff}body.home footer{background:#F5F5F5}body.home footer .footer-item{color:#9FA2AD}body.home button.button.button-prime{background:#0372EF;color:#fafafa}body.home button.button.button-prime:hover{background:#036de5;color:#fff}body.home button.button.button-default{background:#fff;color:#838796}body.home button.button.button-default:hover{color:#767a8a}body.home button.button.button-prime-light{background:rgba(3,114,239,.1);color:#1f87fc}body.home button.button.button-prime-light:hover{background:rgba(3,114,239,.13);color:#0372EF}body.home .badge-version{background:#e4e5e8;color:#2D3842}body.home .caption h2.caption-headline{color:#2D3842}body.home .caption h2.caption-headline b{color:#0372EF}body.home .caption .caption-info p{color:#9FA2AD}}@media (prefers-color-scheme:dark){body.home{background:#333C41}body.home header{background-image:url(../asset/img/background-dark.png)}body.home header .brand-logo a{background-image:url(../asset/img/brand-logo-dark.png)}body.home header .logo{background-image:url(../asset/img/logo-dark.png);background-position:center}body.home header h1.headline{color:#fff}body.home header p.description{color:#E0E0E0}body.home header p.description b{color:#0372EF}body.home main{background:#333C41}body.home footer{background:#2D353A}body.home footer .footer-item{color:#adadad}body.home button.button.button-prime{background:#0372EF;color:#fafafa}body.home button.button.button-prime:hover{background:#036de5;color:#fff}body.home button.button.button-default{background:#1d2326;color:#E0E0E0}body.home button.button.button-default:hover{background:#1b2023;color:#fafafa}body.home button.button.button-prime-light{background:rgba(3,114,239,.1);color:#1f87fc}body.home button.button.button-prime-light:hover{background:rgba(3,114,239,.13);color:#3392fc}body.home .badge-version{background:#2D353A;color:#E0E0E0}body.home .caption h2.caption-headline{color:#fff}body.home .caption h2.caption-headline b{color:#0372EF}body.home .caption .caption-info p{color:#E0E0E0}}body.app,html.app{overflow:hidden}a#download{opacity:0;width:0;height:0;user-select:none;pointer-events:none}.wrapper{position:fixed;top:0;left:0;right:0;bottom:0;background:#fff;z-index:999}.header-list{width:100%;height:60px;background:#fff;border-bottom:1px solid #F1F1F1;display:flex;flex-direction:column;pointer-events:all}.header-list .mainbar,.header-list .sidebar{width:100%;display:flex;justify-content:space-between;padding:8px 14px;min-height:60px;height:60px}.header-list .mainbar.inactive .action-item,.header-list .mainbar.inactive .option-item,.header-list .mainbar.inactive .tool-item,.header-list .sidebar.inactive .action-item,.header-list .sidebar.inactive .option-item,.header-list .sidebar.inactive .tool-item{pointer-events:none!important}.header-list .mainbar .action ul,.header-list .mainbar .option ul,.header-list .mainbar .tool ul,.header-list .sidebar .action ul,.header-list .sidebar .option ul,.header-list .sidebar .tool ul{list-style-type:none;display:flex;gap:10px}.header-list .mainbar .action ul li,.header-list .mainbar .option ul li,.header-list .mainbar .tool ul li,.header-list .sidebar .action ul li,.header-list .sidebar .option ul li,.header-list .sidebar .tool ul li{width:44px;height:44px;padding:10px;border-radius:22px;cursor:pointer;pointer-events:all}.header-list .mainbar .action ul li.placeholder,.header-list .mainbar .option ul li.placeholder,.header-list .mainbar .tool ul li.placeholder,.header-list .sidebar .action ul li.placeholder,.header-list .sidebar .option ul li.placeholder,.header-list .sidebar .tool ul li.placeholder{pointer-events:none}.header-list .mainbar .action ul li:not(.inactive):not(.active):hover,.header-list .mainbar .option ul li:not(.inactive):not(.active):hover,.header-list .mainbar .tool ul li:not(.inactive):not(.active):hover,.header-list .sidebar .action ul li:not(.inactive):not(.active):hover,.header-list .sidebar .option ul li:not(.inactive):not(.active):hover,.header-list .sidebar .tool ul li:not(.inactive):not(.active):hover{background:rgba(250,250,250,.95)}.header-list .mainbar .action ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .mainbar .option ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .mainbar .tool ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .sidebar .action ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .sidebar .option ul li:not(.inactive):not(.active):hover.ripple.ripple-active,.header-list .sidebar .tool ul li:not(.inactive):not(.active):hover.ripple.ripple-active{background:rgba(245,245,245,.95)}.header-list .mainbar .action ul li.active,.header-list .mainbar .option ul li.active,.header-list .mainbar .tool ul li.active,.header-list .sidebar .action ul li.active,.header-list .sidebar .option ul li.active,.header-list .sidebar .tool ul li.active{background:rgba(238,238,238,.95)}.header-list .mainbar .action ul li.active.ripple.ripple-active,.header-list .mainbar .option ul li.active.ripple.ripple-active,.header-list .mainbar .tool ul li.active.ripple.ripple-active,.header-list .sidebar .action ul li.active.ripple.ripple-active,.header-list .sidebar .option ul li.active.ripple.ripple-active,.header-list .sidebar .tool ul li.active.ripple.ripple-active{background:rgba(233,233,233,.95)}.header-list .mainbar .action ul li.inactive i.ico,.header-list .mainbar .option ul li.inactive i.ico,.header-list .mainbar .tool ul li.inactive i.ico,.header-list .sidebar .action ul li.inactive i.ico,.header-list .sidebar .option ul li.inactive i.ico,.header-list .sidebar .tool ul li.inactive i.ico{color:#E0E0E0}.header-list .mainbar .action ul li i.ico,.header-list .mainbar .option ul li i.ico,.header-list .mainbar .tool ul li i.ico,.header-list .sidebar .action ul li i.ico,.header-list .sidebar .option ul li i.ico,.header-list .sidebar .tool ul li i.ico{color:#555}#canvas,#overlay,.controls{position:fixed;top:0;left:0;right:0;bottom:0}#overlay{pointer-events:none}.badge{display:inline-block;margin-top:-1px;margin-left:5px;padding:2px 4px;border-radius:2px;font-weight:500;font-size:12px;color:#fff!important}.badge.prime{background:#0372EF}.badge.beta{background:#388E3C}.key{display:inline-block;padding:3px 8px;border-radius:3px;color:#757575;font-weight:500;background:#FAFAFA;border:1px solid #E0E0E0}.key.round{border-radius:999px}.key.ico{padding:2px;max-width:28px;max-height:27px;display:flex;justify-content:center;align-items:center}.key.ico i.ico{padding:2px;max-width:28px}.button{display:block;height:44px;padding:0 22px;border:none;border-radius:4px;background:#F5F5F5;color:#24292E;font-size:16px}.button:hover.ripple-active{background:#f0f0f0}.button.outline{border:1px solid #F1F1F1;background:0 0}.button.outline:hover.ripple-active{background:#fafafa}.button.prime{background:#0372EF;color:#fff}.button.prime:hover.ripple-active{background:#036de5}.button.danger{background:#E53935;color:#fff}.button.danger:hover.ripple-active{background:#e4302c}.notification{top:90px;position:fixed;display:flex;justify-content:center;width:100%;opacity:0;text-align:center;padding:0 30px}.notification p{display:inline-block;padding:10px 24px;border-radius:24px;background:#24292E;color:#fff;opacity:.95;user-select:none;pointer-events:none}.controls{pointer-events:none}.controls .hotbar{display:flex;position:fixed;left:calc(50% - 216px);bottom:30px;z-index:-1}.controls .hotbar.inactive .color{pointer-events:none!important}.controls .hotbar .color{margin:6px;width:60px;height:60px;border-radius:30px;background:#EEE;cursor:pointer;transition:transform .2s;transform:scale(.9);pointer-events:all}.controls .hotbar .color:not(.active):hover{transform:scale(1)}.controls .hotbar .color.focus{transform:scale(1)}.controls .hotbar .color.active{transform:scale(1.1)}.controls .pencil-modal{top:75px;left:120px}.controls .scale-modal{top:75px;left:70px;width:400px;height:60px}.controls .scale-modal input[type=range]{-webkit-appearance:none;width:calc(400px - 54px);margin-top:21px;margin-left:27px;height:6px;background:#EEE;border:none;border-radius:4px}.controls .scale-modal input[type=range]::-webkit-slider-runnable-track{-webkit-appearance:none}.controls .scale-modal input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;height:20px;width:20px;margin-top:0;background:#9E9E9E;border-radius:10px;cursor:pointer}.controls .scale-modal input[type=range]::-webkit-slider-thumb:hover{background:#757575}.controls .clear-modal{top:calc(50% - 75.5px);left:calc(50% - 175px);width:350px;padding:25px;display:flex;flex-direction:column}.controls .clear-modal .info{width:100%;font-size:20px;text-align:center;margin-bottom:25px;color:#24292E;user-select:none}.controls .clear-modal .align{display:flex;gap:15px}.controls .clear-modal .align .btn-cancel{width:50%;height:48px;border:none;border-radius:3px;font-size:16px;padding-top:1px}.controls .clear-modal .align .btn-apply{width:50%;height:48px;border:none;border-radius:3px;border-color:grey;font-size:16px;padding-top:1px}.controls .capture-modal{top:75px;left:15px}.controls .colors-modal{flex-wrap:wrap;min-width:418px;width:418px;max-width:418px;padding:30px!important;top:75px;left:15px;display:flex;gap:12px;max-height:calc(100vh - 90px);overflow-y:auto}.controls .colors-modal::-webkit-scrollbar{width:8px}.controls .colors-modal::-webkit-scrollbar-thumb{width:8px;background:#F1F1F1}.controls .colors-modal::-webkit-scrollbar-thumb:active,.controls .colors-modal::-webkit-scrollbar-thumb:hover{background:#E0E0E0}.controls .colors-modal .color{width:60px;height:60px;border-radius:30px;background:#EEE;cursor:pointer;transition:transform .2s;transform:scale(.9)}.controls .colors-modal .color:not(.active):hover{transform:scale(1)}.controls .colors-modal .color.active{transform:scale(1.1)}.controls .colors-modal .color.focus{transform:scale(1)}.controls .multiplayer-modal{top:75px;right:120px}.controls .account-modal{top:75px;right:70px}.controls .more-modal{top:75px;right:15px}.controls .help-modal{top:calc(50% - 250px);left:calc(50% - 400px);width:800px;height:500px;display:flex;padding:0}.controls .help-modal .side{border-right:1px solid #F1F1F1;width:230px;min-width:230px;overflow:hidden}.controls .help-modal .side ul.item-list{width:100%;padding:6px 0}.controls .help-modal .side ul.item-list li.item{display:flex;flex-direction:column}.controls .help-modal .side ul.item-list li.item .info{font-size:16px;width:100%;max-width:100%;margin-left:0}.controls .help-modal .content{padding:6px 0;overflow-y:auto}.controls .help-modal .content::-webkit-scrollbar{width:8px}.controls .help-modal .content::-webkit-scrollbar-thumb{width:8px;background:#F1F1F1}.controls .help-modal .content::-webkit-scrollbar-thumb:active,.controls .help-modal .content::-webkit-scrollbar-thumb:hover{background:#E0E0E0}.controls .help-modal .content ul.content-list{list-style-type:none;pointer-events:none}.controls .help-modal .content ul.content-list li.content-item{pointer-events:none;padding:15px 20px;padding-top:25px}.controls .help-modal .content ul.content-list li.content-item p{font-size:16px;color:#757575;line-height:20px;user-select:none;pointer-events:none;margin-bottom:40px}.controls .help-modal .content ul.content-list li.content-item h2{font-size:24px;font-weight:500;margin-bottom:20px;user-select:none;pointer-events:none;color:#555}.controls .help-modal .content ul.content-list li.content-item h3{font-size:22px;font-weight:500;margin-bottom:20px;user-select:none;pointer-events:none;color:#555}.modal{width:250px;position:fixed;background:#fff;border:1px solid #F1F1F1;border-radius:4px;padding:6px 0;pointer-events:all;overflow:hidden;z-index:-1;display:flex}.modal .main{width:248px;min-width:248px;7max-width:248px}.modal ul.tab-list{width:248px;min-width:248px;max-width:248px}.modal .header{display:flex;margin-bottom:3px}.modal .header .back{margin:10px;margin-top:15px;margin-right:3px;width:36px;height:36px;border-radius:18px;padding:6px;padding-left:5px;cursor:pointer}.modal .header .back i.ico{color:#424242}.modal .header .back:hover{background:#FAFAFA}.modal .header .back.ripple.ripple-active{background:#f5f5f5}.modal .header .info{display:flex;flex-direction:column;margin-top:15px;max-width:calc(100% - 24px - 10px - 35px)}.modal .header .info p{display:flex;align-items:center;font-weight:500;color:#555;user-select:none;pointer-events:none}.modal .header .info span{display:block;margin-top:3px;font-size:12px;color:#9E9E9E;user-select:none;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.modal ul.item-list .separator{margin:6px 0;width:100%;height:1px;background:#F1F1F1}.modal ul.item-list li.caption{padding:2px 15px;padding-top:12px;list-style:none}.modal ul.item-list li.caption p{color:#9E9E9E;user-select:none;pointer-events:none}.modal ul.item-list li.item{display:flex;align-items:center;padding:15px;cursor:pointer}.modal ul.item-list li.item.empty p{display:block;width:100%;color:#9E9E9E;text-align:center;user-select:none;pointer-events:none}.modal ul.item-list li.item:not(.active):not(.inactive):hover{background:#FAFAFA}.modal ul.item-list li.item:not(.active):not(.inactive).ripple.ripple-active{background:#f5f5f5}.modal ul.item-list li.item i.ico{color:#555;user-select:none;pointer-events:none}.modal ul.item-list li.item i.lang{display:flex;justify-content:center;align-items:center;font-style:normal;font-weight:600;width:24px;height:24px;color:#555;user-select:none;pointer-events:none}.modal ul.item-list li.item .info{display:flex;flex-direction:column;margin-left:10px;max-width:calc(100% - 24px - 10px)}.modal ul.item-list li.item .info p{display:flex;align-items:center;font-weight:500;color:#555;user-select:none;pointer-events:none}.modal ul.item-list li.item .info span{display:block;margin-top:3px;font-size:12px;color:#9E9E9E;user-select:none;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.modal ul.item-list li.item.active{background:#EEE}.modal ul.item-list li.item.active.ripple.ripple-active{background:#e9e9e9}.modal ul.item-list li.item.inactive i.ico{color:#E0E0E0}.modal ul.item-list li.item.inactive .info p{color:#9E9E9E}.modal ul.item-list li.item.inactive .info span{color:#9E9E9E}body.home .notification{top:50px;z-index:2}body.home .notification p.content{padding:10px 16px;border-radius:10px}body.home .row{display:flex;justify-content:center;gap:60px}body.home .container{max-width:1200px;margin:0 auto}body.home header{display:flex;justify-content:center;align-items:center;background-size:cover;height:calc(100vh - 54px);min-height:750px;padding:0 50px}body.home header .container .header-info{display:flex;flex-direction:column;align-items:center}body.home main{padding:0 50px}body.home main .container{display:flex;flex-direction:column;gap:100px;padding:200px 0}body.home footer{display:flex;align-items:center;justify-content:space-between;height:54px;padding:0 30px}body.home footer .footer-item{font-size:16px}body.home footer a.footer-item{text-decoration:none}body.home footer a.footer-item:hover{text-decoration:underline}body.home footer .footer-group{display:flex;gap:25px}body.home .brand-logo{display:none;position:fixed;top:50px;left:50px}body.home .brand-logo a{display:inline-block;width:44px;height:44px}body.home .logo{width:200px;height:200px;min-width:200px;min-height:200px;max-width:200px;max-height:200px;border-radius:100px;box-shadow:0 0 15px 0 rgba(0,0,0,.1);margin:0 auto;margin-bottom:35px}body.home h1.headline{font-size:70px;font-weight:600;text-align:center;margin-bottom:15px}body.home p.description{font-size:20px;font-weight:400;text-align:center;max-width:550px;margin-bottom:20px;line-height:28px}body.home p.description b{font-weight:inherit}body.home .badge-version{margin-bottom:60px}.cookie{display:flex;position:fixed;bottom:43px;align-items:center;justify-content:space-between;padding:14px 24px;background:#0372EF;border-radius:4px;width:800px;border:1px solid #0372EF;z-index:999;left:calc(50vw - 400px);gap:20px}.cookie p{font-size:16px;color:#fff;user-select:none;pointer-events:none;align-content:flex-start;line-height:24px}.cookie button.button.accept{font-size:16px;font-weight:500;color:#fff;white-space:nowrap;user-select:none;background:inherit}.cookie button.button.accept:hover{background:rgba(0,0,0,.05)}.cookie .group{display:inline-flex;align-items:center;gap:15px}.cookie a{font-size:16px;color:#fff;white-space:nowrap;user-select:none;text-decoration:none}.cookie a:hover{text-decoration:underline}1
\ No newline at end of file
23
<title>Outline</title>24
<link href="./asset/img/favicon.png" rel="shortcut icon" type="image/png">25
<link href="./css/style.css" rel="stylesheet">26
<script src="https://www.gstatic.com/firebasejs/7.21.0/firebase-app.js"></script>27
<script src="https://www.gstatic.com/firebasejs/7.21.0/firebase-analytics.js"></script>28
<script src="./js/index.js" type="module"></script>29
</head>30
<body class="home">31
<div class="cookie hidden">32
<p data-lang="main.cookie.info">We use cookies to give you the best possible user experience.</p>33
<div class="group">34
<button class="button accept" data-lang="main.cookie.submit">Accept</button>35
<a href="https://typable.dev/terms" data-lang="main.cookie.more">Learn more</a>36
</div>37
</div>38
<div class="notification">39
<p class="content"></p>40
</div>
1
import { FIREBASE, COLORS, PRIORITY_MODAL, LOCALES } from './constant.js';2
import { uuid, query, prevent } from './util.js';4
import locale from './mod/locale.js';5
import canvas from './mod/canvas.js';6
import cookie from './mod/cookie.js';8
let node;9
let state = {10
color: 54,11
color_list: [54, 2, 17, 27, 37, 12],12
radius: 14,13
region: [],14
crop: false,15
index: 0,16
device: null,17
device_fallback: null,18
device_list: {19
mouse: false,20
touch: false,21
pen: false,22
gamepad: false23
},24
pencil_list: [25
'pen',26
'marker',27
'eraser'28
],29
pencil: 'pen',30
timestamp: null,31
modal: null,32
tab: null,33
caption: null,34
option: {35
view_mode: false,36
crop_mode: false37
},38
history: [],39
redo_history: []40
};42
export function init() {44
locale.init();45
locale.load('./asset/lang', LOCALES);46
canvas.init();48
node = query({49
wrapper: '.wrapper',50
controls: '.controls',51
modal_list: { query: '.modal', all: true },52
tab_list: { query: '.tab', all: true },53
header: '.header-list',54
hotbar: '.hotbar',55
hotbar_list: { query: '.hotbar .color', all: true },56
modal_color_list: { query: '.colors-modal .color', all: true },57
language_list: { query: '.more-modal .language-tab .item[data-event="change.language"]', all: true },58
device_list: { query: '.more-modal .device-tab .item[data-event="change.device"]', all: true },59
pencil_list: { query: '.pencil-modal .item[data-event="change.pencil"]', all: true },60
modal_event_list: { query: '[data-event*=".modal"]', all: true },61
tab_event_list: { query: '[data-event*=".tab"]', all: true },62
capture_event_list: { query: '[data-event*=".capture"]', all: true },63
tool_list: { query: '.tool', all: true },64
action_list: { query: '.action', all: true },65
notification: '.notification',66
scale_input: 'input.scale[type="range"]',67
clear: 'button.btn-apply[data-event="clear"]',68
pencil_tool: '.tool-item[data-code="pencil"]',69
option_event_fullscreen: '[data-event="toggle.fullscreen"]',70
option_event_view_mode: '[data-event="toggle.view-mode"]',71
undo_tool: '[data-lang="action.undo"]',72
redo_tool: '[data-lang="action.redo"]',73
colors_modal: '.colors-modal',74
mainbar: '.mainbar',75
sidebar: '.sidebar',76
edit_mode: '[data-event="close.view-mode"]',77
content: '.modal .content',78
caption_list: { query: '[data-event="open.content"]' , all: true },79
content_list: { query: '.content-item' , all: true },80
download: '#download',81
cookie: '.cookie',82
accept: '.button.accept'83
});85
fill_hotbar_list();86
fill_modal_color_list();88
bind_events(locale);90
node.wrapper.animate([91
{ opacity: 1 },92
{ opacity: 0, pointerEvents: 'none' }93
], {94
delay: 100,95
duration: 500,96
fill: 'both'97
});98
node.hotbar.animate([99
{ opacity: 0, bottom: '-10px' },100
{ opacity: 1 }101
], {102
delay: 600,103
easing: 'ease-out',104
duration: 250,105
fill: 'both'106
});108
if(!cookie.hasAccepted()) {109
node.cookie.classList.remove('hidden');110
cookie.requestPermission(node.accept)111
.then(function() {112
node.cookie.classList.add('hidden');113
try {114
firebase.initializeApp(FIREBASE);115
firebase.analytics();116
}117
catch(error) {118
console.warn('Unable to load Google Analytics!');119
}120
});121
}122
}124
function bind_events(locale) {125
document.addEventListener('dragstart', prevent);126
document.addEventListener('contextmenu', prevent);127
document.addEventListener('pointerdown', on_pointerdown);128
document.addEventListener('pointermove', on_pointermove);129
document.addEventListener('pointerup', on_pointerup);130
document.addEventListener('pointerout', on_pointerout);131
document.addEventListener('keydown', on_keydown);132
document.addEventListener('wheel', on_wheel);133
document.addEventListener('wheel', function(event) {134
if(event.ctrlKey) {135
prevent(event);136
}137
}, { passive: false });138
document.addEventListener('touchmove', function(event) {139
if(event.target !== node.scale_input && event.target !== node.colors_modal && !node.modal_color_list.includes(event.target) && event.target !== node.content) {140
event.preventDefault();141
}142
}, { passive: false });144
for(let item of node.language_list) {145
item.addEventListener('click', function(event) {146
let code = item.dataset.code;147
locale.change(code);148
update_language_list();149
});150
}151
for(let item of node.device_list) {152
item.addEventListener('click', function(event) {153
let code = item.dataset.code;154
if(state.device_list[code]) {155
state.device = code;156
update_device_list();157
}158
});159
}160
for(let item of node.pencil_list) {161
item.addEventListener('click', function(event) {162
state.pencil = item.dataset.code;163
update_pencil_list();164
state.modal = null;165
update_modal_list();166
});167
}168
for(let item of node.modal_event_list) {169
item.addEventListener('click', function(event) {170
let code = item.dataset.code;171
let match = /^(toggle|open|close).modal$/.exec(item.dataset.event);172
if(match) {173
if(!item.classList.contains('inactive')) {174
switch(match[1]) {175
case 'toggle':176
if(code) {177
state.modal = state.modal !== code ? code : null;178
update_modal_list();179
}180
break;181
case 'open':182
if(code && state.modal !== code) {183
state.modal = code;184
update_modal_list();185
}186
break;187
case 'close':188
if(state.modal !== null) {189
state.modal = null;190
update_modal_list();191
}192
break;193
default:194
break;195
}196
}197
}198
});199
}200
for(let item of node.tab_event_list) {201
item.addEventListener('click', function(event) {202
let code = item.dataset.code;203
let match = /^(open|close).tab/.exec(item.dataset.event);204
if(match) {205
switch(match[1]) {206
case 'open':207
if(code && state.tab !== code) {208
state.tab = code;209
update_tab_list();210
}211
break;212
case 'close':213
if(state.tab !== null) {214
state.tab = null;215
update_tab_list();216
}217
break;218
default:219
break;220
}221
}222
});223
}224
for(let item of node.capture_event_list) {225
item.addEventListener('click', function(event) {226
let code = item.dataset.code;227
if(code === 'download') {228
if(state.option.crop_mode) {229
state.option.crop_mode = false;230
canvas.draw_crop(state);231
canvas.get_canvas().style.cursor = 'default';232
}233
let data = canvas.create_capture(0, 0, window.innerWidth, window.innerHeight, 60);234
if(data) {235
node.download.download = `outline-${uuid()}.png`;236
node.download.href = data;237
node.download.click();238
}239
else {240
console.warn('Unable to create capture from current state!');241
}242
}243
if(code === 'crop') {244
state.option.crop_mode = true;245
state.region = [];246
canvas.draw_crop(state);247
canvas.get_canvas().style.cursor = 'crosshair';248
}249
state.modal = null;250
state.tab = null;251
update_modal_list();252
})253
}254
node.scale_input.addEventListener('input', function(event) {255
state.radius = parseInt(node.scale_input.value);256
state.point = {257
x: parseInt(window.innerWidth / 2),258
y: parseInt(window.innerHeight / 2)259
};260
canvas.draw_cursor(state);261
});262
node.clear.addEventListener('click', function(event) {263
canvas.clear(state);264
update_undo_and_redo();265
show_notification('notification.clear');266
state.modal = null;267
update_modal_list();268
});269
node.option_event_fullscreen.addEventListener('click', function(event) {270
if(!document.fullscreenElement) {271
document.documentElement.requestFullscreen();272
}273
else if(document.exitFullscreen) {274
document.exitFullscreen();275
}276
});277
window.addEventListener('fullscreenchange', on_fullscreenchange);278
node.option_event_view_mode.addEventListener('click', function(event) {279
state.option.view_mode = !state.option.view_mode;280
update_view_mode_option();281
});282
node.undo_tool.addEventListener('click', function(event) {283
canvas.undo(state);284
update_undo_and_redo();285
});286
node.redo_tool.addEventListener('click', function(event) {287
canvas.redo(state);288
update_undo_and_redo();289
});290
node.edit_mode.addEventListener('click', function(event) {291
state.option.view_mode = false;292
update_view_mode_option();293
});294
for(let item of node.caption_list) {295
item.addEventListener('click', function(event) {296
state.caption = item.dataset.code;297
update_caption_list();298
});299
}301
window.addEventListener('beforeunload', function(event) {302
// ...303
});304
}306
function update_language_list() {307
let lang = locale.get_current();308
for(let item of node.language_list) {309
let code = item.dataset.code;310
item.classList[code === lang ? 'add' : 'remove']('active');311
}312
}314
function update_device_list() {315
if(!state.option.view_mode && !state.option.crop_mode) {316
canvas.get_canvas().style.cursor = state.device === 'mouse' ? 'none' : '';317
}318
for(let item of node.device_list) {319
let code = item.dataset.code;320
item.classList[code === state.device ? 'add' : 'remove']('active');321
item.classList[state.device_list[code] ? 'remove' : 'add']('inactive');322
}323
}325
function update_pencil_list() {326
for(let item of node.pencil_list) {327
let code = item.dataset.code;328
item.classList[code === state.pencil ? 'add' : 'remove']('active');329
if(code === state.pencil) {330
node.pencil_tool.querySelector('i.ico').innerHTML = item.querySelector('i.ico').innerHTML;331
}332
}333
}335
function update_hotbar() {336
for(let item of node.hotbar_list) {337
item.classList[node.hotbar_list[state.index] === item ? 'add' : 'remove']('active');338
}339
}341
function update_focus(bool) {342
for(let item of node.hotbar_list) {343
item.style.pointerEvents = bool ? '' : 'none';344
}345
for(let item of node.tool_list) {346
item.style.pointerEvents = bool ? '' : 'none';347
}348
for(let item of node.action_list) {349
item.style.pointerEvents = bool ? '' : 'none';350
}351
}353
function update_modal_list() {354
for(let item of node.modal_list) {355
item.classList.add('hidden');356
}357
for(let item of node.modal_event_list) {358
item.classList.remove('active');359
}360
state.tab = null;361
update_tab_list();362
state.caption = 'controls';363
update_caption_list();364
if(state.modal) {365
canvas.on_release(event, state, true);366
let modal = document.querySelector(`.modal.${state.modal}-modal`);367
let button = document.querySelector(`[data-event*=".modal"][data-code="${state.modal}"]`);368
if(modal) {369
modal.classList.remove('hidden');370
modal.animate([371
{ opacity: 0, marginTop: '-6px' },372
{ opacity: 1, marginTop: '0' }373
], {374
duration: 100,375
fill: 'both'376
});377
}378
if(button) {379
button.classList.add('active');380
}381
}382
}384
function update_tab_list() {385
for(let item of node.modal_list) {386
let main = item.querySelector('.main');387
if(main) {388
main.classList.remove('hidden');389
main.style.marginLeft = '0';390
}391
}392
for(let item of node.tab_list) {393
item.classList.add('hidden');394
}395
if(state.modal && state.tab) {396
let modal = document.querySelector(`.modal.${state.modal}-modal`);397
let tab = document.querySelector(`.${state.tab}-tab`);398
let main = modal.querySelector('.main');399
if(modal && tab && main) {400
tab.classList.remove('hidden');401
main.style.marginLeft = '-100%';402
main.classList.add('hidden');403
}404
}405
}407
function update_fullscreen_option() {408
let fullscreen = document.fullscreenElement;409
node.option_event_fullscreen.classList[fullscreen ? 'add' : 'remove']('active');410
node.option_event_fullscreen.querySelector('.ico').textContent = fullscreen ? 'toggle_on' : 'toggle_off';411
}413
function update_view_mode_option() {414
let view_mode = state.option.view_mode;415
show_notification(`notification.view-mode.${view_mode ? 'on' : 'off'}`);416
node.option_event_view_mode.classList[view_mode ? 'add' : 'remove']('active');417
node.option_event_view_mode.querySelector('.ico').textContent = view_mode ? 'toggle_on' : 'toggle_off';418
state.modal = null;419
state.tab = null;420
update_modal_list();421
if(view_mode) {422
canvas.on_release(null, state);423
canvas.clear_cursor();424
canvas.get_canvas().style.cursor = 'default';425
node.hotbar.classList.add('inactive');426
node.header.classList.add('inactive');427
node.hotbar.animate([428
{ opacity: 1 },429
{ opacity: 0, bottom: '-10px', pointerEvents: 'none' }430
], {431
easing: 'ease-out',432
duration: 250,433
fill: 'both'434
});435
node.mainbar.animate([436
{ opacity: 1, marginTop: 0 },437
{ opacity: 0, marginTop: '-60px' }438
], {439
easing: 'ease-out',440
duration: 250,441
fill: 'both'442
});443
node.sidebar.classList.remove('hidden');444
node.sidebar.animate([445
{ opacity: 0 },446
{ opacity: 1 }447
], {448
delay: 250,449
easing: 'ease-out',450
duration: 250,451
fill: 'both'452
});453
}454
else {455
state.option.crop_mode = false;456
canvas.draw_crop(state);457
canvas.on_release(null, state, true);458
canvas.get_canvas().style.cursor = 'none';459
node.hotbar.classList.remove('inactive');460
node.header.classList.remove('inactive');461
node.hotbar.animate([462
{ opacity: 0, bottom: '-10px' },463
{ opacity: 1, bottom: '30px' }464
], {465
easing: 'ease-out',466
duration: 250,467
fill: 'both'468
});469
node.mainbar.animate([470
{ opacity: 0, marginTop: '-60px' },471
{ opacity: 1, marginTop: 0 }472
], {473
easing: 'ease-out',474
duration: 250,475
fill: 'both'476
});477
node.sidebar.classList.add('hidden');478
}479
}481
function update_undo_and_redo() {482
node.undo_tool.classList[state.history.length > 0 ? 'remove' : 'add']('inactive');483
node.redo_tool.classList[state.redo_history.length > 0 ? 'remove' : 'add']('inactive');484
}486
function update_caption_list() {487
for(let item of node.caption_list) {488
let code = item.dataset.code;489
item.classList[code === state.caption ? 'add' : 'remove']('active');490
}491
for(let item of node.content_list) {492
let code = item.dataset.code;493
item.classList[code === state.caption ? 'remove' : 'add']('hidden');494
}495
}497
function on_pointerdown(event) {498
// detect touch499
if(!state.device_list.touch && event.pointerType === 'touch') {500
state.device_list.touch = true;501
if(state.device) {502
show_notification('notification.input-device.touch.add');503
}504
else {505
state.device = 'touch';506
state.device_fallback = 'touch';507
}508
update_device_list();509
}510
// detect pen511
if(!state.device_list.pen && event.pointerType === 'pen') {512
state.device_list.pen = true;513
show_notification('notification.input-device.pencil.add');514
if(!state.device) {515
state.device = 'pen';516
state.device_fallback = 'pen';517
}518
update_device_list();519
}520
// drawing521
if(!state.option.view_mode && state.device === event.pointerType) {522
if(event.target === canvas.get_canvas()) {523
if(!PRIORITY_MODAL.includes(state.modal)) {524
update_focus(false);525
canvas.on_press(event, state);526
update_undo_and_redo();527
state.point = {528
x: event.layerX,529
y: event.layerY530
};531
canvas.draw_cursor(state);532
}533
}534
}535
if(state.option.view_mode && state.option.crop_mode) {536
if(event.target === canvas.get_canvas()) {537
state.crop = true;538
state.region = [];539
state.region[0] = { x: event.layerX, y: event.layerY };540
canvas.draw_crop(state);541
}542
}543
}545
function on_pointermove(event) {546
// detect mouse547
if(!state.device_list.mouse && event.pointerType === 'mouse') {548
state.device_list.mouse = true;549
if(state.device) {550
show_notification('notification.input-device.mouse.add');551
}552
else {553
state.device = 'mouse';554
state.device_fallback = 'mouse';555
}556
update_device_list();557
}558
// drawing559
if(!state.option.view_mode && state.device === event.pointerType) {560
if(event.target === canvas.get_canvas()) {561
if(!PRIORITY_MODAL.includes(state.modal)) {562
canvas.on_move(event, state);563
}564
state.point = {565
x: event.layerX,566
y: event.layerY567
};568
}569
canvas.draw_cursor(state);570
}571
if(state.option.view_mode && state.option.crop_mode) {572
if(state.crop && event.target === canvas.get_canvas()) {573
state.region[1] = { x: event.layerX, y: event.layerY };574
canvas.draw_crop(state);575
}576
}577
}579
function on_pointerup(event) {580
if(!state.option.view_mode && state.device === event.pointerType) {581
canvas.on_release(event, state);582
update_undo_and_redo();583
update_focus(true);584
}585
if(state.option.view_mode && state.option.crop_mode) {586
if(state.crop && event.target === canvas.get_canvas()) {587
state.crop = false;588
state.region[1] = { x: event.layerX, y: event.layerY };589
canvas.draw_crop(state);590
let [ begin, end ] = state.region;591
let delta = {592
x: end.x - begin.x,593
y: end.y - begin.y594
};595
let x = begin.x < end.x ? begin.x : end.x;596
let y = begin.y < end.y ? begin.y : end.y;597
if(delta.x < 0) {598
delta.x *= -1;599
}600
if(delta.y < 0) {601
delta.y *= -1;602
}603
if(delta.x != 0 && delta.y != 0) {604
let data = canvas.create_capture(x, y, delta.x, delta.y);605
if(data) {606
node.download.download = `outline-${uuid()}.png`;607
node.download.href = data;608
node.download.click();609
state.option.crop_mode = false;610
canvas.draw_crop(state);611
canvas.get_canvas().style.cursor = 'default';612
}613
else {614
console.warn('Unable to create capture from current state!');615
}616
}617
}618
}619
}621
function on_pointerout(event) {622
if(!state.option.view_mode && state.device === event.pointerType) {623
canvas.on_release(event, state);624
update_undo_and_redo();625
state.point = null;626
canvas.draw_cursor(state);627
}628
if(state.option.view_mode && state.option.crop_mode) {629
if(state.crop && event.target === canvas.get_canvas()) {630
state.crop = false;631
state.region = [];632
canvas.draw_crop(state);633
}634
}635
}637
function on_keydown(event) {638
if(event.code === 'Escape') {639
if(state.tab) {640
state.tab = null;641
update_tab_list();642
return;643
}644
if(state.modal) {645
state.modal = null;646
update_modal_list();647
return;648
}649
if(state.option.view_mode && state.option.crop_mode) {650
state.option.crop_mode = false;651
canvas.draw_crop(state);652
canvas.get_canvas().style.cursor = 'default';653
}654
}655
if(!event.ctrlKey && !event.shiftKey && !event.altKey) {656
if(!state.option.view_mode) {657
if(event.code.startsWith('Digit')) {658
let i = parseInt(event.code.substr(5)) - 1;659
if(state.index !== i) {660
if(i >= 0 && i < state.color_list.length) {661
canvas.on_release(event, state);662
state.color = state.color_list[i];663
state.index = i;664
canvas.draw_cursor(state);665
update_hotbar();666
}667
}668
}669
if(event.code === 'KeyZ') {670
state.modal = state.modal !== 'colors' ? 'colors' : null;671
update_modal_list();672
}673
if(event.code === 'KeyX') {674
state.modal = state.modal !== 'scale' ? 'scale' : null;675
update_modal_list();676
}677
if(event.code === 'KeyC') {678
state.modal = state.modal !== 'pencil' ? 'pencil' : null;679
update_modal_list();680
}681
if(event.code === 'KeyV') {682
state.modal = state.modal !== 'clear' ? 'clear' : null;683
update_modal_list();684
}685
/*686
if(event.code === 'KeyB') {687
state.modal = state.modal !== 'multiplayer' ? 'multiplayer' : null;688
update_modal_list();689
}690
if(event.code === 'KeyN') {691
state.modal = state.modal !== 'account' ? 'account' : null;692
update_modal_list();693
}694
*/695
if(event.code === 'KeyM') {696
state.modal = state.modal !== 'more' ? 'more' : null;697
update_modal_list();698
}699
if(event.code === 'KeyQ') {700
canvas.on_release(event, state);701
state.pencil = state.pencil_list[0];702
canvas.draw_cursor(state);703
update_pencil_list();704
}705
if(event.code === 'KeyW') {706
canvas.on_release(event, state);707
state.pencil = state.pencil_list[1];708
canvas.draw_cursor(state);709
update_pencil_list();710
}711
if(event.code === 'KeyE') {712
canvas.on_release(event, state);713
state.pencil = state.pencil_list[2];714
canvas.draw_cursor(state);715
update_pencil_list();716
}717
if(event.code === 'KeyF') {718
if(!document.fullscreenElement) {719
document.documentElement.requestFullscreen();720
}721
else if(document.exitFullscreen) {722
document.exitFullscreen();723
}724
}725
}726
if(event.code === 'Space') {727
state.option.view_mode = !state.option.view_mode;728
update_view_mode_option();729
}730
}731
if(event.ctrlKey && !event.shiftKey && !event.altKey) {732
if(event.code === 'KeyY') {733
canvas.undo(state);734
update_undo_and_redo();735
}736
if(event.code === 'KeyZ') {737
canvas.redo(state);738
update_undo_and_redo();739
}740
}741
if(event.code === 'Enter') {742
if(state.modal === 'clear') {743
node.clear.click();744
}745
}746
}748
function on_wheel(event) {749
if(!state.option.view_mode && state.device === 'mouse') {750
if(event.target === canvas.get_canvas()) {751
let y = event.deltaY < 0 ? 1 : -1;752
if(state.radius + y > 2 - 1 && state.radius + y < 50 + 1) {753
canvas.on_release(event, state);754
state.radius += y;755
node.scale_input.value = state.radius;756
canvas.draw_cursor(state);757
}758
}759
}760
}762
function on_fullscreenchange(event) {763
update_fullscreen_option();764
}766
function fill_hotbar_list() {767
for(let [ i, item ] of Object.entries(node.hotbar_list)) {768
if(state.color_list.length > i) {769
item.style.background = COLORS[state.color_list[i]];770
item.addEventListener('click', function(event) {771
canvas.on_release(event, state);772
state.color = state.color_list[i];773
state.index = i;774
canvas.draw_cursor(state);775
update_hotbar();776
});777
if(state.index == i) {778
item.classList.add('active');779
}780
}781
}782
}784
function fill_modal_color_list() {785
for(let [ i, item ] of Object.entries(node.modal_color_list)) {786
if(COLORS.length > i) {787
item.style.background = COLORS[i];788
item.addEventListener('click', function(event) {789
canvas.on_release(event, state);790
state.color = i;791
state.modal = null;792
update_modal_list();793
canvas.draw_cursor(state);794
state.index = null;795
update_hotbar();796
});797
}798
}799
}801
function show_notification(message) {802
let code = uuid();803
state.timestamp = code;804
let content = node.notification.querySelector('.content');805
content.textContent = locale.get()[message];806
node.notification.animate([807
{ opacity: 0 },808
{ opacity: 1 }809
], {810
duration: 200,811
fill: 'both'812
});813
setTimeout(function() {814
if(state.timestamp === code) {815
node.notification.animate([816
{ opacity: 1 },817
{ opacity: 0 }818
], {819
duration: 200,820
fill: 'both'821
});822
}823
}, 1000);824
}
1
import { COLORS, PRIORITY_MODAL, LOCALES } from '../constant.js';2
import { uuid, query, prevent } from '../util.js';4
import locale from '../mod/locale.js';5
import canvas from './mod/canvas.js';7
let node;8
let state = {9
color: 54,10
color_list: [54, 2, 17, 27, 37, 12],11
radius: 14,12
region: [],13
crop: false,14
index: 0,15
device: null,16
device_fallback: null,17
device_list: {18
mouse: false,19
touch: false,20
pen: false,21
gamepad: false22
},23
pencil_list: [24
'pen',25
'marker',26
'eraser'27
],28
pencil: 'pen',29
timestamp: null,30
modal: null,31
tab: null,32
caption: null,33
option: {34
view_mode: false,35
crop_mode: false36
},37
history: [],38
redo_history: []39
};41
export function init() {43
locale.init();44
locale.load('./asset/lang', LOCALES);45
canvas.init();47
node = query({48
wrapper: '.wrapper',49
controls: '.controls',50
modal_list: { query: '.modal', all: true },51
tab_list: { query: '.tab', all: true },52
header: '.header-list',53
hotbar: '.hotbar',54
hotbar_list: { query: '.hotbar .color', all: true },55
modal_color_list: { query: '.colors-modal .color', all: true },56
language_list: { query: '.more-modal .language-tab .item[data-event="change.language"]', all: true },57
device_list: { query: '.more-modal .device-tab .item[data-event="change.device"]', all: true },58
pencil_list: { query: '.pencil-modal .item[data-event="change.pencil"]', all: true },59
modal_event_list: { query: '[data-event*=".modal"]', all: true },60
tab_event_list: { query: '[data-event*=".tab"]', all: true },61
capture_event_list: { query: '[data-event*=".capture"]', all: true },62
tool_list: { query: '.tool', all: true },63
action_list: { query: '.action', all: true },64
notification: '.notification',65
scale_input: 'input.scale[type="range"]',66
clear: 'button.btn-apply[data-event="clear"]',67
pencil_tool: '.tool-item[data-code="pencil"]',68
option_event_fullscreen: '[data-event="toggle.fullscreen"]',69
option_event_view_mode: '[data-event="toggle.view-mode"]',70
undo_tool: '[data-lang="action.undo"]',71
redo_tool: '[data-lang="action.redo"]',72
colors_modal: '.colors-modal',73
mainbar: '.mainbar',74
sidebar: '.sidebar',75
edit_mode: '[data-event="close.view-mode"]',76
content: '.modal .content',77
caption_list: { query: '[data-event="open.content"]' , all: true },78
content_list: { query: '.content-item' , all: true },79
download: '#download'80
});82
fill_hotbar_list();83
fill_modal_color_list();85
bind_events(locale);87
node.wrapper.animate([88
{ opacity: 1 },89
{ opacity: 0, pointerEvents: 'none' }90
], {91
delay: 100,92
duration: 500,93
fill: 'both'94
});95
node.hotbar.animate([96
{ opacity: 0, bottom: '-10px' },97
{ opacity: 1 }98
], {99
delay: 600,100
easing: 'ease-out',101
duration: 250,102
fill: 'both'103
});104
}106
function bind_events(locale) {107
document.addEventListener('dragstart', prevent);108
document.addEventListener('contextmenu', prevent);109
document.addEventListener('pointerdown', on_pointerdown);110
document.addEventListener('pointermove', on_pointermove);111
document.addEventListener('pointerup', on_pointerup);112
document.addEventListener('pointerout', on_pointerout);113
document.addEventListener('keydown', on_keydown);114
document.addEventListener('wheel', on_wheel);115
document.addEventListener('wheel', function(event) {116
if(event.ctrlKey) {117
prevent(event);118
}119
}, { passive: false });120
document.addEventListener('touchmove', function(event) {121
if(event.target !== node.scale_input && event.target !== node.colors_modal && !node.modal_color_list.includes(event.target) && event.target !== node.content) {122
event.preventDefault();123
}124
}, { passive: false });126
for(let item of node.language_list) {127
item.addEventListener('click', function(event) {128
let code = item.dataset.code;129
locale.change(code);130
update_language_list();131
});132
}133
for(let item of node.device_list) {134
item.addEventListener('click', function(event) {135
let code = item.dataset.code;136
if(state.device_list[code]) {137
state.device = code;138
update_device_list();139
}140
});141
}142
for(let item of node.pencil_list) {143
item.addEventListener('click', function(event) {144
state.pencil = item.dataset.code;145
update_pencil_list();146
state.modal = null;147
update_modal_list();148
});149
}150
for(let item of node.modal_event_list) {151
item.addEventListener('click', function(event) {152
let code = item.dataset.code;153
let match = /^(toggle|open|close).modal$/.exec(item.dataset.event);154
if(match) {155
if(!item.classList.contains('inactive')) {156
switch(match[1]) {157
case 'toggle':158
if(code) {159
state.modal = state.modal !== code ? code : null;160
update_modal_list();161
}162
break;163
case 'open':164
if(code && state.modal !== code) {165
state.modal = code;166
update_modal_list();167
}168
break;169
case 'close':170
if(state.modal !== null) {171
state.modal = null;172
update_modal_list();173
}174
break;175
default:176
break;177
}178
}179
}180
});181
}182
for(let item of node.tab_event_list) {183
item.addEventListener('click', function(event) {184
let code = item.dataset.code;185
let match = /^(open|close).tab/.exec(item.dataset.event);186
if(match) {187
switch(match[1]) {188
case 'open':189
if(code && state.tab !== code) {190
state.tab = code;191
update_tab_list();192
}193
break;194
case 'close':195
if(state.tab !== null) {196
state.tab = null;197
update_tab_list();198
}199
break;200
default:201
break;202
}203
}204
});205
}206
for(let item of node.capture_event_list) {207
item.addEventListener('click', function(event) {208
let code = item.dataset.code;209
if(code === 'download') {210
if(state.option.crop_mode) {211
state.option.crop_mode = false;212
canvas.draw_crop(state);213
canvas.get_canvas().style.cursor = 'default';214
}215
let data = canvas.create_capture(0, 0, window.innerWidth, window.innerHeight, 60);216
if(data) {217
node.download.download = `outline-${uuid()}.png`;218
node.download.href = data;219
node.download.click();220
}221
else {222
console.warn('Unable to create capture from current state!');223
}224
}225
if(code === 'crop') {226
state.option.crop_mode = true;227
state.region = [];228
canvas.draw_crop(state);229
canvas.get_canvas().style.cursor = 'crosshair';230
}231
state.modal = null;232
state.tab = null;233
update_modal_list();234
})235
}236
node.scale_input.addEventListener('input', function(event) {237
state.radius = parseInt(node.scale_input.value);238
state.point = {239
x: parseInt(window.innerWidth / 2),240
y: parseInt(window.innerHeight / 2)241
};242
canvas.draw_cursor(state);243
});244
node.clear.addEventListener('click', function(event) {245
canvas.clear(state);246
update_undo_and_redo();247
show_notification('notification.clear');248
state.modal = null;249
update_modal_list();250
});251
node.option_event_fullscreen.addEventListener('click', function(event) {252
if(!document.fullscreenElement) {253
document.documentElement.requestFullscreen();254
}255
else if(document.exitFullscreen) {256
document.exitFullscreen();257
}258
});259
window.addEventListener('fullscreenchange', on_fullscreenchange);260
node.option_event_view_mode.addEventListener('click', function(event) {261
state.option.view_mode = !state.option.view_mode;262
update_view_mode_option();263
});264
node.undo_tool.addEventListener('click', function(event) {265
canvas.undo(state);266
update_undo_and_redo();267
});268
node.redo_tool.addEventListener('click', function(event) {269
canvas.redo(state);270
update_undo_and_redo();271
});272
node.edit_mode.addEventListener('click', function(event) {273
state.option.view_mode = false;274
update_view_mode_option();275
});276
for(let item of node.caption_list) {277
item.addEventListener('click', function(event) {278
state.caption = item.dataset.code;279
update_caption_list();280
});281
}283
window.addEventListener('beforeunload', function(event) {284
// ...285
});286
}288
function update_language_list() {289
let lang = locale.get_current();290
for(let item of node.language_list) {291
let code = item.dataset.code;292
item.classList[code === lang ? 'add' : 'remove']('active');293
}294
}296
function update_device_list() {297
if(!state.option.view_mode && !state.option.crop_mode) {298
canvas.get_canvas().style.cursor = state.device === 'mouse' ? 'none' : '';299
}300
for(let item of node.device_list) {301
let code = item.dataset.code;302
item.classList[code === state.device ? 'add' : 'remove']('active');303
item.classList[state.device_list[code] ? 'remove' : 'add']('inactive');304
}305
}307
function update_pencil_list() {308
for(let item of node.pencil_list) {309
let code = item.dataset.code;310
item.classList[code === state.pencil ? 'add' : 'remove']('active');311
if(code === state.pencil) {312
node.pencil_tool.querySelector('i.ico').innerHTML = item.querySelector('i.ico').innerHTML;313
}314
}315
}317
function update_hotbar() {318
for(let item of node.hotbar_list) {319
item.classList[node.hotbar_list[state.index] === item ? 'add' : 'remove']('active');320
}321
}323
function update_focus(bool) {324
for(let item of node.hotbar_list) {325
item.style.pointerEvents = bool ? '' : 'none';326
}327
for(let item of node.tool_list) {328
item.style.pointerEvents = bool ? '' : 'none';329
}330
for(let item of node.action_list) {331
item.style.pointerEvents = bool ? '' : 'none';332
}333
}335
function update_modal_list() {336
for(let item of node.modal_list) {337
item.classList.add('hidden');338
}339
for(let item of node.modal_event_list) {340
item.classList.remove('active');341
}342
state.tab = null;343
update_tab_list();344
state.caption = 'controls';345
update_caption_list();346
if(state.modal) {347
canvas.on_release(event, state, true);348
let modal = document.querySelector(`.modal.${state.modal}-modal`);349
let button = document.querySelector(`[data-event*=".modal"][data-code="${state.modal}"]`);350
if(modal) {351
modal.classList.remove('hidden');352
modal.animate([353
{ opacity: 0, marginTop: '-6px' },354
{ opacity: 1, marginTop: '0' }355
], {356
duration: 100,357
fill: 'both'358
});359
}360
if(button) {361
button.classList.add('active');362
}363
}364
}366
function update_tab_list() {367
for(let item of node.modal_list) {368
let main = item.querySelector('.main');369
if(main) {370
main.classList.remove('hidden');371
main.style.marginLeft = '0';372
}373
}374
for(let item of node.tab_list) {375
item.classList.add('hidden');376
}377
if(state.modal && state.tab) {378
let modal = document.querySelector(`.modal.${state.modal}-modal`);379
let tab = document.querySelector(`.${state.tab}-tab`);380
let main = modal.querySelector('.main');381
if(modal && tab && main) {382
tab.classList.remove('hidden');383
main.style.marginLeft = '-100%';384
main.classList.add('hidden');385
}386
}387
}389
function update_fullscreen_option() {390
let fullscreen = document.fullscreenElement;391
node.option_event_fullscreen.classList[fullscreen ? 'add' : 'remove']('active');392
node.option_event_fullscreen.querySelector('.ico').textContent = fullscreen ? 'toggle_on' : 'toggle_off';393
}395
function update_view_mode_option() {396
let view_mode = state.option.view_mode;397
show_notification(`notification.view-mode.${view_mode ? 'on' : 'off'}`);398
node.option_event_view_mode.classList[view_mode ? 'add' : 'remove']('active');399
node.option_event_view_mode.querySelector('.ico').textContent = view_mode ? 'toggle_on' : 'toggle_off';400
state.modal = null;401
state.tab = null;402
update_modal_list();403
if(view_mode) {404
canvas.on_release(null, state);405
canvas.clear_cursor();406
canvas.get_canvas().style.cursor = 'default';407
node.hotbar.classList.add('inactive');408
node.header.classList.add('inactive');409
node.hotbar.animate([410
{ opacity: 1 },411
{ opacity: 0, bottom: '-10px', pointerEvents: 'none' }412
], {413
easing: 'ease-out',414
duration: 250,415
fill: 'both'416
});417
node.mainbar.animate([418
{ opacity: 1, marginTop: 0 },419
{ opacity: 0, marginTop: '-60px' }420
], {421
easing: 'ease-out',422
duration: 250,423
fill: 'both'424
});425
node.sidebar.classList.remove('hidden');426
node.sidebar.animate([427
{ opacity: 0 },428
{ opacity: 1 }429
], {430
delay: 250,431
easing: 'ease-out',432
duration: 250,433
fill: 'both'434
});435
}436
else {437
state.option.crop_mode = false;438
canvas.draw_crop(state);439
canvas.on_release(null, state, true);440
canvas.get_canvas().style.cursor = 'none';441
node.hotbar.classList.remove('inactive');442
node.header.classList.remove('inactive');443
node.hotbar.animate([444
{ opacity: 0, bottom: '-10px' },445
{ opacity: 1, bottom: '30px' }446
], {447
easing: 'ease-out',448
duration: 250,449
fill: 'both'450
});451
node.mainbar.animate([452
{ opacity: 0, marginTop: '-60px' },453
{ opacity: 1, marginTop: 0 }454
], {455
easing: 'ease-out',456
duration: 250,457
fill: 'both'458
});459
node.sidebar.classList.add('hidden');460
}461
}463
function update_undo_and_redo() {464
node.undo_tool.classList[state.history.length > 0 ? 'remove' : 'add']('inactive');465
node.redo_tool.classList[state.redo_history.length > 0 ? 'remove' : 'add']('inactive');466
}468
function update_caption_list() {469
for(let item of node.caption_list) {470
let code = item.dataset.code;471
item.classList[code === state.caption ? 'add' : 'remove']('active');472
}473
for(let item of node.content_list) {474
let code = item.dataset.code;475
item.classList[code === state.caption ? 'remove' : 'add']('hidden');476
}477
}479
function on_pointerdown(event) {480
// detect touch481
if(!state.device_list.touch && event.pointerType === 'touch') {482
state.device_list.touch = true;483
if(state.device) {484
show_notification('notification.input-device.touch.add');485
}486
else {487
state.device = 'touch';488
state.device_fallback = 'touch';489
}490
update_device_list();491
}492
// detect pen493
if(!state.device_list.pen && event.pointerType === 'pen') {494
state.device_list.pen = true;495
show_notification('notification.input-device.pencil.add');496
if(!state.device) {497
state.device = 'pen';498
state.device_fallback = 'pen';499
}500
update_device_list();501
}502
// drawing503
if(!state.option.view_mode && state.device === event.pointerType) {504
if(event.target === canvas.get_canvas()) {505
if(!PRIORITY_MODAL.includes(state.modal)) {506
update_focus(false);507
canvas.on_press(event, state);508
update_undo_and_redo();509
state.point = {510
x: event.layerX,511
y: event.layerY512
};513
canvas.draw_cursor(state);514
}515
}516
}517
if(state.option.view_mode && state.option.crop_mode) {518
if(event.target === canvas.get_canvas()) {519
state.crop = true;520
state.region = [];521
state.region[0] = { x: event.layerX, y: event.layerY };522
canvas.draw_crop(state);523
}524
}525
}527
function on_pointermove(event) {528
// detect mouse529
if(!state.device_list.mouse && event.pointerType === 'mouse') {530
state.device_list.mouse = true;531
if(state.device) {532
show_notification('notification.input-device.mouse.add');533
}534
else {535
state.device = 'mouse';536
state.device_fallback = 'mouse';537
}538
update_device_list();539
}540
// drawing541
if(!state.option.view_mode && state.device === event.pointerType) {542
if(event.target === canvas.get_canvas()) {543
if(!PRIORITY_MODAL.includes(state.modal)) {544
canvas.on_move(event, state);545
}546
state.point = {547
x: event.layerX,548
y: event.layerY549
};550
}551
canvas.draw_cursor(state);552
}553
if(state.option.view_mode && state.option.crop_mode) {554
if(state.crop && event.target === canvas.get_canvas()) {555
state.region[1] = { x: event.layerX, y: event.layerY };556
canvas.draw_crop(state);557
}558
}559
}561
function on_pointerup(event) {562
if(!state.option.view_mode && state.device === event.pointerType) {563
canvas.on_release(event, state);564
update_undo_and_redo();565
update_focus(true);566
}567
if(state.option.view_mode && state.option.crop_mode) {568
if(state.crop && event.target === canvas.get_canvas()) {569
state.crop = false;570
state.region[1] = { x: event.layerX, y: event.layerY };571
canvas.draw_crop(state);572
let [ begin, end ] = state.region;573
let delta = {574
x: end.x - begin.x,575
y: end.y - begin.y576
};577
let x = begin.x < end.x ? begin.x : end.x;578
let y = begin.y < end.y ? begin.y : end.y;579
if(delta.x < 0) {580
delta.x *= -1;581
}582
if(delta.y < 0) {583
delta.y *= -1;584
}585
if(delta.x != 0 && delta.y != 0) {586
let data = canvas.create_capture(x, y, delta.x, delta.y);587
if(data) {588
node.download.download = `outline-${uuid()}.png`;589
node.download.href = data;590
node.download.click();591
state.option.crop_mode = false;592
canvas.draw_crop(state);593
canvas.get_canvas().style.cursor = 'default';594
}595
else {596
console.warn('Unable to create capture from current state!');597
}598
}599
}600
}601
}603
function on_pointerout(event) {604
if(!state.option.view_mode && state.device === event.pointerType) {605
canvas.on_release(event, state);606
update_undo_and_redo();607
state.point = null;608
canvas.draw_cursor(state);609
}610
if(state.option.view_mode && state.option.crop_mode) {611
if(state.crop && event.target === canvas.get_canvas()) {612
state.crop = false;613
state.region = [];614
canvas.draw_crop(state);615
}616
}617
}619
function on_keydown(event) {620
if(event.code === 'Escape') {621
if(state.tab) {622
state.tab = null;623
update_tab_list();624
return;625
}626
if(state.modal) {627
state.modal = null;628
update_modal_list();629
return;630
}631
if(state.option.view_mode && state.option.crop_mode) {632
state.option.crop_mode = false;633
canvas.draw_crop(state);634
canvas.get_canvas().style.cursor = 'default';635
}636
}637
if(!event.ctrlKey && !event.shiftKey && !event.altKey) {638
if(!state.option.view_mode) {639
if(event.code.startsWith('Digit')) {640
let i = parseInt(event.code.substr(5)) - 1;641
if(state.index !== i) {642
if(i >= 0 && i < state.color_list.length) {643
canvas.on_release(event, state);644
state.color = state.color_list[i];645
state.index = i;646
canvas.draw_cursor(state);647
update_hotbar();648
}649
}650
}651
if(event.code === 'KeyZ') {652
state.modal = state.modal !== 'colors' ? 'colors' : null;653
update_modal_list();654
}655
if(event.code === 'KeyX') {656
state.modal = state.modal !== 'scale' ? 'scale' : null;657
update_modal_list();658
}659
if(event.code === 'KeyC') {660
state.modal = state.modal !== 'pencil' ? 'pencil' : null;661
update_modal_list();662
}663
if(event.code === 'KeyV') {664
state.modal = state.modal !== 'clear' ? 'clear' : null;665
update_modal_list();666
}667
/*668
if(event.code === 'KeyB') {669
state.modal = state.modal !== 'multiplayer' ? 'multiplayer' : null;670
update_modal_list();671
}672
if(event.code === 'KeyN') {673
state.modal = state.modal !== 'account' ? 'account' : null;674
update_modal_list();675
}676
*/677
if(event.code === 'KeyM') {678
state.modal = state.modal !== 'more' ? 'more' : null;679
update_modal_list();680
}681
if(event.code === 'KeyQ') {682
canvas.on_release(event, state);683
state.pencil = state.pencil_list[0];684
canvas.draw_cursor(state);685
update_pencil_list();686
}687
if(event.code === 'KeyW') {688
canvas.on_release(event, state);689
state.pencil = state.pencil_list[1];690
canvas.draw_cursor(state);691
update_pencil_list();692
}693
if(event.code === 'KeyE') {694
canvas.on_release(event, state);695
state.pencil = state.pencil_list[2];696
canvas.draw_cursor(state);697
update_pencil_list();698
}699
if(event.code === 'KeyF') {700
if(!document.fullscreenElement) {701
document.documentElement.requestFullscreen();702
}703
else if(document.exitFullscreen) {704
document.exitFullscreen();705
}706
}707
}708
if(event.code === 'Space') {709
state.option.view_mode = !state.option.view_mode;710
update_view_mode_option();711
}712
}713
if(event.ctrlKey && !event.shiftKey && !event.altKey) {714
if(event.code === 'KeyY') {715
canvas.undo(state);716
update_undo_and_redo();717
}718
if(event.code === 'KeyZ') {719
canvas.redo(state);720
update_undo_and_redo();721
}722
}723
if(event.code === 'Enter') {724
if(state.modal === 'clear') {725
node.clear.click();726
}727
}728
}730
function on_wheel(event) {731
if(!state.option.view_mode && state.device === 'mouse') {732
if(event.target === canvas.get_canvas()) {733
let y = event.deltaY < 0 ? 1 : -1;734
if(state.radius + y > 2 - 1 && state.radius + y < 50 + 1) {735
canvas.on_release(event, state);736
state.radius += y;737
node.scale_input.value = state.radius;738
canvas.draw_cursor(state);739
}740
}741
}742
}744
function on_fullscreenchange(event) {745
update_fullscreen_option();746
}748
function fill_hotbar_list() {749
for(let [ i, item ] of Object.entries(node.hotbar_list)) {750
if(state.color_list.length > i) {751
item.style.background = COLORS[state.color_list[i]];752
item.addEventListener('click', function(event) {753
canvas.on_release(event, state);754
state.color = state.color_list[i];755
state.index = i;756
canvas.draw_cursor(state);757
update_hotbar();758
});759
if(state.index == i) {760
item.classList.add('active');761
}762
}763
}764
}766
function fill_modal_color_list() {767
for(let [ i, item ] of Object.entries(node.modal_color_list)) {768
if(COLORS.length > i) {769
item.style.background = COLORS[i];770
item.addEventListener('click', function(event) {771
canvas.on_release(event, state);772
state.color = i;773
state.modal = null;774
update_modal_list();775
canvas.draw_cursor(state);776
state.index = null;777
update_hotbar();778
});779
}780
}781
}783
function show_notification(message) {784
let code = uuid();785
state.timestamp = code;786
let content = node.notification.querySelector('.content');787
content.textContent = locale.get()[message];788
node.notification.animate([789
{ opacity: 0 },790
{ opacity: 1 }791
], {792
duration: 200,793
fill: 'both'794
});795
setTimeout(function() {796
if(state.timestamp === code) {797
node.notification.animate([798
{ opacity: 1 },799
{ opacity: 0 }800
], {801
duration: 200,802
fill: 'both'803
});804
}805
}, 1000);806
}
1
const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;2
const MAX_HISTORY_STEP = 10;4
import { COLORS } from '../../constant.js';6
let active;7
let point_list = [];8
let width;9
let height;10
let size;11
let last;12
let ratio;13
let backing_store_ratio;15
let canvas;16
let overlay;17
let memory;18
let temporary;19
let g;20
let o;21
let m;22
let t;24
function init() {25
width = window.innerWidth;26
height = window.innerHeight;27
canvas = document.querySelector('#canvas');28
overlay = document.querySelector('#overlay');29
memory = document.createElement('canvas');30
temporary = document.createElement('canvas');31
g = canvas.getContext('2d');32
o = overlay.getContext('2d');33
m = memory.getContext('2d');34
t = temporary.getContext('2d');35
resize();36
window.addEventListener('resize', resize);37
}39
function get_canvas() {40
return canvas;41
}43
function resize() {44
width = window.innerWidth;45
height = window.innerHeight;46
let max = width > height ? width : height;47
if(!size || max > size) {48
last = size;49
size = max;50
}51
else {52
last = null;53
}54
backing_store_ratio = (55
g.webkitBackingStorePixelRatio ||56
g.mozBackingStorePixelRatio ||57
g.msBackingStorePixelRatio ||58
g.oBackingStorePixelRatio ||59
g.backingStorePixelRatio || 160
)61
ratio = DEVICE_PIXEL_RATIO / backing_store_ratio;62
let buffer = document.createElement('canvas');63
let b = buffer.getContext('2d');64
scale_canvas(buffer, b, last || size);65
b.imageSmoothingEnabled = false;66
b.clearRect(0, 0, size, size);67
b.drawImage(canvas, 0, 0, last || size, last || size);68
scale_canvas(canvas, g, size);69
g.imageSmoothingEnabled = false;70
g.drawImage(buffer, 0, 0, last || size, last || size);71
scale_canvas(overlay, o, size);72
o.imageSmoothingEnabled = false;73
scale_canvas(memory, m, size);74
m.imageSmoothingEnabled = false;75
m.drawImage(canvas, 0, 0, last || size, last || size);76
b.clearRect(0, 0, size, size);77
b.drawImage(temporary, 0, 0, last || size, last || size);78
scale_canvas(temporary, t, size);79
t.imageSmoothingEnabled = false;80
t.drawImage(buffer, 0, 0, last || size, last || size);81
}83
function scale_canvas(canvas, g, size, height) {84
if(DEVICE_PIXEL_RATIO !== backing_store_ratio) {85
canvas.width = size * ratio;86
canvas.height = (height || size) * ratio;87
canvas.style.width = size + 'px';88
canvas.style.height = (height || size) + 'px';89
}90
else {91
canvas.width = size;92
canvas.height = height || size;93
canvas.style.width = '';94
canvas.style.height = '';95
}96
g.scale(ratio, ratio);97
}99
function clear(state) {100
g.clearRect(0, 0, size, size);101
m.clearRect(0, 0, size, size);102
t.clearRect(0, 0, size, size);103
state.history = [];104
state.redo_history = [];105
}107
function on_press(event, state) {108
point_list.push({109
x: event.layerX,110
y: event.layerY111
});112
active = true;113
state.redo_history = [];114
draw_curve(g, state, point_list);115
}117
function on_move(event, state) {118
if(active) {119
g.clearRect(0, 0, size, size);120
g.drawImage(memory, 0, 0, size, size);121
point_list.push({122
x: event.layerX,123
y: event.layerY124
});125
draw_curve(g, state, point_list);126
}127
}129
function on_release(event, state, undrag) {130
if(active) {131
if((event && event.type === 'pointerup') || undrag) {132
active = false;133
}134
if(point_list.length > 0) {135
state.history.push({136
list: point_list,137
state: Object.assign({}, state)138
});139
if(state.history.length > MAX_HISTORY_STEP) {140
let line = state.history.shift();141
draw_curve(t, line.state, line.list);142
}143
}144
m.clearRect(0, 0, size, size);145
m.drawImage(canvas, 0, 0, size, size);146
point_list = [];147
}148
}150
function undo(state) {151
if(state.history.length > 0) {152
state.redo_history.push(state.history.pop());153
g.clearRect(0, 0, size, size);154
m.clearRect(0, 0, size, size);155
g.drawImage(temporary, 0, 0, size, size);156
m.drawImage(temporary, 0, 0, size, size);157
for(let line of state.history) {158
draw_curve(g, line.state, line.list);159
draw_curve(m, line.state, line.list);160
}161
}162
}164
function redo(state) {165
if(state.redo_history.length > 0) {166
let line = state.redo_history.pop();167
state.history.push(line);168
draw_curve(g, line.state, line.list);169
draw_curve(m, line.state, line.list);170
}171
}173
function draw_curve(g, state, point_list) {174
if(state.pencil === 'pen') {175
g.strokeStyle = COLORS[state.color];176
g.fillStyle = COLORS[state.color];177
}178
if(state.pencil === 'marker') {179
g.strokeStyle = COLORS[state.color] + '88';180
g.fillStyle = COLORS[state.color] + '88';181
}182
if(state.pencil === 'eraser') {183
g.strokeStyle = 'white';184
g.fillStyle = 'white';185
}186
g.lineCap = 'round';187
g.lineJoin = 'round';188
g.lineWidth = 2 * state.radius;189
if(point_list.length < 3) {190
g.beginPath();191
g.arc(point_list[0].x, point_list[0].y, g.lineWidth / 2, 0, Math.PI * 2, !0);192
g.closePath();193
g.fill();194
return;195
}196
g.beginPath();197
g.moveTo(point_list[0].x, point_list[0].y);198
let i;199
for(i = 1; i < point_list.length - 2; i++) {200
let dx = (point_list[i].x + point_list[i + 1].x);201
let dy = (point_list[i].y + point_list[i + 1].y);202
g.quadraticCurveTo(point_list[i].x, point_list[i].y, parseInt(dx / 2), parseInt(dy / 2));203
}204
g.quadraticCurveTo(point_list[i].x, point_list[i].y, point_list[i + 1].x, point_list[i + 1].y);205
g.stroke();206
}208
function draw_cursor(state) {209
o.clearRect(0, 0, size, size);210
o.lineWidth = 2;211
if(state.point) {212
if(state.pencil === 'pen') {213
o.fillStyle = COLORS[state.color];214
}215
if(state.pencil === 'marker') {216
o.fillStyle = COLORS[state.color] + '88';217
}218
if(state.pencil === 'eraser') {219
o.fillStyle = COLORS[state.color] + '55';220
}221
o.beginPath();222
o.arc(state.point.x, state.point.y, 2 * state.radius / 2, 0, Math.PI * 2, !0);223
o.closePath();224
o.fill();225
o.strokeStyle = 'white';226
o.beginPath();227
o.arc(state.point.x, state.point.y, 2 * state.radius / 2, 0, Math.PI * 2, !0);228
o.closePath();229
o.stroke();230
if(state.pencil === 'eraser') {231
o.strokeStyle = 'white';232
o.beginPath();233
o.moveTo(state.point.x - state.radius * 0.5, state.point.y);234
o.lineTo(state.point.x + state.radius * 0.5, state.point.y);235
o.stroke();236
o.beginPath();237
o.moveTo(state.point.x, state.point.y - state.radius * 0.5);238
o.lineTo(state.point.x, state.point.y + state.radius * 0.5);239
o.stroke();240
}241
}242
}244
function draw_crop(state) {245
o.clearRect(0, 0, size, size);246
if(state.option.crop_mode) {247
o.fillStyle = 'rgba(0, 0, 0, 0.3)';248
o.beginPath();249
o.rect(0, 0, size, size);250
o.fill();251
if(state.region && state.region.length == 2) {252
let [ begin, end ] = state.region;253
if(begin && end) {254
let delta = {255
x: end.x - begin.x,256
y: end.y - begin.y257
};258
if(delta.x != 0 && delta.y != 0) {259
o.clearRect(begin.x, begin.y, delta.x, delta.y);260
o.strokeStyle = 'white';261
o.beginPath();262
o.rect(begin.x, begin.y, delta.x, delta.y);263
o.stroke();264
}265
}266
}267
}268
}270
function clear_cursor() {271
o.clearRect(0, 0, size, size);272
}274
function set_data(data) {275
let image = new Image();276
image.onload = function(event) {277
g.drawImage(image, 0, 0);278
m.drawImage(image, 0, 0);279
t.drawImage(image, 0, 0);280
}281
image.src = data;282
}284
function get_data() {285
return canvas.toDataURL();286
}288
function create_capture(x, y, width, height, offset) {289
if(!offset) {290
offset = 0;291
}292
let cache = document.createElement('canvas');293
let c = cache.getContext('2d');294
scale_canvas(cache, c, width * ratio, (height - offset) * ratio);295
c.translate(-x * ratio, -(y * ratio + offset));296
c.fillStyle = 'white';297
c.fillRect(0, 0, window.innerWidth * ratio, window.innerHeight * ratio);298
c.drawImage(canvas, 0, 0 - offset);299
let data = cache.toDataURL() || null;300
cache.remove();301
return data;302
}304
export default {305
init,306
get_canvas,307
resize,308
scale_canvas,309
clear,310
on_press,311
on_move,312
on_release,313
undo,314
redo,315
draw_curve,316
draw_cursor,317
draw_crop,318
clear_cursor,319
set_data,320
get_data,321
create_capture322
};
1
const FIREBASE = {2
apiKey: atob('QUl6YVN5QzZVcFRpNVlYc1h6eFJ2aEo4Z1RWbnJtTkpCQ2JCMjBn'),3
authDomain: 'typable-website.firebaseapp.com',4
databaseURL: 'https://typable-website.firebaseio.com',5
projectId: 'typable-website',6
storageBucket: 'typable-website.appspot.com',7
messagingSenderId: '1097239723234',8
appId: '1:1097239723234:web:a9b8491f4778f46b96f2bb',9
measurementId: 'G-6881VEFYTQ'10
};12
const COLORS = [13
'#FFCDD2',14
'#E57373',
80
];82
export {83
FIREBASE,84
COLORS,85
PRIORITY_MODAL,86
LOCALES
1
import { FIREBASE, LOCALES } from './constant.js';2
import { uuid, query } from './util.js';4
import locale from './mod/locale.js';5
import cookie from './mod/cookie.js';7
let node;8
let state = {9
deferredPrompt: null10
};12
export function init() {14
locale.init();15
locale.load('./asset/lang', LOCALES);17
node = query({18
notification: '.notification',19
cookie: '.cookie',20
accept: '.button.accept'21
});23
let elements = document.querySelectorAll('[data-event]');24
for(let element of elements) {25
let value = element.dataset.event;27
if(value === 'play') {28
element.addEventListener('click', function() {29
window.location.href = '/app';30
});31
}33
if(value === 'install') {34
element.addEventListener('click', function() {35
if(state.deferredPrompt) {36
state.deferredPrompt.prompt();37
state.deferredPrompt.userChoice.then(function(result) {38
// let installed = result.outcome === 'accepted';39
});40
}41
else {42
show_notification('main.upcoming');43
}44
});45
}46
}48
let header = document.querySelector('header');49
header.classList.remove('transparent');50
header.animate([51
{ opacity: 0 },52
{ opacity: 1 }53
], {54
duration: 400,55
fill: 'both',56
easing: 'ease-in'57
});59
let brand_logo = document.querySelector('.brand-logo');60
brand_logo.classList.remove('transparent');61
brand_logo.animate([62
{ opacity: 0 },63
{ opacity: 1 }64
], {65
duration: 200,66
fill: 'both',67
easing: 'ease-in',68
delay: 40069
});71
let logo = document.querySelector('.logo');72
logo.classList.remove('transparent');73
logo.animate([74
{ opacity: 0, marginTop: '50px' },75
{ opacity: 1, marginTop: 0 }76
], {77
duration: 400,78
fill: 'both',79
easing: 'ease-out',80
delay: 60081
});83
let info = document.querySelector('.header-info');84
info.classList.remove('transparent');85
info.animate([86
{ opacity: 0, marginTop: '50px' },87
{ opacity: 1, marginTop: 0 }88
], {89
duration: 400,90
fill: 'both',91
easing: 'ease-out',92
delay: 60093
});95
window.addEventListener('beforeinstallprompt', function(event) {96
event.preventDefault();97
state.deferredPrompt = event;98
});100
if(!cookie.hasAccepted()) {101
node.cookie.classList.remove('hidden');102
cookie.requestPermission(node.accept)103
.then(function() {104
node.cookie.classList.add('hidden');105
try {106
firebase.initializeApp(FIREBASE);107
firebase.analytics();108
}109
catch(error) {110
console.warn('Unable to load Google Analytics!');111
}112
});113
}114
}116
function show_notification(message) {117
let code = uuid();118
state.timestamp = code;119
let content = node.notification.querySelector('.content');120
content.textContent = locale.get()[message];121
node.notification.animate([122
{ opacity: 0 },123
{ opacity: 1 }124
], {125
duration: 200,126
fill: 'both'127
});128
setTimeout(function() {129
if(state.timestamp === code) {130
node.notification.animate([131
{ opacity: 1 },132
{ opacity: 0 }133
], {134
duration: 200,135
fill: 'both'136
});137
}138
}, 5000);139
}
1
import { LOCALES } from '../constant.js';2
import { uuid, query } from '../util.js';4
import locale from '../mod/locale.js';6
let node;7
let state = {8
deferredPrompt: null9
};11
export function init() {13
locale.init();14
locale.load('./asset/lang', LOCALES);16
node = query({17
notification: '.notification'18
});20
let elements = document.querySelectorAll('[data-event]');21
for(let element of elements) {22
let value = element.dataset.event;24
if(value === 'play') {25
element.addEventListener('click', function() {26
window.location.href = '/app';27
});28
}30
if(value === 'install') {31
element.addEventListener('click', function() {32
if(state.deferredPrompt) {33
state.deferredPrompt.prompt();34
state.deferredPrompt.userChoice.then(function(result) {35
// let installed = result.outcome === 'accepted';36
});37
}38
else {39
show_notification('main.upcoming');40
}41
});42
}43
}45
let header = document.querySelector('header');46
header.classList.remove('transparent');47
header.animate([48
{ opacity: 0 },49
{ opacity: 1 }50
], {51
duration: 400,52
fill: 'both',53
easing: 'ease-in'54
});56
let brand_logo = document.querySelector('.brand-logo');57
brand_logo.classList.remove('transparent');58
brand_logo.animate([59
{ opacity: 0 },60
{ opacity: 1 }61
], {62
duration: 200,63
fill: 'both',64
easing: 'ease-in',65
delay: 40066
});68
let logo = document.querySelector('.logo');69
logo.classList.remove('transparent');70
logo.animate([71
{ opacity: 0, marginTop: '50px' },72
{ opacity: 1, marginTop: 0 }73
], {74
duration: 400,75
fill: 'both',76
easing: 'ease-out',77
delay: 60078
});80
let info = document.querySelector('.header-info');81
info.classList.remove('transparent');82
info.animate([83
{ opacity: 0, marginTop: '50px' },84
{ opacity: 1, marginTop: 0 }85
], {86
duration: 400,87
fill: 'both',88
easing: 'ease-out',89
delay: 60090
});92
window.addEventListener('beforeinstallprompt', function(event) {93
event.preventDefault();94
state.deferredPrompt = event;95
});96
}98
function show_notification(message) {99
let code = uuid();100
state.timestamp = code;101
let content = node.notification.querySelector('.content');102
content.textContent = locale.get()[message];103
node.notification.animate([104
{ opacity: 0 },105
{ opacity: 1 }106
], {107
duration: 200,108
fill: 'both'109
});110
setTimeout(function() {111
if(state.timestamp === code) {112
node.notification.animate([113
{ opacity: 1 },114
{ opacity: 0 }115
], {116
duration: 200,117
fill: 'both'118
});119
}120
}, 5000);121
}
3
import ripple from './mod/ripple.js';5
const path = isApp() ? './app/index.js' : './home/index.js';5
const path = isApp() ? './app.js' : './home.js';7
window.addEventListener('load', init);
1
const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;2
const MAX_HISTORY_STEP = 10;4
import { COLORS } from '../constant.js';6
let active;7
let point_list = [];8
let width;9
let height;10
let size;11
let last;12
let ratio;13
let backing_store_ratio;15
let canvas;16
let overlay;17
let memory;18
let temporary;19
let g;20
let o;21
let m;22
let t;24
function init() {25
width = window.innerWidth;26
height = window.innerHeight;27
canvas = document.querySelector('#canvas');28
overlay = document.querySelector('#overlay');29
memory = document.createElement('canvas');30
temporary = document.createElement('canvas');31
g = canvas.getContext('2d');32
o = overlay.getContext('2d');33
m = memory.getContext('2d');34
t = temporary.getContext('2d');35
resize();36
window.addEventListener('resize', resize);37
}39
function get_canvas() {40
return canvas;41
}43
function resize() {44
width = window.innerWidth;45
height = window.innerHeight;46
let max = width > height ? width : height;47
if(!size || max > size) {48
last = size;49
size = max;50
}51
else {52
last = null;53
}54
backing_store_ratio = (55
g.webkitBackingStorePixelRatio ||56
g.mozBackingStorePixelRatio ||57
g.msBackingStorePixelRatio ||58
g.oBackingStorePixelRatio ||59
g.backingStorePixelRatio || 160
)61
ratio = DEVICE_PIXEL_RATIO / backing_store_ratio;62
let buffer = document.createElement('canvas');63
let b = buffer.getContext('2d');64
scale_canvas(buffer, b, last || size);65
b.imageSmoothingEnabled = false;66
b.clearRect(0, 0, size, size);67
b.drawImage(canvas, 0, 0, last || size, last || size);68
scale_canvas(canvas, g, size);69
g.imageSmoothingEnabled = false;70
g.drawImage(buffer, 0, 0, last || size, last || size);71
scale_canvas(overlay, o, size);72
o.imageSmoothingEnabled = false;73
scale_canvas(memory, m, size);74
m.imageSmoothingEnabled = false;75
m.drawImage(canvas, 0, 0, last || size, last || size);76
b.clearRect(0, 0, size, size);77
b.drawImage(temporary, 0, 0, last || size, last || size);78
scale_canvas(temporary, t, size);79
t.imageSmoothingEnabled = false;80
t.drawImage(buffer, 0, 0, last || size, last || size);81
}83
function scale_canvas(canvas, g, size, height) {84
if(DEVICE_PIXEL_RATIO !== backing_store_ratio) {85
canvas.width = size * ratio;86
canvas.height = (height || size) * ratio;87
canvas.style.width = size + 'px';88
canvas.style.height = (height || size) + 'px';89
}90
else {91
canvas.width = size;92
canvas.height = height || size;93
canvas.style.width = '';94
canvas.style.height = '';95
}96
g.scale(ratio, ratio);97
}99
function clear(state) {100
g.clearRect(0, 0, size, size);101
m.clearRect(0, 0, size, size);102
t.clearRect(0, 0, size, size);103
state.history = [];104
state.redo_history = [];105
}107
function on_press(event, state) {108
point_list.push({109
x: event.layerX,110
y: event.layerY111
});112
active = true;113
state.redo_history = [];114
draw_curve(g, state, point_list);115
}117
function on_move(event, state) {118
if(active) {119
g.clearRect(0, 0, size, size);120
g.drawImage(memory, 0, 0, size, size);121
point_list.push({122
x: event.layerX,123
y: event.layerY124
});125
draw_curve(g, state, point_list);126
}127
}129
function on_release(event, state, undrag) {130
if(active) {131
if((event && event.type === 'pointerup') || undrag) {132
active = false;133
}134
if(point_list.length > 0) {135
state.history.push({136
list: point_list,137
state: Object.assign({}, state)138
});139
if(state.history.length > MAX_HISTORY_STEP) {140
let line = state.history.shift();141
draw_curve(t, line.state, line.list);142
}143
}144
m.clearRect(0, 0, size, size);145
m.drawImage(canvas, 0, 0, size, size);146
point_list = [];147
}148
}150
function undo(state) {151
if(state.history.length > 0) {152
state.redo_history.push(state.history.pop());153
g.clearRect(0, 0, size, size);154
m.clearRect(0, 0, size, size);155
g.drawImage(temporary, 0, 0, size, size);156
m.drawImage(temporary, 0, 0, size, size);157
for(let line of state.history) {158
draw_curve(g, line.state, line.list);159
draw_curve(m, line.state, line.list);160
}161
}162
}164
function redo(state) {165
if(state.redo_history.length > 0) {166
let line = state.redo_history.pop();167
state.history.push(line);168
draw_curve(g, line.state, line.list);169
draw_curve(m, line.state, line.list);170
}171
}173
function draw_curve(g, state, point_list) {174
if(state.pencil === 'pen') {175
g.strokeStyle = COLORS[state.color];176
g.fillStyle = COLORS[state.color];177
}178
if(state.pencil === 'marker') {179
g.strokeStyle = COLORS[state.color] + '88';180
g.fillStyle = COLORS[state.color] + '88';181
}182
if(state.pencil === 'eraser') {183
g.strokeStyle = 'white';184
g.fillStyle = 'white';185
}186
g.lineCap = 'round';187
g.lineJoin = 'round';188
g.lineWidth = 2 * state.radius;189
if(point_list.length < 3) {190
g.beginPath();191
g.arc(point_list[0].x, point_list[0].y, g.lineWidth / 2, 0, Math.PI * 2, !0);192
g.closePath();193
g.fill();194
return;195
}196
g.beginPath();197
g.moveTo(point_list[0].x, point_list[0].y);198
let i;199
for(i = 1; i < point_list.length - 2; i++) {200
let dx = (point_list[i].x + point_list[i + 1].x);201
let dy = (point_list[i].y + point_list[i + 1].y);202
g.quadraticCurveTo(point_list[i].x, point_list[i].y, parseInt(dx / 2), parseInt(dy / 2));203
}204
g.quadraticCurveTo(point_list[i].x, point_list[i].y, point_list[i + 1].x, point_list[i + 1].y);205
g.stroke();206
}208
function draw_cursor(state) {209
o.clearRect(0, 0, size, size);210
o.lineWidth = 2;211
if(state.point) {212
if(state.pencil === 'pen') {213
o.fillStyle = COLORS[state.color];214
}215
if(state.pencil === 'marker') {216
o.fillStyle = COLORS[state.color] + '88';217
}218
if(state.pencil === 'eraser') {219
o.fillStyle = COLORS[state.color] + '55';220
}221
o.beginPath();222
o.arc(state.point.x, state.point.y, 2 * state.radius / 2, 0, Math.PI * 2, !0);223
o.closePath();224
o.fill();225
o.strokeStyle = 'white';226
o.beginPath();227
o.arc(state.point.x, state.point.y, 2 * state.radius / 2, 0, Math.PI * 2, !0);228
o.closePath();229
o.stroke();230
if(state.pencil === 'eraser') {231
o.strokeStyle = 'white';232
o.beginPath();233
o.moveTo(state.point.x - state.radius * 0.5, state.point.y);234
o.lineTo(state.point.x + state.radius * 0.5, state.point.y);235
o.stroke();236
o.beginPath();237
o.moveTo(state.point.x, state.point.y - state.radius * 0.5);238
o.lineTo(state.point.x, state.point.y + state.radius * 0.5);239
o.stroke();240
}241
}242
}244
function draw_crop(state) {245
o.clearRect(0, 0, size, size);246
if(state.option.crop_mode) {247
o.fillStyle = 'rgba(0, 0, 0, 0.3)';248
o.beginPath();249
o.rect(0, 0, size, size);250
o.fill();251
if(state.region && state.region.length == 2) {252
let [ begin, end ] = state.region;253
if(begin && end) {254
let delta = {255
x: end.x - begin.x,256
y: end.y - begin.y257
};258
if(delta.x != 0 && delta.y != 0) {259
o.clearRect(begin.x, begin.y, delta.x, delta.y);260
o.strokeStyle = 'white';261
o.beginPath();262
o.rect(begin.x, begin.y, delta.x, delta.y);263
o.stroke();264
}265
}266
}267
}268
}270
function clear_cursor() {271
o.clearRect(0, 0, size, size);272
}274
function set_data(data) {275
let image = new Image();276
image.onload = function(event) {277
g.drawImage(image, 0, 0);278
m.drawImage(image, 0, 0);279
t.drawImage(image, 0, 0);280
}281
image.src = data;282
}284
function get_data() {285
return canvas.toDataURL();286
}288
function create_capture(x, y, width, height, offset) {289
if(!offset) {290
offset = 0;291
}292
let cache = document.createElement('canvas');293
let c = cache.getContext('2d');294
scale_canvas(cache, c, width * ratio, (height - offset) * ratio);295
c.translate(-x * ratio, -(y * ratio + offset));296
c.fillStyle = 'white';297
c.fillRect(0, 0, window.innerWidth * ratio, window.innerHeight * ratio);298
c.drawImage(canvas, 0, 0 - offset);299
let data = cache.toDataURL() || null;300
cache.remove();301
return data;302
}304
export default {305
init,306
get_canvas,307
resize,308
scale_canvas,309
clear,310
on_press,311
on_move,312
on_release,313
undo,314
redo,315
draw_curve,316
draw_cursor,317
draw_crop,318
clear_cursor,319
set_data,320
get_data,321
create_capture322
};
1
const CONFIG_COOKIE_PROPERTY = 'outline.custom.accepted';3
function requestPermission(element) {4
return new Promise(function(resolve, reject) {5
element.onclick = function() {6
localStorage.setItem(CONFIG_COOKIE_PROPERTY, true);7
resolve();8
}9
});10
}12
function hasAccepted() {13
return localStorage.getItem(CONFIG_COOKIE_PROPERTY) === 'true';14
}16
function reset() {17
localStorage.removeItem(CONFIG_COOKIE_PROPERTY);18
}20
export default {21
requestPermission,22
hasAccepted,23
reset24
}
1
body.home {3
button.button {3
button.button:not(.accept) {4
display: inline-flex;5
justify-content: center;6
align-items: center;
880
margin-bottom: 60px;881
}882
}884
.cookie {885
display: flex;886
position: fixed;887
bottom: 43px;888
align-items: center;889
justify-content: space-between;890
padding: 14px 24px;891
background: @brand-blue;892
border-radius: 4px;893
width: 800px;894
border: 1px solid @brand-blue;895
z-index: 999;896
left: calc(50vw - 400px);897
gap: 20px;899
p {900
font-size: 16px;901
color: white;902
user-select: none;903
pointer-events: none;904
align-content: flex-start;905
line-height: 24px;906
}908
button.button.accept {909
font-size: 16px;910
font-weight: 500;911
color: white;912
white-space: nowrap;913
user-select: none;914
background: inherit;916
&:hover {917
background: rgba(black, 0.05);918
}919
}921
.group {922
display: inline-flex;923
align-items: center;924
gap: 15px;925
}927
a {928
font-size: 16px;929
color: white;930
white-space: nowrap;931
user-select: none;932
text-decoration: none;934
&:hover {935
text-decoration: underline;936
}937
}938
}