HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body>
<div id='option_section' class='horizontal_center'>
<button id='pick_color' class='change_mode_button change_line_button selected'>Pick Color From Image </button>
<button id='edit_image' class='change_mode_button change_line_button'>Edit Image</button>
<button id='take_image' class='change_mode_button change_line_button'>Take Image</button>
</div>
<div class='center_screen'>
<div id='drop_section'>
<div>
<input id="myFileInput" type="file" accept="image/*">
<svg class='broswe_button' fill="none" stroke='currentColor' stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" shape-rendering="geometricPrecision" viewBox="0 0 24 24" height="24" width="24" style="color: currentcolor;"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><path d="M21 15l-5-5L5 21"></path></svg><br>
<div>Browse or Drop Image here</div>
</div>
<div class='hor_center' id='cancel_section'>
<button id='cancel_button' class='change_mode_button full_width'>Cancel</button><br>
</div>
</div>
</div>
<div class='vertical_center'>
<div id='canvas_wrapper' class='box-shadow-transition '>
<canvas ></canvas>
</div>
</div>
<div id='wrapper'>
<table cellspacing="0">
<tbody>
</tbody>
</table>
</div>
<div class='scene scene_1'>
<div id='upload_section' class='box-shadow-transition'>
<div class='expand_button'>
<svg id="Capa_1" x="0px" y="0px" viewBox="0 0 478.5 478.5" style="enable-background:new 0 0 478.5 478.5;" xml:space="preserve">
<g>
<path d="M458.1,0.5H20.3C9.1,0.5,0,9.6,0,20.8v436.9C0,468.9,9.1,478,20.3,478h436.9c11.2,0,20.3-9.1,21.3-19.3V20.9 C478.5,9.7,469.3,0.5,458.1,0.5z M437.8,438.4H39.6V40.2h398.3v398.2H437.8z"/>
<path d="M218.4,376.5c0,11.2,9.1,20.3,20.3,20.3h137.2c11.2,0,20.3-9.1,21.3-20.3V239.3c0-11.2-9.1-20.3-20.3-20.3 s-20.3,9.1-20.3,20.3v116.8H238.7C227.5,356.1,218.4,365.3,218.4,376.5z"/>
<path d="M101.5,259.6c10.2,0,19.3-9.1,19.3-20.3V122.5h117.9c11.2,0,20.3-9.1,20.3-20.3s-9.1-20.3-20.3-20.3H101.5 c-11.2,0-20.3,9.1-20.3,20.3v137.1C81.2,250.5,90.4,259.6,101.5,259.6z"/>
</g>
</svg>
</div>
<div class='hor_center'>
<div id='use_image'>
<div>Use your image</div>
<input id="Input" type="file" accept="image/*">
</div>
</div>
<div>
<strong>Data protection</strong> is important. You could turn off your WIFI while processing your image. All process is done in your broswer.
</div>
</div>
<div id='color_section' class='box-shadow-transition'>
<div id='circle_section'>
<span class='round_circle' style='background-color:rgb(255, 95, 86)'></span>
<span class='round_circle' style='background-color:rgb(255, 189, 46)'></span>
<span class='round_circle' style='background-color:rgb(39, 201, 63)'></span>
</div>
<div class='hor_center' style='flex-direction: column;align-items: center;'>
<div>Colors</div>
<hr />
</div>
<div id='big_box'>
<div class='container'>
<div class='box'></div>
<div class='vert_center'>
<div class='color_box'>
<span> HEX: </span><span id='hex_value' class='selectable_text big_right_padding'></span>
</div>
<svg class='copy_button' viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none" shape-rendering="geometricPrecision" class="jsx-418323402" style="color: currentcolor;"><path d="M8 17.929H6c-1.105 0-2-.912-2-2.036V5.036C4 3.91 4.895 3 6 3h8c1.105 0 2 .911 2 2.036v1.866m-6 .17h8c1.105 0 2 .91 2 2.035v10.857C20 21.09 19.105 22 18 22h-8c-1.105 0-2-.911-2-2.036V9.107c0-1.124.895-2.036 2-2.036z" class="jsx-418323402"></path></svg>
</div>
</div>
</div>
<div id='small_box'>
<div class='container'>
<div class='box'></div>
<div class='vert_center'>
<div class='color_box'>
<span>RGBA:</span> <span id='rgba_value' class='selectable_text big_right_padding'></span>
</div>
<svg class='copy_button' viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none" shape-rendering="geometricPrecision" class="jsx-418323402" style="color: currentcolor;"><path d="M8 17.929H6c-1.105 0-2-.912-2-2.036V5.036C4 3.91 4.895 3 6 3h8c1.105 0 2 .911 2 2.036v1.866m-6 .17h8c1.105 0 2 .91 2 2.035v10.857C20 21.09 19.105 22 18 22h-8c-1.105 0-2-.911-2-2.036V9.107c0-1.124.895-2.036 2-2.036z" class="jsx-418323402"></path></svg>
</div>
</div>
</div>
<div id='check_box_section'>
<hr />
<div id='checkbox'>
<input id='check_box' type='checkbox' checked >
<label for='check_box'>Include Alpha value</label>
</div>
</div>
</div>
</div>
<div class='scene_2 scene'>
<nav >
<div class='hor_center column-flex icon_section' >
<div id='filter_button' class='button hor_center ' >
<svg class='button_hover' id="Layer_1" x="0px" y="0px" viewBox="0 0 512.001 512.001" s xml:space="preserve">
<g>
<path d="M123.901,168h-15.802c0,15.494-12.605,28.099-28.099,28.099v15.802c15.494,0,28.099,12.605,28.099,28.099h15.802 c0-15.494,12.605-28.099,28.099-28.099v-15.802C136.506,196.099,123.901,183.494,123.901,168z M116,214.899 c-2.966-4.24-6.659-7.934-10.9-10.899c4.24-2.966,7.934-6.659,10.9-10.899c2.966,4.24,6.659,7.934,10.899,10.899 C122.659,206.966,118.966,210.658,116,214.899z"/>
<path d="M144.001,336.098c-35.344,0-64.099-28.754-64.099-64.099H64.1c0,35.344-28.754,64.099-64.099,64.099v15.802 c35.344,0,64.099,28.754,64.099,64.099h15.802c0-35.344,28.754-64.099,64.099-64.099V336.098z M72.001,381.369 c-7.862-16.282-21.088-29.506-37.37-37.37c16.282-7.862,29.506-21.088,37.37-37.37c7.862,16.282,21.088,29.506,37.37,37.37 C93.089,351.863,79.863,365.088,72.001,381.369z"/>
<path d="M479.901,168h-15.802c0,17.699-14.399,32.099-32.099,32.099v15.802c17.699,0,32.099,14.399,32.099,32.099h15.802 c0-17.699,14.399-32.099,32.099-32.099v-15.802C494.302,200.099,479.901,185.699,479.901,168z M472,221.672 c-3.584-5.428-8.244-10.087-13.671-13.671c5.428-3.584,10.087-8.244,13.671-13.671c3.584,5.428,8.244,10.087,13.671,13.671 C480.244,211.585,475.585,216.244,472,221.672z"/>
<path d="M240.001,240.098v15.802C257.7,255.901,272.1,270.3,272.1,288h15.802c0-17.699,14.399-32.099,32.099-32.099v-15.802 c-17.699,0-32.099-14.399-32.099-32.099H272.1C272.099,225.699,257.7,240.098,240.001,240.098z M280,234.328 c3.584,5.428,8.244,10.087,13.671,13.671c-5.428,3.584-10.087,8.244-13.671,13.671c-3.584-5.428-8.244-10.087-13.671-13.671 C271.757,244.416,276.416,239.756,280,234.328z"/>
<path d="M32.1,87.947h15.802c0-17.699,14.399-32.099,32.099-32.099V40.046c-17.699,0-32.099-14.399-32.099-32.099H32.1 C32.1,25.645,17.7,40.046,0,40.046v15.802C17.699,55.848,32.1,70.248,32.1,87.947z M40.001,34.276 c3.584,5.428,8.244,10.087,13.671,13.671c-5.428,3.584-10.087,8.244-13.671,13.671c-3.584-5.428-8.244-10.087-13.671-13.671 C31.757,44.363,36.416,39.703,40.001,34.276z"/>
<path d="M352.099,80.001h15.802c0-17.699,14.399-32.099,32.099-32.099V32.099c-17.699,0-32.099-14.399-32.099-32.099h-15.802 c0,17.699-14.399,32.099-32.099,32.099v15.802C337.699,47.901,352.099,62.301,352.099,80.001z M360.001,26.329 c3.584,5.428,8.244,10.087,13.671,13.671c-5.428,3.584-10.087,8.244-13.671,13.671c-3.584-5.428-8.244-10.087-13.671-13.671 C351.757,36.415,356.416,31.757,360.001,26.329z"/>
<path d="M183.902,432H168.1c0,17.699-14.399,32.099-32.099,32.099v15.802c17.699,0,32.099,14.399,32.099,32.099h15.802 c0-17.699,14.399-32.099,32.099-32.099V464.1C198.301,464.098,183.902,449.699,183.902,432z M176.001,485.671 c-3.584-5.428-8.244-10.087-13.671-13.671c5.428-3.584,10.087-8.244,13.671-13.671c3.584,5.428,8.244,10.087,13.671,13.671 C184.245,475.585,179.585,480.243,176.001,485.671z"/>
<path d="M359.902,288h-15.802c0,57.4-46.698,104.099-104.099,104.099v15.802c57.4,0,104.099,46.698,104.099,104.099h15.802 c0-57.4,46.698-104.099,104.099-104.099v-15.802C406.6,392.099,359.902,345.4,359.902,288z M352,469.181 c-12.171-31.723-37.457-57.01-69.18-69.18c31.723-12.171,57.01-37.457,69.18-69.18c12.171,31.723,37.457,57.01,69.18,69.18 C389.458,412.171,364.172,437.458,352,469.181z"/>
<path d="M168.1,184h15.802c0-44.167,35.932-80.099,80.098-80.099V88.099c-44.167,0-80.098-35.932-80.098-80.099H168.1 c0,44.167-35.932,80.099-80.099,80.099v15.802C132.167,103.901,168.1,139.833,168.1,184z M176.001,46.116 C185.69,68.399,203.602,86.311,225.885,96c-22.284,9.689-40.195,27.601-49.884,49.884C166.312,123.601,148.4,105.689,126.117,96 C148.399,86.311,166.312,68.399,176.001,46.116z"/>
</g>
</svg>
</div>
<div class='button hor_center' id='download_button'>
<svg id="Capa_1" x="0px" y="0px" viewBox="0 0 490 490" style="enable-background:new 0 0 490 490;" xml:space="preserve">
<g>
<path d="M245,0c-9.5,0-17.2,7.7-17.2,17.2v331.2L169,289.6c-6.7-6.7-17.6-6.7-24.3,0s-6.7,17.6,0,24.3l88.1,88.1 c3.3,3.3,7.7,5,12.1,5c4.4,0,8.8-1.7,12.1-5l88.1-88.1c6.7-6.7,6.7-17.6,0-24.3c-6.7-6.7-17.6-6.7-24.3,0L262,348.4V17.1 C262.1,7.6,254.5,0,245,0z"/>
<path d="M462.1,472.9v-99.7c0-9.5-7.7-17.2-17.2-17.2s-17.2,7.7-17.2,17.2v82.6H62.2v-82.6c0-9.5-7.7-17.2-17.1-17.2 s-17.2,7.7-17.2,17.2v99.7c0,9.5,7.7,17.1,17.2,17.1h399.8C454.4,490,462.1,482.4,462.1,472.9z"/>
</g>
</svg>
</div>
<div class='button hor_center' id='text_button'>
<svg id="Layer_1" x="0px" y="0px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
<path id="Text-tool" d="M61.3532181,2.3886499C60.8721352,0.77235,59.5148201-0.01455,58.5148201-0.01455 c0.1809998,0-34.7579002-0.0136-47.8758011-0.0136c-2.9957004,0-4.8558855,0.0007-4.8970003,0.0024 C4.03302,0.04665,2.8945198,1.17215,2.6395199,2.3886499c-0.1513853,0.7219-0.0975001-0.6331999-0.0975001,17.8031998 c0,0-0.0025001,0.1509991,0.0431149,0.5279999c0.3898852,1.8477001,1.9273851,2.7136993,3.7625849,2.7136993 c3.2359004,0,7.3954997-2.6949997,7.8070998-7.4528999l0.0207005-0.408l11.2912998-0.0352001h0.0207005h0.0016994 l0.0030994,0.0016003h0.0016003h0.0016994h0.0016003h0.0015011l0.0016994,0.0016003h0.0014992l0.0017014,0.0015993 l0.0015984,0.0016003h0.0015011v0.0015001h0.0016003l0.0016003,0.0017004l0.0015984,0.0015993l0.0017014,0.0016003 l0.0014992,0.0016003l0.0016003,0.0015993l0.0016994,0.0016003l0.0016003,0.0016003v0.0016003l0.0016003,0.0015993V15.56145 v0.0016003h0.0014992v0.0015993v0.0016003v0.0016003v0.0016003v0.0015993v0.0032005v0.0223999v35.7071991v0.0161018h-0.0143986 h-3.1519012l-0.1952,0.0046997c-2.1146984,0.1585999-3.6665001,1.4902992-4.2159996,3.1264 c-0.3606987,1.0737991-0.2768002,1.3132019-0.2768002,4.6864014c0-0.1016006-0.0038986-0.1478004-0.0072002-0.1478004 c-0.0289993,0-0.0064983,3.6250992,3.2392006,4.6997986c0.8012009,0.2653008,8.0429993,0.3387032,13.7827168,0.3387032 c3.6510811,0,6.695282-0.0297012,7.0844841-0.0587006c2.1296997-0.1585007,3.7221985-1.5070038,4.2767982-3.1712036 c0.3525009-1.0578995,0.2784004-1.1899986,0.2784004-4.8223c0,0.1053009,0.0043983,0.1532021,0.0082016,0.1532021 c0.0326996,0,0.0238991-3.4556999-3.0914001-4.5245018c-0.7382011-0.2531967-1.0839005-0.2933998-2.3179016-0.2933998 c-0.5741005,0-1.3403015,0.0087013-2.4277992,0.0087013h-0.0191002h-0.0015984h-0.0016022v-0.0017014h-0.0017014v-0.0015984 v-0.0014992l-0.0014992-0.0193024v-35.7584h11.3472023c0.0711975,4.3004007,3.4926987,7.6778002,7.5631981,7.8448 c0.161499,0.0065994,0.3395996,0.0132008,0.5285988,0.0132008c0.9820023,0,2.258503-0.1779003,3.021801-1.4531002 c0.1542015-0.2577,0.3399162-0.5668011,0.4239998-0.964901C61.5488167,20.0512505,61.4547195,2.7297499,61.3532181,2.3886499z M59.3847198,20.60145c-0.0300026,0.0771008-0.1038017,0.2003994-0.1716995,0.3138008 c-0.1514015,0.2529984-0.365303,0.4801998-1.305603,0.4801998c-0.1597977,0-0.3101997-0.0059013-0.4466972-0.0115013 c-3.113102-0.1276989-5.5929031-2.7103996-5.645401-5.8795996l-0.0326004-1.9668999h-1.9670982H38.4684181h-2v2v35.7584 l0.0014992,0.1002998l0.000103,0.0007019l0.0015984,1.9213982h0.0223007v0.0017014h2 c0.6343002,0,1.160099-0.0028992,1.6026001-0.0054016l0.8251991-0.0032997c1.1290016,0,1.2220001,0.0319023,1.6688004,0.1851997 c1.5298004,0.5248032,1.7195015,2.1091003,1.7429008,2.4794998h-0.010601c0,0.6244011,0.0021019,1.1459007,0.0040016,1.5868034 c0.0084991,2.0380974,0.0049973,2.0486984-0.1798019,2.603199c-0.3364983,1.0097008-1.328701,1.719799-2.5223007,1.8085976 c-0.3591003,0.0223999-3.1736984,0.0536003-6.9415817,0.0536003c-8.014616,0-12.3816166-0.1307983-13.229002-0.263298 c-1.5624142-0.5666008-1.7668152-2.2266998-1.7934151-2.6273994h0.0077c0-0.6242027-0.0028992-1.1417999-0.0052834-1.5777016 c-0.0105152-1.9106979,0.0000839-1.9423981,0.1779995-2.4719009c0.3275852-0.975399,1.2783852-1.6649971,2.4289989-1.7654991 l0.0862846-0.0023994h3.1662998l2-0.0161018v-2v-35.740799l-0.0014992-2h-0.0160007v-0.0192003h-1.1827984l-0.0032864-0.0031996 h-0.0064144l-0.0016994-0.0016003h-0.3686008l-0.0065002-0.0031004l-0.475399,0.0015001L14.1693192,13.57265l-1.8946991,0.0060005 l-0.0964851,1.8922997l-0.0189152,0.3703003c-0.3339996,3.6491995-3.5845003,5.5922995-5.8115001,5.5922995 c-1.4372997,0-1.7073998-0.7124996-1.7876997-1.0459003c-0.0123-0.1110001-0.0171003-0.176899-0.0180001-0.1957989 c0-4.9156008-0.0038853-8.4246006-0.0065999-10.9412003C4.5306196,4.8678498,4.52882,3.22785,4.56392,2.94785l0.0330997-0.1489 c0.0560002-0.2672999,0.3793001-0.7795,1.2026-0.8250999c0.2771001-0.0015,2.0718999-0.002,4.8518-0.002h0.0067997 c13.0723009,0,47.7075005,0.0135,47.8549156,0.0136c0.0972862,0.0036,0.604084,0.1615999,0.8646851,0.8062 C59.4665184,4.8607502,59.5204201,18.9434509,59.3847198,20.60145z"/>
</svg>
</div>
<div class='button hor_center' id='art_button'>
<svg id="Capa_1" x="0px" y="0px" viewBox="0 0 325.04 325.04" xml:space="preserve">
<g>
<path d="M117.866,234.088c-2.956,14.532-4.875,21.558-16.092,22.458c-2.764,0.222-5.015,2.308-5.446,5.047 c-0.432,2.738,1.069,5.416,3.631,6.477c0.721,0.298,17.877,7.308,37.921,7.309c0.003,0,0.005,0,0.007,0 c13.968,0,25.95-3.386,35.612-10.063c11.45-7.912,19.344-20.294,23.541-36.788l-38.572-38.88 C125.871,194.924,121.253,217.436,117.866,234.088z"/>
<path d="M322.745,63.336c-1.037-1.046-2.887-2.293-5.806-2.293c-3.423,0-12.516,0-67.74,46.992 c-25.509,21.706-54.92,48.559-78.314,71.41l36.603,36.894c24.061-25.009,52.129-56.355,74.451-83.258 c14.096-16.986,24.935-31.002,32.216-41.657C323.799,77.311,328.023,68.655,322.745,63.336z"/>
<path d="M182.595,278.479c-12.387,8.56-27.429,12.899-44.716,12.899c-22.753-0.001-41.919-7.649-44.046-8.527 c-9.425-3.906-14.898-13.673-13.31-23.749c1.555-9.871,9.463-17.373,19.341-18.446c0.861-2.571,1.813-7.254,2.323-9.758 c1.878-9.23,4.449-21.873,12.358-33.126c8.637-12.287,21.656-20.165,38.751-23.466c9.811-9.737,21.005-20.443,32.686-31.308 c-5.905-1.281-11.185-5.127-14.017-10.944c-4.875-10.02-0.623-22.073,9.484-26.895c10.133-4.834,22.287-0.612,27.155,9.423 c0.961,1.978,1.555,4.033,1.832,6.096c9.688-8.677,19.309-17.099,28.392-24.828c0.054-0.046,0.105-0.09,0.16-0.136 c-10.209-19.536-24.849-36.845-42.687-50.098c-25.614-19.031-56.114-29.096-88.2-29.104c-0.01,0-0.017,0-0.025,0 c-21.654,0-47.976,7.566-68.697,19.749C13.981,51.193-0.005,71.163,0,92.49c0.008,25.748,14.53,36.518,26.199,45.171 c9.515,7.057,17.03,12.63,17.034,24.844c0.003,12.213-7.508,17.781-17.018,24.831c-11.665,8.648-26.184,19.412-26.176,45.163 c0.006,21.324,14.001,41.299,39.406,56.244c20.736,12.198,47.072,19.78,68.73,19.786c0.015,0,0.028,0,0.042,0 c39.305,0,76.254-15.171,104.044-42.72c20.837-20.655,34.656-46.416,40.273-74.442c-13.952,15.471-27.997,30.493-40.563,43.322 C206.641,253.965,196.773,268.682,182.595,278.479z M111.054,77.103c2.498-10.871,13.4-17.657,24.354-15.167 c10.939,2.478,17.793,13.282,15.313,24.138c-2.499,10.844-13.407,17.631-24.362,15.154 C115.411,98.764,108.554,87.947,111.054,77.103z M45.054,114.152c-7.005-8.716-5.565-21.401,3.216-28.339 c8.78-6.925,21.571-5.505,28.589,3.195c6.99,8.703,5.545,21.388-3.229,28.34C64.869,124.288,52.058,122.853,45.054,114.152z M55.746,247.168c-8.786-6.944-10.231-19.629-3.226-28.342c7-8.696,19.796-10.122,28.581-3.18 c8.778,6.943,10.224,19.629,3.225,28.327C77.327,252.686,64.53,254.111,55.746,247.168z"/>
</g>
</svg>
</div>
<div class='button hor_center' id='crop_button'>
<svg id="Capa_1" x="0px" y="0px" viewBox="0 0 199.263 199.263" style="enable-background:new 0 0 199.263 199.263;" xml:space="preserve">
<g>
<rect x="144.317" y="161.148" style="fill:#010002;" width="5.433" height="34.919"/>
<polygon style="fill:#010002;" points="144.317,141.078 149.75,141.078 149.75,46.321 63.131,46.321 63.131,51.75 144.317,51.75 "/>
<rect x="0" y="46.321" style="fill:#010002;" width="43.064" height="5.429"/>
<polygon style="fill:#010002;" points="54.943,147.513 54.943,3.196 49.521,3.196 49.521,152.942 199.263,152.942 199.263,147.513 "/>
</g>
</svg>
</div>
</div>
<div id='explanation'>
<div class='text vert_center'>
<div class='text_hover'>Effects</div>
</div>
<div class='text vert_center'>
<div>Download</div>
</div>
<div class='text vert_center'>
<div>Artsy</div>
</div>
<div class='text vert_center'>
<div>Text</div>
</div>
<div class='text vert_center'>
<div>Crop</div>
</div>
</div>
</nav>
<div id='setting_section' class='box-shadow-transition'>
<div id='circle_section'>
<span class='round_circle' style='background-color:rgb(255, 95, 86)'></span>
<span class='round_circle' style='background-color:rgb(255, 189, 46)'></span>
<span class='round_circle' style='background-color:rgb(39, 201, 63)'></span>
</div>
<hr />
<div id='filter_section'>
<div class='hor_center column-flex'>
<div class='section'>
<div>Brightness</div>
<div class='range_value'></div>
<input type='range' min=0 max=300 value=100>
</div>
<div class='section'>
<div>Saturate</div>
<div class='range_value'></div>
<input type='range' min=0 max=100 value=100>
</div>
<div class='section'>
<div>Contrast</div>
<div class='range_value'></div>
<input type='range' min=0 max=100 value=200>
</div>
<div class='section'>
<div>Grayscale</div>
<div class='range_value'></div>
<input type='range' min=0 max=100 value=0>
</div>
<div class='section'>
<div>Invert</div>
<div class='range_value'></div>
<input type='range' min=0 max=100 value=0>
</div>
<div class='section'>
<div >Blur</div>
<div class='range_value' ></div>
<input type='range' min=0 max=100 value=0>
</div>
<div class='section'>
<div>Hue-rotate</div>
<div class='range_value'></div>
<input type='range' min=0 max=360 value=0>
</div>
<div class='section'>
<div >Sepia</div>
<div class='range_value' ></div>
<input type='range' min=0 max=100 value=0>
</div>
<button class='reset_button'>Reset</button>
</div>
</div>
<div id='download_section'>
<div style='text-align: center;'>
<h2>Download</h2>
</div>
<labe for='file_input'>File Name:</label><br>
<input type='text' id='file_input' value='download_image'>
<div>Format:</div>
<button class='format_button'>JPEG</button>
<button class='format_button'>PNG</button>
<div>Size:</div>
<div id='file_size'></div>
<button class='reset_button' id='download_image_button' style='bottom:30%'>Download</button>
</div>
</div>
</div>
</div>
</div>
<div class='scene_3 scene'>
<div class='horizontal_center '>
<div id='video_container' >
<video id='preview'></video>
<div id='button_container' >
<svg id='take_photo_button' id="Layer_1" x="0px" y="0px" viewBox="0 0 198.931 198.931" >
<g>
<path d="M99.469,69.561c-25.423,0-46.104,20.683-46.104,46.104s20.683,46.104,46.104,46.104 c25.421,0,46.104-20.683,46.104-46.104S124.89,69.561,99.469,69.561z M99.469,146.91c-17.229,0-31.245-14.017-31.245-31.245 c0-17.228,14.017-31.245,31.245-31.245c17.228,0,31.245,14.017,31.245,31.245C130.714,132.892,116.698,146.91,99.469,146.91z"/>
<path d="M175.499,44.681h-72.315h-3.715V27.956c0-9.393-7.64-17.036-17.033-17.036H44.247c-9.393,0-17.033,7.642-17.033,17.036 v16.726h-3.777C10.515,44.681,0,55.194,0,68.116v96.465c0,12.92,10.515,23.43,23.437,23.43h152.059 c12.925,0,23.435-10.51,23.435-23.43V68.116C198.934,55.194,188.421,44.681,175.499,44.681z M42.07,27.956 c0-1.201,0.976-2.176,2.177-2.176h38.189c1.199,0,2.174,0.976,2.174,2.177v16.726H42.07V27.956z M175.499,173.152H23.437 c-4.73,0-8.578-3.846-8.578-8.571V68.116c0-4.73,3.848-8.576,8.578-8.576h5.451H42.07h42.538h18.573h72.315 c4.73,0,8.576,3.846,8.576,8.576v96.465h0.003C184.075,169.306,180.229,173.152,175.499,173.152z"/>
<rect x="156.012" y="71.816" width="18.989" height="14.859"/>
</g>
</svg>
<svg class='delete_button' id="Layer_1" x="0px" y="0px" viewBox="0 0 300.003 300.003" style="enable-background:new 0 0 300.003 300.003;" xml:space="preserve">
<g>
<path d="M150,0C67.159,0,0.001,67.159,0.001,150c0,82.838,67.157,150.003,149.997,150.003S300.002,232.838,300.002,150 C300.002,67.159,232.839,0,150,0z M206.584,207.171c-5.989,5.984-15.691,5.984-21.675,0l-34.132-34.132l-35.686,35.686 c-5.986,5.984-15.689,5.984-21.672,0c-5.989-5.991-5.989-15.691,0-21.68l35.683-35.683L95.878,118.14 c-5.984-5.991-5.984-15.691,0-21.678c5.986-5.986,15.691-5.986,21.678,0l33.222,33.222l31.671-31.673 c5.986-5.984,15.694-5.986,21.675,0c5.989,5.991,5.989,15.697,0,21.678l-31.668,31.671l34.13,34.132 C212.57,191.475,212.573,201.183,206.584,207.171z"/>
</g>
</svg>
<svg class='correct_mark' version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 117.72 117.72" style="enable-background:new 0 0 117.72 117.72" xml:space="preserve"><style type="text/css">
.st0{fill:#01A601;}
</style><g><path class="st0" d="M58.86,0c9.13,0,17.77,2.08,25.49,5.79c-3.16,2.5-6.09,4.9-8.82,7.21c-5.2-1.89-10.81-2.92-16.66-2.92 c-13.47,0-25.67,5.46-34.49,14.29c-8.83,8.83-14.29,21.02-14.29,34.49c0,13.47,5.46,25.66,14.29,34.49 c8.83,8.83,21.02,14.29,34.49,14.29s25.67-5.46,34.49-14.29c8.83-8.83,14.29-21.02,14.29-34.49c0-3.2-0.31-6.34-0.9-9.37 c2.53-3.3,5.12-6.59,7.77-9.85c2.08,6.02,3.21,12.49,3.21,19.22c0,16.25-6.59,30.97-17.24,41.62 c-10.65,10.65-25.37,17.24-41.62,17.24c-16.25,0-30.97-6.59-41.62-17.24C6.59,89.83,0,75.11,0,58.86 c0-16.25,6.59-30.97,17.24-41.62S42.61,0,58.86,0L58.86,0z M31.44,49.19L45.8,49l1.07,0.28c2.9,1.67,5.63,3.58,8.18,5.74 c1.84,1.56,3.6,3.26,5.27,5.1c5.15-8.29,10.64-15.9,16.44-22.9c6.35-7.67,13.09-14.63,20.17-20.98l1.4-0.54H114l-3.16,3.51 C101.13,30,92.32,41.15,84.36,52.65C76.4,64.16,69.28,76.04,62.95,88.27l-1.97,3.8l-1.81-3.87c-3.34-7.17-7.34-13.75-12.11-19.63 c-4.77-5.88-10.32-11.1-16.79-15.54L31.44,49.19L31.44,49.19z"></path></g></svg>
</div>
</div>
</div>
</div>
<div id='notice_section'>
</div>
* {
user-select: none;
-webkit-user-select: none;
}
html {
--opacity: 1;
--outline_size: 5px;
}
::selection {
background-color: #79ffe1;
color: #000;
}
body {
overflow: hidden;
}
}
button,
input[type='file'] {
cursor: pointer;
}
.second_notice {
visibility: visible !important;
transform: translate3d(0, calc(100% - 125px - 20px), -1px) scale(0.95);
}
.third_notice {
visibility: visible !important;
transform: translate3d(0, calc(100% - 125px - 40px), -2px) scale(0.9);
}
.further_notice {
visibility: visible !important;
transform: translate3d(0, calc(100% - 125px - 60px), -3px) scale(0.85);
}
.center_align {
text-align: center;
}
input[type='file'] {
width: 100%;
height: 100%;
opacity: 0;
position: absolute;
left: 0;
top: 0;
z-index: 999;
cursor: pointer;
}
.cropper_point,
.cropper_side {
display: none;
}
.center_screen {
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
position: absolute;
display: none;
}
.change_mode_button {
border: none;
background: transparent;
font-family: sans-serif;
font-size: 1.25em;
display: inline-block;
text-decoration: none;
margin: 1vw;
}
.change_line_button {
opacity: var(--opacity);
}
.change_line_button:after {
content: "";
display: block;
height: 2px;
background: red;
width: 0;
}
.selected:after {
width: 100% !important;
transition: width 0.5s linear;
}
.vert_center {
display: flex;
align-items: center;
height: 100%;
width: 72.5%;
}
.box {
width: 65px;
height: inherit;
background-color: yellow;
border-radius: 5px;
box-shadow: 0 5px 10px rgb(0 0 0 / 12%);
}
.box:hover {
box-shadow: 0 7px 30px rgb(0 0 0 / 12%) !important;
transition: box-shadow 0.1s linear;
}
.container {
position: relative;
height: 100%;
}
.copy_button {
width: 24px;
height: auto;
z-index: 999;
position: absolute;
right: 1.5%;
}
.copy_button:hover {
opacity: 0.75;
}
.selectable_text {
user-select: text !important;
}
.big_right_padding {
padding-right: 10%;
}
canvas {
margin: 0;
border: 0;
padding: 0;
box-shadow: rgba(0, 0, 0, 0.17) 0px -23px 25px 0px inset, rgba(0, 0, 0, 0.15) 0px -36px 30px 0px inset, rgba(0, 0, 0, 0.1) 0px -79px 40px 0px inset, rgba(0, 0, 0, 0.06) 0px 2px 1px, rgba(0, 0, 0, 0.09) 0px 4px 2px, rgba(0, 0, 0, 0.09) 0px 8px 4px, rgba(0, 0, 0, 0.09) 0px 16px 8px, rgba(0, 0, 0, 0.09) 0px 32px 16px;
}
.full_width {
width: 100%;
}
.round_circle {
border-radius: 50%;
width: 0.75rem;
height: 0.75rem;
display: inline-block;
margin: 0.2vw;
}
hr {
width: 92.5%;
background-color: rgb(220, 220, 220);
border: none;
height: 1px;
text-align: center;
}
.vertical_center {
display: flex;
align-items: center;
height: 100vh;
z-index: -1;
}
.horizontal_center {
display: flex;
justify-content: center;
width: 100vw;
z-index: -1;
position: absolute;
left: 0;
top: 0;
}
.hor_center {
width: 100%;
display: flex;
justify-content: center;
}
.column-flex {
flex-direction: column;
}
#canvas_wrapper {
box-shadow: 0 5px 10px rgb(0 0 0 / 12%);
padding: 1vw;
border-radius: 10px;
opacity: var(--opacity);
}
div[class^='scene_'],
div[class*='scene_'] {
display: none;
}
#option_section {
z-index: 999;
}
.notice {
width: 420px;
max-width: 90vw;
max-height: 75px;
display: flex;
font-family: sans-serif;
align-items: center;
color: #000;
background-color: #0070f3;
color: white;
border: 0;
border-radius: 5px;
padding: 16pt;
position: absolute;
top: 100%;
right: 1vw;
box-shadow: none;
visibility: hidden;
transition: transform 400ms ease 0ms, visibility 200ms ease 0ms, opacity 1000ms ease 0ms;
}
img{
display: none;
}
const drop_section = document.querySelector('#drop_section');
const image_editor = document.querySelector('#edit_image');
let image_data;
function calculateAspectRatioFit(srcWidth, srcHeight) {
const ratio = window.innerWidth * 0.45 / srcWidth;
if (srcHeight > window.innerHeight * 0.8) {
// prevent vertical center that overflow if image size is bigger than window.height;
const canvas_wrapper = document.querySelector('#canvas_wrapper');
canvas_wrapper.parentNode.style.display = 'block';
canvas_wrapper.style.position = 'absolute';
canvas_wrapper.style.top = '20vh';
} else {
canvas_wrapper.parentNode.style.display = 'flex';
canvas_wrapper.style.position = 'static';
}
update_position();
return {
width: srcWidth * ratio,
height: srcHeight * ratio };
}
document.querySelectorAll('.change_line_button').forEach(button => {
button.addEventListener('click', function () {
document.querySelector('.selected').classList.remove('selected');
button.classList.add('selected');
});
});
document.querySelector('#cancel_button').addEventListener('click', function () {
drop_section.parentNode.style.display = 'none';
document.documentElement.style.setProperty('--opacity', "1");
document.addEventListener('mousemove', zoom_tool);
});
document.querySelector('.expand_button').addEventListener('click', function () {
drop_section.parentNode.style.display = 'flex';
document.documentElement.style.setProperty('--opacity', "0.5");
setTimeout(() => document.addEventListener('click', close_section));
document.removeEventListener('mousemove', zoom_tool);
});
document.querySelectorAll('.copy_button').forEach(button => {
button.addEventListener('click', function () {
navigator.clipboard.writeText(button.parentNode.querySelector('span:nth-of-type(2)').textContent);
make_notice("Code copied");
});
});
function make_notice(text) {
const notice = document.createElement('div');
notice.className = 'notice';
notice.textContent = text;
document.body.appendChild(notice);
setTimeout(() => notice.classList.add('first_notice'));
const all_notice = document.querySelectorAll('.notice');
let time;
all_notice.forEach((notice, index) => {
if (index < all_notice.length - 3) {
notice.className = 'notice';
notice.classList.add('further_notice');
time = 750;
} else {
if (index === all_notice.length - 2) notice.className = 'notice second_notice';else
if (index === all_notice.length - 3) notice.className = 'notice third_notice';
time = 2000;
}
setTimeout(() => {
notice.style.setProperty('opacity', '0', 'important');
notice.addEventListener('transitionend', () => notice.remove());
}, time);
});
}
document.querySelector('input[type=checkbox]').addEventListener('change', function (event) {
const rgba_value = document.querySelector('#rgba_value');
const hex_value = document.querySelector('#hex_value');
if (event.target.checked) {
document.querySelector('#small_box .color_box > span:nth-of-type(1)').textContent = 'RGBA:';
rgba_value.textContent = rgba_value.textContent.toRGBA("#small_box .box");
hex_value.textContent = rgba_value.textContent.toHex();
} else {
document.querySelector('#small_box .color_box > span:nth-of-type(1)').textContent = 'RGB:';
rgba_value.textContent = rgba_value.textContent.toRGB();
hex_value.textContent = hex_value.textContent.slice(0, -1);
}
});
function close_section(e) {
const [posX, posY] = [e.clientX, e.clientY];
const {
left,
right,
top: top_pos,
bottom } =
drop_section.getBoundingClientRect();
if (!(posX >= left && right >= posX && posY >= top_pos && bottom >= posY)) {
drop_section.parentNode.style.display = 'none';
document.documentElement.style.setProperty('--opacity', "1");
document.removeEventListener('click', close_section);
document.addEventListener('mousemove', zoom_tool);
}
}
const table = document.querySelector('table');
const wrapper = document.querySelector('#wrapper');
for (let i = 0; i < 11; i++) {if (window.CP.shouldStopExecution(0)) break;
const tr = document.createElement('tr');
tr.id = `tr${i}`;
table.querySelector('tbody').appendChild(tr);
for (let index = 0; index < 11; index++) {if (window.CP.shouldStopExecution(1)) break;
const td = document.createElement('td');
td.setAttribute('data-x', index);
td.setAttribute('data-y', i);
tr.appendChild(td);
}window.CP.exitedLoop(1);
}window.CP.exitedLoop(0);
let current_image;
const input = document.querySelector('input[type=file]');
function load_image(url) {
return new Promise(resolve => {
const img = new Image();
img.onload = () => resolve(img);
img.src = url;
return img;
});
}
const canvas = document.querySelector('canvas');
const context = canvas.getContext('2d');
const img = new Image();
current_image = img;
img.crossOrigin = "Anonymous";
img.onload = function () {
context.canvas.width = calculateAspectRatioFit(img.width, img.height).width;
context.canvas.height = calculateAspectRatioFit(img.width, img.height).height;
context.drawImage(img, 0, 0, calculateAspectRatioFit(img.width, img.height).width, calculateAspectRatioFit(img.width, img.height).height);
const data = canvas.toDataURL("image/jpg");
image_data = data;
};
img.src = "https://i0.wp.com/theluxurytravelexpert.com/wp-content/uploads/2014/01/new-york-city-usa.jpg?ssl=1";
drop_section.ondragover = drop_section.ondragenter = function (evt) {
evt.preventDefault();
};
drop_section.ondrop = function (e) {
e.preventDefault();
const file = e.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = async function (event) {
const image = await load_image(event.target.result);
context.canvas.width = calculateAspectRatioFit(image.width, image.height).width;
context.canvas.height = calculateAspectRatioFit(image.width, image.height).height;
current_image = image;
context.drawImage(image, 0, 0, calculateAspectRatioFit(image.width, image.height).width, calculateAspectRatioFit(image.width, image.height).height);
drop_section.parentNode.style.display = 'none';
document.documentElement.style.setProperty('--opacity', "1");
const data = canvas.toDataURL("image/jpg");
image_data = data;
};
reader.readAsDataURL(file);
};
document.querySelectorAll('input[type=file]').forEach(input => {
input.addEventListener('change', function () {
document.documentElement.style.setProperty('--opacity', "1");
drop_section.parentNode.style.display = 'none';
const file = input.files[0];
const read_size = input.files[0].size;
const file_reader = new FileReader();
file_reader.onload = async function (e) {
const image = await load_image(e.target.result);
context.filter = "none";
context.canvas.width = calculateAspectRatioFit(image.width, image.height).width;
context.canvas.height = calculateAspectRatioFit(image.width, image.height).height;
current_image = image;
context.drawImage(image, 0, 0, calculateAspectRatioFit(image.width, image.height).width, calculateAspectRatioFit(image.width, image.height).height);
const data = canvas.toDataURL("image/jpg");
image_data = data;
};
file_reader.readAsDataURL(file);
});
});
function isInCanvas(posX, posY) {
const coord = canvas.getBoundingClientRect();
return posX >= coord.left && posX <= coord.right && posY >= coord.top && posY <= coord.bottom;
}
document.addEventListener('mousemove', zoom_tool);
canvas.addEventListener('click', get_color);
function get_color() {
let color = window.getComputedStyle(document.querySelector('td[data-x="5"][data-y="5"]'))['background-color'];
document.querySelector('#big_box .box').style.backgroundColor = color;
if (document.querySelector('input[type=checkbox]').checked) {
color = color.toRGBA("#big_box .box");
document.querySelector('#hex_value').textContent = color.toHex();
} else {
document.querySelector('#hex_value').textContent = color.toRGBA("#big_box .box").toHex().slice(0, -1);
color = color.toRGB();
}
document.querySelector('#rgba_value').textContent = color;
}
function zoom_tool(e) {
if (!isInCanvas(e.clientX, e.clientY)) {
document.body.style.cursor = "initial";
wrapper.style.display = 'none';
return;
} else wrapper.style.display = 'block';
//document.body.style.cursor='crosshair';
let color = window.getComputedStyle(document.querySelector('td[data-x="5"][data-y="5"]'))['background-color'];
document.querySelector('#small_box .box').style.backgroundColor = color;
const posX = e.clientX - canvas.getBoundingClientRect().left;
const posY = e.clientY - canvas.getBoundingClientRect().top;
const data = canvas.getContext('2d').getImageData(posX - 5, posY - 5, 11, 11).data;
const data_array = [];
for (let i = 0; i < data.length; i += 4) {if (window.CP.shouldStopExecution(2)) break;data_array.push([data[i], data[i + 1], data[i + 2], data[i + 3]]);}window.CP.exitedLoop(2);
table.querySelectorAll('td').forEach((td, index) => {
const rgba = data_array[index];
td.style.backgroundColor = `rgba(${rgba[0]},${rgba[1]},${rgba[2]},${rgba[3]})`;
});
wrapper.style.left = e.pageX + "px";
wrapper.style.top = e.pageY + 'px';
}
window.addEventListener('resize', function () {
const image = current_image;
context.canvas.width = calculateAspectRatioFit(image.width, image.height).width;
context.canvas.height = calculateAspectRatioFit(image.width, image.height).height;
current_image = image;
context.drawImage(image, 0, 0, calculateAspectRatioFit(image.width, image.height).width, calculateAspectRatioFit(image.width, image.height).height);
});
String.prototype.toHex = function () {
const [r, g, b, a] = this.substring(this.indexOf("(") + 1, this.indexOf(")") - 1).split(',').map(Number);
return `#${r.toString(16).padStart(2, 0) + g.toString(16).padStart(2, 0) + b.toString(16).padStart(2, 0) + Math.round(a * 255).toString(16).substring(0, 2)}`;
};
String.prototype.toRGB = function () {
if (!this.toUpperCase().startsWith('RGBA')) return this;
const [r, g, b, a] = this.substring(this.indexOf("(") + 1, this.indexOf(")") - 1).split(',');
return `rgb(${r}, ${g}, ${b})`;
};
String.prototype.toRGBA = function (ele) {
const color = window.getComputedStyle(document.querySelector(ele)).getPropertyValue('background-color');
if (color.toUpperCase().startsWith('RGBA')) return color;else
return `rgba(${color.substring(color.indexOf("(") + 1, color.indexOf(")") - 1)}, 1)`;
};
document.querySelectorAll('input[type=file]').forEach(input => {
input.parentNode.addEventListener('click', function () {
input.parentNode.classList.add('effect');
});
});
const cropper_list = [];
for (let i = 0; i < 8; i++) {if (window.CP.shouldStopExecution(3)) break;
const cropper = document.createElement('div');
cropper.className = `cropper_point cropper_point_${i + 1}`;
document.body.appendChild(cropper);
cropper_list.push(cropper);
}window.CP.exitedLoop(3);;
const cropper_side = [];
for (let i = 0; i < 4; i++) {if (window.CP.shouldStopExecution(4)) break;
const side = document.createElement('div');
side.className = `cropper_side cropper_${(i + 1) % 2 === 0 ? "hor" : "ver"}_${i + 1}`;
document.body.appendChild(side);
cropper_side.push(side);
}window.CP.exitedLoop(4);
function update_position() {
let {
top: canvas_top,
left: canvas_left,
right: canvas_right,
bottom: canvas_bottom,
width: canvas_width,
height: canvas_height } =
document.querySelector('canvas').getBoundingClientRect();
canvas_left += window.scrollX;
canvas_top += window.scrollY;
canvas_bottom += window.scrollY;
canvas_right += window.scrollX;
const outline = parseFloat(getComputedStyle(canvas).getPropertyValue('--outline_size'));
cropper_list[0].style.top = canvas_top + outline / 2 + 'px';
cropper_list[0].style.left = canvas_left + outline / 2 + 'px';
cropper_list[1].style.left = canvas_left + canvas_width / 2 + "px";
cropper_list[1].style.top = canvas_top + outline / 2 + 'px';
cropper_list[2].style.left = canvas_right + outline / 2 + 'px';
cropper_list[2].style.top = canvas_top + outline / 2 + 'px';
cropper_list[3].style.left = canvas_right + outline / 2 + 'px';
cropper_list[3].style.top = canvas_top + canvas_height / 2 + 'px';
cropper_list[4].style.left = canvas_right + outline / 2 + 'px';
cropper_list[4].style.top = canvas_bottom + outline / 2 + 'px';
cropper_list[5].style.left = canvas_left + canvas_width / 2 + "px";
cropper_list[5].style.top = canvas_bottom + outline / 2 + "px";
cropper_list[6].style.left = canvas_left + outline / 2 + 'px';
cropper_list[6].style.top = canvas_bottom + outline / 2 + "px";
cropper_list[7].style.left = canvas_left + outline / 2 + 'px';
cropper_list[7].style.top = canvas_top + canvas_height / 2 + 'px';
cropper_side[0].style.left = canvas_left + 'px';
cropper_side[0].style.height = canvas_height + 'px';
cropper_side[0].style.top = canvas_top + 'px';
cropper_side[1].style.width = canvas_width + 'px';
cropper_side[1].style.left = canvas_left + 'px';
cropper_side[1].style.top = canvas_top + 'px';
cropper_side[2].style.left = canvas_right + 'px';
cropper_side[2].style.height = canvas_height + 'px';
cropper_side[2].style.top = canvas_top + 'px';
cropper_side[3].style.width = canvas_width + 'px';
cropper_side[3].style.left = canvas_left + 'px';
cropper_side[3].style.top = canvas_bottom + 'px';
}
edit_image.addEventListener('click', function () {
active_stylesheet("stylesheet_two");
if (document.querySelector('.photo_canvas')) document.querySelector('.photo_canvas').remove();
preview.style.visibility = 'visible';
all_text_button[0].click();
});
const all_text_button = document.querySelectorAll('.text');
const all_button = document.querySelectorAll('.button');
all_text_button.forEach((text, index) => {
text.addEventListener('click', () => all_button[index].click());
text.addEventListener('mouseenter', () => all_button[index].children[0].classList.add("button_hover"));
text.addEventListener('mouseleave', () => all_button[index].children[0].classList.remove("button_hover"));
});
let prev_index = null;
all_button.forEach((button, index) => {
button.children[0].addEventListener('mouseenter', () => all_text_button[index].children[0].classList.add("text_hover"));
button.addEventListener('mouseleave', () => all_text_button[index].children[0].classList.remove("text_hover"));
button.addEventListener('click', function () {
if (prev_index !== null) {
all_button[prev_index].children[0].style.opacity = 0.45;
all_text_button[prev_index].children[0].style.color = 'rgba(108, 122, 137)';
}
button.children[0].style.setProperty('opacity', "1", "important");
prev_index = index;
all_text_button[index].children[0].style.setProperty('color', "black");
});
//if(button.id=)
});
let timeout;
document.querySelector('nav').addEventListener('mouseenter', e => {
timeout = setTimeout(() => {
e.target.style.width = '11vw';
e.target.querySelector('#explanation').style.display = 'block';
}, 500);
});
document.querySelector('nav').addEventListener('mouseleave', e => {
e.target.style.width = '5vw';
e.target.querySelector('#explanation').style.display = 'none';
if (timeout) window.clearTimeout(timeout);
});
document.querySelector('#crop_button').children[0].addEventListener('click', function () {
document.querySelectorAll('.cropper_point').forEach(i => i.style.display = 'block');
document.querySelectorAll('.cropper_side').forEach(i => i.style.display = 'block');
});
/*
document.querySelectorAll(".cropper_point").forEach(i=>{
i.addEventListener('click',e=>{
canvas.style.width = e.clientX + 'px';
canvas.style.height = e.clientY +'px'
})
})
*/
const all_input_range = document.querySelectorAll('input[type=range]');
function update_input() {
all_input_range.forEach(input => {
const text = input.parentNode.querySelector('div').textContent;
const units = text !== "Blur" ? text !== "Hue-rotate" ? "%" : "deg" : "px";
input.parentNode.querySelector('.range_value').textContent = input.value + units;
});
};
update_input();
all_input_range.forEach(input => {
input.oninput = function () {
const text = input.parentNode.querySelector('div').textContent;
const units = text !== "Blur" ? text !== "Hue-rotate" ? "%" : "deg" : "px";
input.parentNode.querySelector('.range_value').textContent = input.value + units;
context.filter = "brightness(100%)";
all_input_range.forEach(i => {
const text = i.parentNode.querySelector('div').textContent;
const units = text !== "Blur" ? text !== "Hue-rotate" ? "%" : "deg" : "px";
context.filter += `${text.toLowerCase()}(${i.value + units}) `;
});
const image = new Image();
image.onload = function () {
context.drawImage(image, 0, 0, calculateAspectRatioFit(image.width, image.height).width, calculateAspectRatioFit(image.width, image.height).height);
};
image.src = image_data;
};
});
document.querySelector('.reset_button').addEventListener('click', function () {
all_input_range.forEach(input => {
const text = input.parentNode.querySelector('div').textContent;
if (text === "Brightness" || text === "Saturate" || text === "Contrast") input.value = 100;else
input.value = 0;
});
context.filter = "none";
const image = new Image();
image.onload = function () {
context.drawImage(image, 0, 0, calculateAspectRatioFit(image.width, image.height).width, calculateAspectRatioFit(image.width, image.height).height);
};
canvas.style.opacity = 1;
image.src = image_data;
update_input();
});
let track;
const video = document.querySelector('video');
document.querySelector('#take_image').addEventListener('click', function () {
active_stylesheet("stylesheet_three");
navigator.mediaDevices.getUserMedia({
video: true,
audio: false }).
then(stream => {
video.srcObject = stream;
video.play();
stream = stream;
track = stream.getTracks();
});
});
function active_stylesheet(remain_stylesheet_id) {
document.querySelectorAll("link[rel=stylesheet]:not(#stylesheet_general").forEach(link => {
if (link.id != remain_stylesheet_id) link.setAttribute("disabled", true);else
link.removeAttribute('disabled');
});
}
//edit_image.click();//
document.querySelector('#take_photo_button').addEventListener('click', function () {
const canvas = document.createElement('canvas');
const preview = document.querySelector('#preview');
canvas.className = 'photo_canvas';
document.body.appendChild(canvas);
const context = canvas.getContext('2d');
context.canvas.width = preview.offsetWidth;
context.canvas.height = preview.offsetHeight;
context.drawImage(video, 0, 0, preview.offsetWidth, preview.offsetHeight);
const data = canvas.toDataURL('image/png');
canvas.src = data;
canvas.style.position = 'absolute';
canvas.style.left = preview.getBoundingClientRect().left + window.scrollX + "px";
canvas.style.top = preview.getBoundingClientRect().top + window.scrollY + "px";
const correct_button = document.querySelector('.correct_mark');
const delete_button = document.querySelector('.delete_button');
correct_button.style.display = 'revert';
delete_button.style.display = 'revert';
preview.style.visibility = 'hidden';
delete_button.addEventListener('click', function () {
preview.style.visibility = 'visible';
canvas.remove();
correct_button.style.display = 'none';
delete_button.style.display = 'none';
});
correct_button.addEventListener('click', function () {
track.forEach(track => {
track.stop();
});
image_data = canvas.toDataURL('image/png');
edit_image.click();
const general_canvas = canvas_wrapper.querySelector('canvas');
const image = new Image();
current_image = image;
image.onload = function () {
console.log(image.width, image.height);
general_canvas.getContext('2d').drawImage(image, 0, 0, image.width, image.height);
};
image.src = image_data;
correct_button.style.display = 'none';
delete_button.style.display = 'none';
context.canvas.width = calculateAspectRatioFit(image.width, image.height).width;
context.canvas.height = calculateAspectRatioFit(image.width, image.height).height;
current_image = image;
context.drawImage(image, 0, 0, calculateAspectRatioFit(image.width, image.height).width, calculateAspectRatioFit(image.width, image.height).height);
setTimeout(() => window.dispatchEvent(new Event('resize')), 10);
});
});
document.querySelector('#pick_color').addEventListener('click', function () {
active_stylesheet('stylesheet_one');
if (document.querySelector('.photo_canvas')) document.querySelector('.photo_canvas').remove();
preview.style.visibility = 'visible';
});
document.querySelector('#download_image_button').addEventListener('click', function () {
if (!document.querySelector('.selected_format_button')) {
make_notice("Please select a format first!");
return;
}
const link = document.createElement('a');
link.download = document.querySelector('#file_input').value;
link.href = canvas.toDataURL(`image/${document.querySelector('.selected_format_button').textContent.toLowerCase()}`);
link.click();
link.remove();
});
document.querySelectorAll('.format_button').forEach(button => {
button.addEventListener('click', function () {
if (document.querySelector('.selected_format_button')) document.querySelector('.selected_format_button').classList.remove('selected_format_button');
button.classList.add("selected_format_button");
});
});
document.querySelector('#download_button').addEventListener('click', function () {
document.querySelector('#download_section').style.display = 'revert';
document.querySelector('#filter_section').style.display = 'none';
const size = window.atob(canvas.toDataURL(`image/${document.querySelector('.selected_format_button') ? document.querySelector('.selected_format_button').textContent.toLowerCase() : "png"}`).split(",")[1]).length + " bytes";
document.querySelector("#file_size").textContent = size;
if (document.querySelector('.alert')) document.querySelector('.alert').remove();
});
document.querySelector('#filter_button').addEventListener('click', function () {
document.querySelector('#download_section').style.display = 'none';
document.querySelector('#filter_section').style.display = 'revert';
});
function unfinished_message() {
if (document.querySelector('.alert')) document.querySelector('.alert').remove();
document.querySelector('#download_section').style.display = 'none';
document.querySelector('#filter_section').style.display = 'none';
const div = document.createElement('div');
div.className = 'alert';
div.style.fontSize = "1.5em";
div.textContent = "This is unfished but will soon be finished. Last updated date: 2023 Apirl 4th ";
document.querySelector('#setting_section').appendChild(div);
}
document.querySelector('#text_button').addEventListener('click', unfinished_message);
document.querySelector('#crop_button').addEventListener('click', () => {
unfinished_message();
update_position();
});
document.querySelector('#art_button').addEventListener('click', unfinished_message);
Also see: Tab Triggers