xxxxxxxxxx
221
// 2d matrix width
let pw = 2
// 2d matrix size
let pws = pw * pw
let ptws = pw / 2
// bitfields logo (3 rows)
let l1 = 887
let l2 = 533
let l3 = 1559
// for outline (horizontal)
let l4 = 354
let l5 = 1026
let l6 = 1559
// basically ->
/*
let logo = [
1,1,1,0,1,1,1,0,1,1,0,
1,0,1,0,1,0,0,0,0,1,0,
1,1,1,0,1,0,0,0,0,1,1
]
*/
//let logo = 26714095
let logo = 105684975
function setup() {
ptws = round(ptws)
pixelDensity(1)
createCanvas(1920/2, 1080/2)
background(0)
rectMode(CORNERS)
let b1 = 0
let b2 = 0
let b3 = 0
let b4 = 0
loadPixels()
// bit field data
let logo = 105684975
// text position
const offsetX = 128
const offsetY = 128
let ox = offsetX + offsetY * width
// some constants
const blockWidth = 64
const blockHeight = 64
const glyphWidth = 64 * 4
const glyphHeight = 64 * 3
// iterate until there is no glyph
while (logo > 0) {
/*
for (let y = 0; y < 64 * 3; y += 1) {
for (let x = 0; x < 64 * 3; x += 1) {
*/
// iterate whole glyph on screen
for (let i = 0; i < glyphWidth * glyphHeight; i += 1) {
const x = i & 255
const y = i >> 8
const bi = x >> 6
const bbi = bi + (y >> 6) * 3 // bit field bit index
const br = ((logo >> bbi) & 0x1) * 255 // get glyph bit from given index
if (bi < 3) { // spacing
const index = (ox + x + y * width) * 4
pixels[index + 0] = br
pixels[index + 1] = br
pixels[index + 2] = br
}
}
/*
}
*/
// go to the next glyph
logo >>= 9
ox += glyphWidth
}
/*
for (let i = 0; i < (width * (height / 2 / 3)); i += 1) {
let x = i % width
let y = floor(i / width)
//let xscale = 1.25
//let lx = floor(x / width * xscale * 11)
let lx = x >> 6
// bit lookup
b1 = ((l1 >> lx) & 0x1)
b2 = ((l2 >> lx) & 0x1)
b3 = ((l3 >> lx) & 0x1)
// outline only (partial; only vertical lines, see below for second pass)
//let lxp = (x-1) >> 6
//b1 = ((l1 >> lx) & 0x1)^((l1 >> lxp) & 0x1)
//b2 = ((l2 >> lx) & 0x1)^((l2 >> lxp) & 0x1)
//b3 = ((l3 >> lx) & 0x1)^((l3 >> lxp) & 0x1)
let col = 255 // color
x += 128
y += 128
// first row
pixels[(x + y * width) * 4 + 0] = col * b1
pixels[(x + y * width) * 4 + 1] = col * b1
pixels[(x + y * width) * 4 + 2] = col * b1
// second row
pixels[(x + (y + (height / 2 / 3)) * width) * 4 + 0] = col * b2
pixels[(x + (y + (height / 2 / 3)) * width) * 4 + 1] = col * b2
pixels[(x + (y + (height / 2 / 3)) * width) * 4 + 2] = col * b2
// third row
pixels[(x + (y + (height / 2 / 3)*2) * width) * 4 + 0] = col * b3
pixels[(x + (y + (height / 2 / 3)*2) * width) * 4 + 1] = col * b3
pixels[(x + (y + (height / 2 / 3)*2) * width) * 4 + 2] = col * b3
}
*/
// outline second pass (horizontal)
/*
for (let x = 0; x < width; x += 1) {
let lx = x >> 6
// bit lookup
b1 = ((l1 >> lx) & 0x1)
b2 = ((l4 >> lx) & 0x1)
b3 = ((l5 >> lx) & 0x1)
b4 = ((l6 >> lx) & 0x1)
let col = 255
let px = x + 128
let y = 128
pixels[(px + y * width) * 4 + 0] = col * b1
pixels[(px + y * width) * 4 + 1] = col * b1
pixels[(px + y * width) * 4 + 2] = col * b1
y += height / 2 / 3
pixels[(px + y * width) * 4 + 0] = col * b2
pixels[(px + y * width) * 4 + 1] = col * b2
pixels[(px + y * width) * 4 + 2] = col * b2
y += height / 2 / 3
pixels[(px + y * width) * 4 + 0] = col * b3
pixels[(px + y * width) * 4 + 1] = col * b3
pixels[(px + y * width) * 4 + 2] = col * b3
y += height / 2 / 3
pixels[(px + y * width) * 4 + 0] = col * b4
pixels[(px + y * width) * 4 + 1] = col * b4
pixels[(px + y * width) * 4 + 2] = col * b4
}
*/
updatePixels()
/*
noFill()
stroke(4)
textSize(400);
textAlign(CENTER, CENTER);
text('ORZ', width / 2-24, height / 2+24);
*/
}
function draw() {
//return;
loadPixels()
if (frameCount > 150) return
let tx = 0
let ty = 1-frameCount*800000
let xx = 0
let yy = 0
for (let i = 0; i < width * height; i += 1) {
let x = i % width
let y = floor(i / width)
let ci = (x + (y * width)) * 4
let pc = pixels[ci+2]
if (pc > 1 && pc < 16) {
for (let k = 0; k < 4; k += 1) {
//let tx = k % pw
//let ty = floor(k / pw)//+tx
let tz = tx
tx += (ty >> 9)
ty -= (tx >> 8)
//tx += ty >> 11
let cx = floor(x + ((tx)>>21))
let cy = floor(y + ((ty)>>21))
let index = floor(cx + cy * width) * 4
let c = pc+15//frameCount >> (1 + (pc/4))) //% floor(8 + frameCount / 2/* + k * 8*/)//index / 10e4//pattern[k]+k
let cl = width * height * 4
if (index >= 0 && index < cl) {
pixels[index + 1] += (c >> (2+(frameCount>>5)))// - (frameCount >> 10))
pixels[index + 2] += ((c/*-(tx>>10)*/) >> (1+(ty>>22)))// - (pc>>4)
pixels[index + 0] += (c >> (1+(frameCount>>5)))
/*
pixels[cl - index - 4 + 0] += (c >> 4)
pixels[cl - index - 4 + 1] += (c >> 4)
pixels[cl - index - 4 + 2] += (c >> 4)
*/
}
}
}
}
updatePixels()
}