|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title> |
| 7 | + Pixel Art With Alpine.js |
| 8 | + </title> |
| 9 | + <link rel="stylesheet" type="text/css" href="./main.css"> |
| 10 | + <script type="text/javascript" src="./palette.js" defer></script> |
| 11 | + <script type="text/javascript" src="./main.js" defer></script> |
| 12 | + <script type="text/javascript" src="../../vendor/alpine/3.13.5/alpine.3.13.5.min.js" defer></script> |
| 13 | +</head> |
| 14 | +<body> |
| 15 | + |
| 16 | + <main |
| 17 | + x-data="Demo" |
| 18 | + data-width="25" |
| 19 | + data-height="25" |
| 20 | + @mouseup.window="stopDrawing()" |
| 21 | + @hashchange.window="handleHashchange()" |
| 22 | + @keydown.meta.z.window="handleDo( event )" |
| 23 | + @keydown.ctrl.z.window="handleDo( event )"> |
| 24 | + |
| 25 | + <h1> |
| 26 | + <a href="./index.htm">Pixel Art With Alpine.js</a> |
| 27 | + </h1> |
| 28 | + |
| 29 | + <!-- Rendered canvas. --> |
| 30 | + <div class="grid"> |
| 31 | + <template x-for="( pixel, i ) in pixels" :key="i"> |
| 32 | + <button |
| 33 | + @mousedown="startDrawing( $event, i )" |
| 34 | + @mouseenter="enterPixel( $event, i )" |
| 35 | + :style="{ backgroundColor: pixel?.hex }"> |
| 36 | + </button> |
| 37 | + </template> |
| 38 | + </div> |
| 39 | + |
| 40 | + <!-- Color palette. --> |
| 41 | + <div class="palette"> |
| 42 | + <template x-for="option in palette.swatches"> |
| 43 | + <button |
| 44 | + @mousedown="selectSwatch( option )" |
| 45 | + :title="option.name" |
| 46 | + :style="{ backgroundColor: option.hex }" |
| 47 | + :class="{ 'isSelected': ( option === foregroundSwatch ) }"> |
| 48 | + </button> |
| 49 | + </template> |
| 50 | + </div> |
| 51 | + |
| 52 | + <dl class="selected"> |
| 53 | + <div> |
| 54 | + <dt>Name:</dt> |
| 55 | + <dd x-text="foregroundSwatch.name"></dd> |
| 56 | + </div> |
| 57 | + <div> |
| 58 | + <dt>Hex:</dt> |
| 59 | + <dd x-text="foregroundSwatch.hex"></dd> |
| 60 | + </div> |
| 61 | + </dl> |
| 62 | + |
| 63 | + <div class="fillers"> |
| 64 | + <button @click="clearCanvas()"> |
| 65 | + Clear Canvas |
| 66 | + <span :style="{ backgroundColor: foregroundSwatch.hex }"></span> |
| 67 | + </button> |
| 68 | + <button @click="changeCanvasBackground()"> |
| 69 | + Set Background |
| 70 | + <span :style="{ backgroundColor: foregroundSwatch.hex }"></span> |
| 71 | + </button> |
| 72 | + </div> |
| 73 | + |
| 74 | + <div class="tuggers"> |
| 75 | + <button @click="pullCanvasCenter()"> |
| 76 | + Center |
| 77 | + </button> |
| 78 | + <button @click="pullCanvasUp()"> |
| 79 | + Up |
| 80 | + </button> |
| 81 | + <button @click="pullCanvasDown()"> |
| 82 | + Down |
| 83 | + </button> |
| 84 | + <button @click="pullCanvasLeft()"> |
| 85 | + Left |
| 86 | + </button> |
| 87 | + <button @click="pullCanvasRight()"> |
| 88 | + Right |
| 89 | + </button> |
| 90 | + </div> |
| 91 | + |
| 92 | + <div class="tips"> |
| 93 | + <p> |
| 94 | + Use <kbd>CMD</kbd>+Click to sample a pixel. |
| 95 | + </p> |
| 96 | + <p> |
| 97 | + Use <kbd>ALT</kbd>+Click to erase a pixel. |
| 98 | + </p> |
| 99 | + <p> |
| 100 | + Use <kbd>CMD+Z</kbd> to undo pixel and <kbd>Shift+CMD+Z</kbd> to redo pixel. |
| 101 | + </p> |
| 102 | + </div> |
| 103 | + |
| 104 | + <div class="examples"> |
| 105 | + <a href="#a,a,a:30,14:3,a:3,14:3,a:f,14,15:4,b,15:4,14,a:d,14,15:b,14,a:c,14,15:b,17,a:c,14,15:b,17,a:c,b,15:a,17,b,a:d,b,15:8,17,b,a:f,b,15:6,17,b,a:h,b,15:4,17,b,a:j,b,15:2,17,b,a:l,b,17,b,a:n,b,a:2h,d,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