I thought this might come in handy one day
// Project: led board
// Created: 2018-12-27
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
// set window properties
SetWindowTitle( "led board" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
dim objects [64,64]
saveletter("B","B.png",255,255,255)
B = grabinfo("\media\B.png")
saveletter("O","O.png",255,255,0)
O = grabinfo("\media\O.png")
saveletter("N","N.png",0,255,0)
N = grabinfo("\media\N.png")
saveletter("U","U.png",255,0,0)
U = grabinfo("\media\U.png")
saveletter("S","S.png",255,0,255)
S = grabinfo("\media\S.png")
SetObjectPosition(B,-50,50,0)
SetObjectPosition(O,-25,50,0)
SetObjectPosition(N,-0,50,0)
SetObjectPosition(U,25,50,0)
SetObjectPosition(S,50,50,0)
saveletter("E","E.png",255,255,255)
E = grabinfo("\media\E.png")
saveletter("X","X.png",255,255,0)
X = grabinfo("\media\X.png")
saveletter("T","T.png",0,255,0)
T = grabinfo("\media\T.png")
saveletter("R","R.png",255,0,0)
R = grabinfo("\media\R.png")
saveletter("A","A.png",255,0,255)
A = grabinfo("\media\A.png")
SetObjectPosition(E,-50,-50,0)
SetObjectPosition(X,-25,-50,0)
SetObjectPosition(T,-0,-50,0)
SetObjectPosition(R,25,-50,0)
SetObjectPosition(A,50,-50,0)
camerax#=0
cameray#=50
cameraz#=-100
do
RotateObjectLocalY(B,.1)
RotateObjectLocalY(O,.1)
RotateObjectLocalY(N,.1)
RotateObjectLocalY(U,.1)
RotateObjectLocalY(S,.1)
RotateObjectLocalY(E,-.1)
RotateObjectLocalY(X,-.1)
RotateObjectLocalY(T,-.1)
RotateObjectLocalY(R,-.1)
RotateObjectLocalY(A,-.1)
if GetRawKeyState(38) then inc cameraz#
if GetRawKeyState(40) then dec cameraz#
if GetRawKeyState(37) then inc camerax#
if GetRawKeyState(39) then dec camerax#
if GetRawKeyState(87) then inc cameray#
if GetRawKeyState(83) then dec cameray#
print(GetRawLastKey())
SetCameraPosition(1,camerax#,cameray#,cameraz#)
Print( ScreenFPS() )
Sync()
loop
function saveletter(letter$,filename$,r,g,b)
id = CreateText(letter$)
SetTextColor(id,r,g,b,255)
SetTextSize(id,32)
SetTextBold(id,1)
swap()
DrawBox(0,0,32,32,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
SetTextPosition(id,0,0)
Render2DFront()
render()
DeleteText(id)
img = GetImage(0,0,32,32)
SaveImage(img,filename$)
endfunction
function grabinfo(filename$)
img = LoadImage(filename$)
imgmemblock = CreateMemblockFromImage(img)
width = GetMemblockInt(imgmemblock,0)
height = GetMemblockInt(imgmemblock,4)
id = CreateObjectBox(.01,.01,.01)
for x=width to 0 step -1
for y=height-4 to 0 step -1
offset = (12+((y * width) + x) * 4) - 4
r=GetMemblockByte(imgmemblock,offset)
g=GetMemblockByte(imgmemblock,offset+1)
b=GetMemblockByte(imgmemblock,offset+2)
a=GetMemblockByte(imgmemblock,offset+3)
if r>150 or g>150 or b>150
//DrawBox(x,y,x+1,y+1,MakeColor(r,g,b),MakeColor(r,g,b),MakeColor(r,g,b),MakeColor(r,g,b),1)
objects [ x, y] = CreateObjectSphere(3,20,20)
SetObjectPosition(objects[x,y],x, -y , 0)
SetObjectColor(objects[x,y],r,g,b,a)
FixObjectToObject(objects[x,y],id)
endif
next
next
endfunction id
// Project: led board
// Created: 2018-12-27
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
// set window properties
SetWindowTitle( "led board" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
dim objects [64,64]
numbers as integer[10]
for a=48 to 57
saveletter(chr(a),chr(a)+".png",255,255,255)
numbers[a-48] = grabinfo("\media\"+chr(a)+".png")
SetObjectPosition(numbers[a-48],-5+(a-48)*5,15,0)
next
saveletter("B","B.png",255,255,255)
B = grabinfo("\media\B.png")
saveletter("O","O.png",255,255,0)
O = grabinfo("\media\O.png")
saveletter("N","N.png",0,255,0)
N = grabinfo("\media\N.png")
saveletter("U","U.png",255,0,0)
U = grabinfo("\media\U.png")
saveletter("S","S.png",255,0,255)
S = grabinfo("\media\S.png")
SetObjectPosition(B,-50,50,0)
SetObjectPosition(O,-25,50,0)
SetObjectPosition(N,-0,50,0)
SetObjectPosition(U,25,50,0)
SetObjectPosition(S,50,50,0)
saveletter("c","c.png",255,255,255)
c = grabinfo("\media\c.png")
saveletter("a","a.png",255,255,0)
a = grabinfo("\media\a.png")
saveletter("r","r.png",0,255,0)
r = grabinfo("\media\r.png")
saveletter("V","V.png",255,0,0)
V = grabinfo("\media\V.png")
saveletter("u","u.png",255,0,255)
u = grabinfo("\media\u.png")
saveletter("p","p.png",255,0,255)
p = grabinfo("\media\p.png")
SetObjectPosition(c,-50,0,0)
SetObjectPosition(a,-25,0,0)
SetObjectPosition(r,-0,0,0)
SetObjectPosition(v,25,0,0)
SetObjectPosition(u,50,0,0)
SetObjectPosition(p,50,0,0)
saveletter("E","E.png",255,255,255)
E = grabinfo("\media\E.png")
saveletter("X","X.png",255,255,0)
X = grabinfo("\media\X.png")
saveletter("T","T.png",0,255,0)
T = grabinfo("\media\T.png")
saveletter("R","R.png",255,0,0)
R = grabinfo("\media\R.png")
saveletter("A","A.png",255,0,255)
A = grabinfo("\media\A.png")
SetObjectPosition(E,-50,-50,0)
SetObjectPosition(X,-25,-50,0)
SetObjectPosition(T,-0,-50,0)
SetObjectPosition(R,25,-50,0)
SetObjectPosition(A,50,-50,0)
camerax#=0
cameray#=50
cameraz#=-100
do
RotateObjectLocalY(B,.1)
RotateObjectLocalY(O,.1)
RotateObjectLocalY(N,.1)
RotateObjectLocalY(U,.1)
RotateObjectLocalY(S,.1)
RotateObjectLocalY(E,-.1)
RotateObjectLocalY(X,-.1)
RotateObjectLocalY(T,-.1)
RotateObjectLocalY(R,-.1)
RotateObjectLocalY(A,-.1)
if GetRawKeyState(38) then inc cameraz#
if GetRawKeyState(40) then dec cameraz#
if GetRawKeyState(37) then inc camerax#
if GetRawKeyState(39) then dec camerax#
if GetRawKeyState(87) then inc cameray#
if GetRawKeyState(83) then dec cameray#
print(GetRawLastKey())
SetCameraPosition(1,camerax#,cameray#,cameraz#)
Print( ScreenFPS() )
Sync()
loop
function saveletter(letter$,filename$,r,g,b)
size=16
id = CreateText(letter$)
SetTextColor(id,r,g,b,255)
SetTextSize(id,size)
// SetTextBold(id,1)
swap()
DrawBox(0,0,size,size,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
SetTextPosition(id,0,0)
Render2DFront()
render()
DeleteText(id)
img = GetImage(0,0,size,size)
SaveImage(img,filename$)
endfunction
function grabinfo(filename$)
img = LoadImage(filename$)
imgmemblock = CreateMemblockFromImage(img)
width = GetMemblockInt(imgmemblock,0)
height = GetMemblockInt(imgmemblock,4)
id = CreateObjectBox(.01,.01,.01)
for x=width to 0 step -1
for y=height-4 to 0 step -1
offset = (12+((y * width) + x) * 4) - 4
r=GetMemblockByte(imgmemblock,offset)
g=GetMemblockByte(imgmemblock,offset+1)
b=GetMemblockByte(imgmemblock,offset+2)
a=GetMemblockByte(imgmemblock,offset+3)
if r>150 or g>150 or b>150
//DrawBox(x,y,x+1,y+1,MakeColor(r,g,b),MakeColor(r,g,b),MakeColor(r,g,b),MakeColor(r,g,b),1)
objects [ x, y] = CreateObjectSphere(3,20,20)
SetObjectPosition(objects[x,y],x, -y , 0)
SetObjectColor(objects[x,y],r,g,b,a)
FixObjectToObject(objects[x,y],id)
endif
next
next
SetObjectScale(id,.5,.5,.5)
endfunction id
Tier 1 Developer