Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                /**
 *  @param {ArrayBuffer} srcArrayBuffer 埋め込み元(任意のファイル)
 *  @param {ArrayBuffer} destArrayBuffer 埋め込み先(必要サイズにスケールされたすき焼き画像)
 *  @return {ArrayBuffer} データが埋め込まれたすき焼き画像のピクセルデータ
 */
export default function embedDataInPixels(srcArrayBuffer, destArrayBuffer) {
    const byteLength = srcArrayBuffer.byteLength;
    
    const srcView  = new Uint8Array(srcArrayBuffer);
    const destView = new Uint8Array(destArrayBuffer.slice());// バッファは改変用にコピー
    
    for (let byte = 0, px = 0; byte < byteLength; ++byte) {
        for (let bit = 0; bit < 8; ++bit, ++px) {
            const i = px * 4;// ※1pxはRGBAの4チャンネルあるので4倍する
            let r = destView[i];// Rチャンネル(0〜255)を取り出す
            
            r &= ~1;// 最下位ビットをあとでORするために0にする
            r |= (srcView[byte] >> bit) & 1;// ビットを順番に取り出してORで埋め込み
            
            destView[i] = r;// Rチャンネルを上書き
        }
    }
    
    return destView.buffer;
};

              
            
!
999px

Console