|
36 | 36 | pre { padding: 0.75rem 1rem; font-family: "SF Mono","Fira Code",monospace; font-size: 13px; line-height: 1.6; overflow-x: auto; white-space: pre; background: #0d0d0d; color: #ccc; border-radius: 8px; margin-bottom: 1.25rem; } |
37 | 37 | .welcome h1 { font-size: 1.8rem; font-weight: 600; margin-bottom: 1rem; } |
38 | 38 | .welcome p { color: #555; line-height: 1.8; max-width: 500px; } |
39 | | - .cm-static-wrap { margin-bottom: 1.25rem; } |
40 | | - .cm-static-wrap .CodeMirror { height: auto; border-radius: 8px; font-size: 13px; line-height: 1.6; padding: 0; font-family: "SF Mono","Fira Code",monospace; } |
| 39 | + .cm-static-wrap .CodeMirror { height: auto; border-radius: 8px; font-size: 13px; line-height: 1.6; padding: 0.25rem 0; margin-bottom: 1.25rem; font-family: "SF Mono","Fira Code",monospace; } |
41 | 40 | .cm-static-wrap .CodeMirror-scroll { overflow: hidden !important; max-height: none; } |
42 | 41 | footer { border-top: 1px solid #e0e0e0; padding: 2rem; text-align: center; font-size: 13px; color: #888; } |
43 | 42 | .footer-contact { margin-top: 0.4rem; font-size: 12px; } |
@@ -98,7 +97,7 @@ <h1>Alpha Mask</h1> |
98 | 97 | <span>alpha-mask.pde</span> |
99 | 98 | <button class="copy-btn" onclick="copyCode()">Copy</button> |
100 | 99 | </div> |
101 | | - <pre id="code-pre">/** |
| 100 | + <textarea id="code-pre" style="display:none">/** |
102 | 101 | * Alpha Mask. |
103 | 102 | * |
104 | 103 | * Loads a "mask" for an image to specify the transparency |
@@ -126,8 +125,24 @@ <h1>Alpha Mask</h1> |
126 | 125 | image(img, width / 2, height / 2); |
127 | 126 | image(img, mouseX, mouseY); |
128 | 127 | } |
129 | | -</pre> |
| 128 | +</textarea> |
130 | 129 | </div> |
| 130 | + <script> |
| 131 | + (function(){ |
| 132 | + var ta = document.getElementById('code-pre'); |
| 133 | + var cm = CodeMirror.fromTextArea(ta, { |
| 134 | + mode: 'cppmode', |
| 135 | + theme: 'cppmode', |
| 136 | + readOnly: true, |
| 137 | + lineNumbers: false, |
| 138 | + lineWrapping: false, |
| 139 | + viewportMargin: Infinity, |
| 140 | + }); |
| 141 | + cm.getWrapperElement().style.fontSize = '13px'; |
| 142 | + cm.getWrapperElement().style.lineHeight = '1.6'; |
| 143 | + cm.getWrapperElement().style.borderRadius = '0 0 8px 8px'; |
| 144 | + })(); |
| 145 | + </script> |
131 | 146 | </div> |
132 | 147 | </div> |
133 | 148 | <footer> |
|
0 commit comments