-- a vlorb consists of six gromlings[A -- 1 2 -- 4 8 -- 16 Q -- these are characters 0x80 through 0x9f in the cc charset -- which is only 2^5 characters though. for the sixth bit you flip the colours -- of that vlorb. -- on colour, off colour, gromlings 1 through 6 (bools) -- returns text colour, bg color, and vlorbchar local function vlorb(onc,offc, g1,g2,g3,g4,g5,g6) local textc,bgc = onc,offc if g6 then textc,bgc=bgc,textc end local vlorbchar = 0x80 -- ~= on booleans is xor -- if g6 set then flip all the other bits if g1 ~= g6 then vlorbchar=vlorbchar+1 end if g2 ~= g6 then vlorbchar=vlorbchar+2 end if g3 ~= g6 then vlorbchar=vlorbchar+4 end if g4 ~= g6 then vlorbchar=vlorbchar+8 end if g5 ~= g6 then vlorbchar=vlorbchar+16 end return textc,bgc,string.char(vlorbchar) end local function should_be_on(col) return col[1]+col[2]+col[3] > 1.5 end -- todo: refactor common stuff into a common file local function disp(R,img,scrx,scry,w,h,imgx,imgy) -- w and h are image coords scrx = scrx or 1 scry = scry or 1 w = w or img.width h = h or img.width imgx = imgx or 1 imgy = imgy or 1 local sw = math.ceil(w/2) local sh = math.ceil(h/3) for soffx=0,sw do for soffy=0,sh do local ioffx=soffx*2 local ioffy=soffy*3 R.setCursorPos(scrx+soffx,scry+soffy) local gs = {} for goffy=0,2 do for goffx=0,1 do local ic = img[imgy+ioffy+goffy][imgx+ioffx+goffx] or {0,0,0} table.insert(gs,should_be_on(ic)) end end local tc,bc,ch = vlorb(colors.white,colors.black,table.unpack(gs)) R.setTextColor(tc) R.setBackgroundColor(bc) R.write(ch) end end end return {vlorb=vlorb,disp=disp}