summaryrefslogtreecommitdiff
path: root/img
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-06 01:20:11 +0100
committerubq323 <ubq323@ubq323.website>2022-08-06 01:20:11 +0100
commitcb630d5580174ffe9640fcb23f23a24b376ae9b2 (patch)
tree24cf3fedb3714c5ca49f6653a61d36fe6593823a /img
parente33799e0da61b3b882ef4427807d9cd9579c553e (diff)
vlorb
Diffstat (limited to 'img')
-rw-r--r--img/better_disp.lua47
1 files changed, 33 insertions, 14 deletions
diff --git a/img/better_disp.lua b/img/better_disp.lua
index 99fa5dd..4122836 100644
--- a/img/better_disp.lua
+++ b/img/better_disp.lua
@@ -22,21 +22,40 @@ local function vlorb(onc,offc, g1,g2,g3,g4,g5,g6)
return textc,bgc,string.char(vlorbchar)
end
-local function test()
- term.clear()
- local gs = {false,false,false,false,false,false}
- while true do
- term.setCursorPos(5,5)
- local tc,bgc,char = vlorb(colors.red,colors.black, table.unpack(gs))
- term.setTextColor(tc)
- term.setBackgroundColor(bgc)
- term.write(char)
- local _,key = os.pullEvent"key"
- if 65<=key and key<=70 then
- local idx = key-64
- gs[idx] = not gs[idx]
+-- 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
+ img = imgx or 1
+ imgy = imgy or 1
+
+ local sw = math.ceil(w/2)
+ local sh = math.ceil(h/3)
+
+ for soffx=0,sw-1 do
+ for soffy=0,sh-1 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
+ table.insert(gs,img[imgy+ioffy+goffy][imgx+ioffx+goffx] or {0,0,0})
+ 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,test=test}
+
+
+
+
+return {vlorb=vlorb}