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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <pre id="display"></pre>
              
            
!

CSS

              
                
              
            
!

JS

              
                const dotPosition = [1, 8, 2, 16, 4, 32, 64, 128];

class DotDisplay {
	constructor(width, height) {
		this.width = width;
		this.height = height;
		this.buf = new Array(width * height); // 픽셀 정보들을 담을 배열
	}

	clear() {
		this.buf.fill(0);
	}

	put(x, y, color) { // color: 0 = empty, 1 = dot
		if ( x < 0 || x >= this.width || y < 0 || y >= this.height ) return; // clipping
    x >>= 0;
    y >>= 0;
		this.buf[y * this.width + x] = color;
	}
  
  render() {
	// 글자당 2*4 픽셀이지만 줄간격이 조금 있으므로 세로는 5 픽셀을 한 글자로 취급하자. 줄 사이에 있는 픽셀은... 아쉽지만 포기하는걸로.
	const xChunks = Math.ceil(this.width / 2);
	const yChunks = Math.ceil(this.height / 5);

	const lines = []; // 만들어진 문자열들을 담을 배열
	let line, ch; 

	for(let y = 0; y < yChunks; y++) {
		line = []; // 우선 한 줄을 초기화하고
		for(let x = 0; x < xChunks; x++) {
			ch = 0; // 한 글자를 초기화

			const sx = x * 2;
			const sy = y * 5;

			const xlimit = Math.min(2, this.width - sx);
			const ylimit = Math.min(4, this.height - sy);

			for(let i = 0; i < xlimit; i++) {
				for (let j = 0; j < ylimit; j++) {
					const idx = (j + sy) * this.width + (i + sx);
					const cl = this.buf[idx];
					if (cl) ch |= dotPosition[i + (j*2)];
				}
			}

			line.push(String.fromCharCode(ch + 0x2800));
			ch = 0;
		}
	  lines.push(line.join(''));
	}
	return lines.join('\n');
}

}

const elem = document.querySelector('#display');
const dot = new DotDisplay(100, 100);

let x = 0;

function update() {
  dot.clear();  
  for (let y = 0; y < 100; y++) {
    dot.put(x, y, 1);
  }
  x = (x+1) % 100;
  const str = dot.render();
  elem.innerHTML = str;
  requestAnimationFrame(update);
}

update();
              
            
!
999px

Console