v1.15.0 - Added updates to the raster library.

This commit is contained in:
Ponali
2025-07-04 19:29:20 +02:00
parent c095f1fcdd
commit d386ec5eba
4 changed files with 34 additions and 14 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
local agcfg = { local agcfg = {
["halyde"] = { ["halyde"] = {
["maindir"] = "", ["maindir"] = "",
["version"] = "1.14.2", ["version"] = "1.15.0",
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.", ["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
["directories"] = { ["directories"] = {
"halyde/apps", "halyde/apps",
+8 -4
View File
@@ -1,3 +1,5 @@
local component = import("component")
local computer = import("computer")
local raster = import("raster") local raster = import("raster")
local event = import("event") local event = import("event")
@@ -74,7 +76,8 @@ end
-- Render a single frame -- Render a single frame
local function renderFrame() local function renderFrame()
increment = increment + 0.05 local time = computer.uptime()*20
increment = time*0.05 -- increment + 0.05
CUBE_SIZE = (math.sin(increment) + 1) * 25 CUBE_SIZE = (math.sin(increment) + 1) * 25
vertices = { vertices = {
{-CUBE_SIZE, -CUBE_SIZE, -CUBE_SIZE}, -- 0: left bottom back {-CUBE_SIZE, -CUBE_SIZE, -CUBE_SIZE}, -- 0: left bottom back
@@ -88,9 +91,9 @@ local function renderFrame()
} }
-- Update rotation angles -- Update rotation angles
raster.clear() raster.clear()
angleX = angleX + ROTATION_SPEED angleX = time * ROTATION_SPEED -- angleX
angleY = angleY + ROTATION_SPEED * 0.7 angleY = time * ROTATION_SPEED * 0.7 -- angleY
angleZ = angleZ + ROTATION_SPEED * 0.5 angleZ = time * ROTATION_SPEED * 0.5 -- angleZ
-- Project all vertices -- Project all vertices
local projectedPoints = {} local projectedPoints = {}
@@ -124,6 +127,7 @@ function main()
-- Main loop (assume this is called repeatedly by the host environment) -- Main loop (assume this is called repeatedly by the host environment)
while true do while true do
renderFrame() renderFrame()
coroutine.yield()
if event.pull("key_down", 0) then if event.pull("key_down", 0) then
raster.free() raster.free()
break break
+1 -1
View File
@@ -1,7 +1,7 @@
local loadfile = ... local loadfile = ...
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile) local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
_G._OSVERSION = "Halyde 1.14.2" _G._OSVERSION = "Halyde 1.15.0"
_G._OSLOGO = "" _G._OSLOGO = ""
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
repeat repeat
+24 -8
View File
@@ -5,7 +5,8 @@ local raster = {
["displayWidth"]=0, ["displayWidth"]=0,
["displayHeight"]=0, ["displayHeight"]=0,
["charWidth"]=0, ["charWidth"]=0,
["charHeight"]=0 ["charHeight"]=0,
["backgroundColor"]=0xFFFFFF
} }
local component = import("component") local component = import("component")
@@ -34,22 +35,27 @@ function raster.init(width, height, bgcolor)
width, height = gpu.getResolution() width, height = gpu.getResolution()
end end
for i = 1, width*height do
chunksAffected[i] = true
end
raster.charWidth = width raster.charWidth = width
raster.charHeight = height raster.charHeight = height
width, height = raster.units.charToBraille(width, height) width, height = raster.units.charToBraille(width, height)
bgcolor = bgcolor or raster.defaultBackgroundColor bgcolor = bgcolor or raster.defaultBackgroundColor
if bgcolor~=0 then
for i=1,width*height do
display[i]=bgcolor
end
end
raster.displayWidth = width raster.displayWidth = width
raster.displayHeight = height raster.displayHeight = height
raster.backgroundColor = bgcolor
pcall(function() pcall(function()
renderBuffer = gpu.allocateBuffer() renderBuffer = gpu.allocateBuffer()
end) end)
raster.clear()
end end
function raster.set(x, y, color) function raster.set(x, y, color)
@@ -70,7 +76,7 @@ end
function raster.get(x, y) function raster.get(x, y)
local i = x+y*raster.displayWidth local i = x+y*raster.displayWidth
return display[i] or 0 return display[i] or raster.backgroundColor
end end
local function stats(arr) local function stats(arr)
@@ -88,8 +94,14 @@ end
local function getKeys(t) local function getKeys(t)
local keys = {} local keys = {}
for key, _ in pairs(t) do for k,v in pairs(t) do
table.insert(keys, key) table.insert(keys,{k,v})
end
table.sort(keys,function(a,b)
return a[2]>b[2]
end)
for i=1,#keys do
keys[i] = keys[i][1]
end end
return keys return keys
end end
@@ -127,6 +139,7 @@ local function arrayToBraille(arr)
for i=1,8 do for i=1,8 do
codePoint = codePoint | arr[i]<<(i-1) codePoint = codePoint | arr[i]<<(i-1)
end end
if codePoint==0x2800 then return " " end
return utf8.char(codePoint) return utf8.char(codePoint)
end end
@@ -172,7 +185,10 @@ function raster.clear()
if renderBuffer~=nil then if renderBuffer~=nil then
gpu.setActiveBuffer(renderBuffer) gpu.setActiveBuffer(renderBuffer)
end end
clear() -- clear()
local bgcolor = raster.backgroundColor
gpu.setBackground(bgcolor)
gpu.fill(1,1,raster.displayWidth,raster.displayHeight," ")
display = {} display = {}
end end