mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-03-27 10:12:48 +01:00
Хууууй
This commit is contained in:
@@ -318,7 +318,7 @@
|
||||
path="/lib/syntax.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/syntax.lua",
|
||||
type="Library",
|
||||
version=1.15,
|
||||
version=1.16,
|
||||
},
|
||||
{
|
||||
path="/lib/palette.lua",
|
||||
@@ -331,7 +331,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/doubleBuffering.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.23,
|
||||
version=1.24,
|
||||
},
|
||||
{
|
||||
path="/lib/compressor.lua",
|
||||
@@ -367,19 +367,19 @@
|
||||
path="/lib/OpenComputersGL/Main.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Main.lua",
|
||||
type="Library",
|
||||
version=1.07,
|
||||
version=1.08,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Materials.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Materials.lua",
|
||||
type="Library",
|
||||
version=1.07,
|
||||
version=1.08,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Renderer.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Renderer.lua",
|
||||
type="Library",
|
||||
version=1.07,
|
||||
version=1.08,
|
||||
},
|
||||
{
|
||||
path="/lib/MeowEngine/Main.lua",
|
||||
@@ -469,7 +469,7 @@
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DTest/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
forceDownload=true,
|
||||
version=1.19,
|
||||
version=1.20,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/GeoScan2",
|
||||
|
||||
@@ -317,7 +317,7 @@ local controls = {
|
||||
local OCGLView = GUI.object(1, 1, mainContainer.width, mainContainer.height)
|
||||
|
||||
local function drawInvertedText(x, y, text)
|
||||
local index = buffer.getBufferIndexByCoordinates(x, y)
|
||||
local index = buffer.getIndexByCoordinates(x, y)
|
||||
local background, foreground = buffer.rawGet(index)
|
||||
buffer.rawSet(index, background, 0xFFFFFF - foreground, text)
|
||||
end
|
||||
@@ -378,7 +378,7 @@ mainContainer:addChild(OCGLView)
|
||||
mainContainer.infoTextBox = mainContainer:addChild(GUI.textBox(2, 4, 45, mainContainer.height, nil, 0xEEEEEE, {}, 1, 0, 0))
|
||||
local lines = {
|
||||
"Copyright © 2016-2017 - Developed by ECS Inc.",
|
||||
"Timofeev Igor (vk.com/id7799889), Trifonov Gleb (vk.com/id88323331), Verevkin Yakov (vk.com/id60991376), Bogushevich Victoria (vk.com/id171497518)",
|
||||
"Timofeef Igor (vk.com/id7799889), Trifonov Gleb (vk.com/id88323331), Verevkin Yakov (vk.com/id60991376), Bogushevich Victoria (vk.com/id171497518)",
|
||||
"All rights reserved",
|
||||
}
|
||||
mainContainer:addChild(GUI.textBox(1, mainContainer.height - #lines + 1, mainContainer.width, #lines, nil, 0x3C3C3C, lines, 1)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
|
||||
@@ -15,7 +15,7 @@ DoubleBuffering - низкоуровневая библиотека для эф
|
||||
|
||||
Цена таких космических скоростей - повышенный расход оперативной памяти. Чтобы предельно уменьшить ее расход, мы используем одномерную структуру экранных массивов вместо трехмерной:
|
||||
|
||||

|
||||

|
||||
|
||||
Для получения данных о пикселях используются специальные методы, преобразующие экранные координаты в индексы экранного буфера и наоборот, подробнее об этом написано ниже в разделе "**Вспомогательные методы**".
|
||||
|
||||
@@ -34,10 +34,10 @@ DoubleBuffering - низкоуровневая библиотека для эф
|
||||
|
||||
pastebin run vTM8nbSZ
|
||||
|
||||
Свойства библиотеки
|
||||
Параметры библиотеки
|
||||
======
|
||||
|
||||
| Тип свойства | Свойство |Описание |
|
||||
| Тип параметра | Параметр |Описание |
|
||||
| ------ | ------ | ------ |
|
||||
| *int* | buffer.**width**| Текущее разрешение буфера по ширине |
|
||||
| *int* | buffer.**height**| Текущее разрешение буфера по высоте |
|
||||
@@ -139,15 +139,14 @@ buffer.**square**( x, y, width, height, background, foreground, symbol, transpar
|
||||
|
||||
Заполнить прямоугольную область указанными данными. При указании прозрачности в диапазоне [0; 100] прямоугольник будет накладываться поверх существующей информации, словно прозрачное стеклышко.
|
||||
|
||||
buffer.**clear**( [background, foreground, symbol] )
|
||||
buffer.**clear**( [color, transparency] )
|
||||
-----------------------------------------------------------
|
||||
| Тип | Аргумент | Описание |
|
||||
| ------ | ------ | ------ |
|
||||
| [*int* | background] | Опциональный цвет фона |
|
||||
| [*int* | foreground] | Опциональный цвет символов |
|
||||
| [*char* | symbol] | Опциональный символ |
|
||||
| [*int* | transparency] | Опциональная прозрачность фона |
|
||||
|
||||
Работает как buffer.**square**(...), однако применяется сразу ко всей области экрана. Если аргументов не передается, то буфер заполняется стандартным черным цветом и символом пробела. Удобно для быстрого заполнения содержимого буфера.
|
||||
Работает как buffer.**square**(...), однако применяется сразу ко всем пикселям буфера. Если аргументов не передается, то буфер заполняется стандартным черным цветом и символом пробела. Удобно для быстрой очистки содержимого буфера.
|
||||
|
||||
buffer.**text**( x, y, color, text, transparency )
|
||||
-----------------------------------------------------------
|
||||
@@ -220,7 +219,15 @@ buffer.**semiPixelCircle**( xCenter, yCenter, radius, color )
|
||||
| *int* | radius | Радиус окружности |
|
||||
| *int* | color | Цвет окружности |
|
||||
|
||||
Растеризация окружности указанного цвета
|
||||
buffer.**bezierCurve**( points, color, precision )
|
||||
-----------------------------------------------------------
|
||||
| Тип | Аргумент | Описание |
|
||||
| ------ | ------ | ------ |
|
||||
| *table* | points | Таблица вида ```{{x = 32, y = 2}, {x = 2, y = 2}, {x = 2, y = 98}}```, содержащая опорные точки для отрисовки кривой Безье |
|
||||
| *int* | color | Цвет кривой Безье |
|
||||
| *float* | precision | Точность отрисовки кривой Безье. Чем меньше - тем точнее |
|
||||
|
||||
Растеризация [кривой Безье](https://ru.wikipedia.org/wiki/%D0%9A%D1%80%D0%B8%D0%B2%D0%B0%D1%8F_%D0%91%D0%B5%D0%B7%D1%8C%D0%B5) с указанным цветом.
|
||||
|
||||
Вспомогательные методы
|
||||
======
|
||||
@@ -236,7 +243,7 @@ buffer.**flush**( [width, height] )
|
||||
|
||||
Метод, устанавливающий разрешение экранного буфера равным указанному и заполняющий его черными пикселями с символом пробела. В отличие от buffer.**setResolution** не изменяет текущего разрешения GPU. Если опциональные аргументы не указаны, то размер буфера становится эквивалентным текущему разрешению GPU.
|
||||
|
||||
buffer.**getBufferIndexByCoordinates**( x, y ): int index
|
||||
buffer.**getIndexByCoordinates**( x, y ): int index
|
||||
-----------------------------------------------------------
|
||||
| Тип | Аргумент | Описание |
|
||||
| ------ | ------ | ------ |
|
||||
@@ -245,7 +252,7 @@ buffer.**getBufferIndexByCoordinates**( x, y ): int index
|
||||
|
||||
Метод, преобразующий экранные координаты в индекс экраннного буфера. К примеру, пиксель 2x1 имеет индекс буфера 4, а пиксель 3x1 имеет индекс буфера 7.
|
||||
|
||||
buffer.**getBufferCoordinatesByIndex**( index ): int x, int y
|
||||
buffer.**getCoordinatesByIndex**( index ): int x, int y
|
||||
-----------------------------------------------------------
|
||||
| Тип | Аргумент | Описание |
|
||||
| ------ | ------ | ------ |
|
||||
@@ -275,17 +282,32 @@ buffer.**rawGet**( index ): int background, int foreground, char symbol
|
||||
-- Подключаем библиотеку
|
||||
local buffer = require("doubleBuffering")
|
||||
|
||||
-- Рисуем 10 квадратиков, заполненных произвольным цветом
|
||||
-- Загружаем и рисуем изображение с лукошком с малиной
|
||||
buffer.image(1, 1, image.load("/MineOS/Pictures/Raspberry.pic"))
|
||||
-- Заполняем буфер черным цветом с прозрачностью 60%, чтобы малина на фоне была чуть темнее
|
||||
buffer.clear(0x0, 60)
|
||||
|
||||
-- Рисуем 10 квадратиков, заполненных рандомным цветом
|
||||
local x, y, xStep, yStep = 2, 2, 4, 2
|
||||
for i = 1, 10 do
|
||||
buffer.square(x, y, 6, 3, math.random(0x0, 0xFFFFFF), 0x0, " ")
|
||||
x, y = x + xStep, y + yStep
|
||||
end
|
||||
|
||||
-- Рисуем черную окружность
|
||||
buffer.semiPixelCircle(22, 22, 10, 0x0)
|
||||
-- Рисуем желтую окружность
|
||||
buffer.semiPixelCircle(22, 22, 10, 0xFFDB40)
|
||||
-- Рисуем белую линию
|
||||
buffer.semiPixelLine(2, 36, 35, 3, 0xFFFFFF)
|
||||
-- Рисуем желтую кривую Безье с точностью 0.01
|
||||
buffer.bezierCurve(
|
||||
{
|
||||
{ x = 2, y = 63},
|
||||
{ x = 63, y = 63},
|
||||
{ x = 63, y = 2}
|
||||
},
|
||||
0x44FF44,
|
||||
0.01
|
||||
)
|
||||
|
||||
-- Выводим содержимое буфера на экран
|
||||
buffer.draw()
|
||||
@@ -293,4 +315,4 @@ buffer.draw()
|
||||
|
||||
Результат:
|
||||
|
||||

|
||||

|
||||
@@ -43,7 +43,7 @@ function renderer.setPixelUsingDepthBuffer(x, y, pixelDepthValue, pixelColor)
|
||||
then
|
||||
if pixelDepthValue < renderer.depthBuffer[y][x] then
|
||||
renderer.depthBuffer[y][x] = pixelDepthValue
|
||||
buffer.semiPixelRawSet(buffer.getBufferIndexByCoordinates(x, math.ceil(y / 2)), pixelColor, y % 2 == 0)
|
||||
buffer.semiPixelRawSet(buffer.getIndexByCoordinates(x, math.ceil(y / 2)), pixelColor, y % 2 == 0)
|
||||
-- buffer.set(x, y, pixelColor, 0x0, " ")
|
||||
end
|
||||
end
|
||||
@@ -271,7 +271,7 @@ function renderer.renderFloatingText(x, y, z, color, text)
|
||||
end
|
||||
end
|
||||
|
||||
index = buffer.getBufferIndexByCoordinates(x, yInteger)
|
||||
index = buffer.getIndexByCoordinates(x, yInteger)
|
||||
background = buffer.rawGet(index)
|
||||
buffer.rawSet(index, background, color, unicode.sub(text, i, i))
|
||||
end
|
||||
|
||||
@@ -14,13 +14,13 @@ local buffer = {}
|
||||
------------------------------------------------- Core methods -------------------------------------------------
|
||||
|
||||
--Формула конвертации индекса массива изображения в абсолютные координаты пикселя изображения
|
||||
function buffer.getBufferCoordinatesByIndex(index)
|
||||
function buffer.getCoordinatesByIndex(index)
|
||||
local integer, fractional = math.modf(index / (buffer.tripleWidth))
|
||||
return math.ceil(fractional * buffer.width), integer + 1
|
||||
end
|
||||
|
||||
--Формула конвертации абсолютных координат пикселя изображения в индекс для массива изображения
|
||||
function buffer.getBufferIndexByCoordinates(x, y)
|
||||
function buffer.getIndexByCoordinates(x, y)
|
||||
return buffer.tripleWidth * (y - 1) + x * 3 - 2
|
||||
end
|
||||
|
||||
@@ -86,7 +86,7 @@ end
|
||||
|
||||
-- Получить информацию о пикселе из буфера
|
||||
function buffer.get(x, y)
|
||||
local index = buffer.getBufferIndexByCoordinates(x, y)
|
||||
local index = buffer.getIndexByCoordinates(x, y)
|
||||
if x >= 1 and y >= 1 and x <= buffer.width and y <= buffer.height then
|
||||
return buffer.rawGet(index)
|
||||
else
|
||||
@@ -96,7 +96,7 @@ end
|
||||
|
||||
-- Установить пиксель в буфере
|
||||
function buffer.set(x, y, background, foreground, symbol)
|
||||
local index = buffer.getBufferIndexByCoordinates(x, y)
|
||||
local index = buffer.getIndexByCoordinates(x, y)
|
||||
if x >= buffer.drawLimit.x1 and y >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and y <= buffer.drawLimit.y2 then
|
||||
buffer.rawSet(index, background, foreground or 0x0, symbol or " ")
|
||||
end
|
||||
@@ -114,7 +114,7 @@ function buffer.square(x, y, width, height, background, foreground, symbol, tran
|
||||
if not foreground then foreground = 0x000000 end
|
||||
if not symbol then symbol = " " end
|
||||
|
||||
local index, indexStepForward, indexPlus1 = buffer.getBufferIndexByCoordinates(x, y), (buffer.width - width) * 3
|
||||
local index, indexStepForward, indexPlus1 = buffer.getIndexByCoordinates(x, y), (buffer.width - width) * 3
|
||||
for j = y, (y + height - 1) do
|
||||
for i = x, (x + width - 1) do
|
||||
if i >= buffer.drawLimit.x1 and j >= buffer.drawLimit.y1 and i <= buffer.drawLimit.x2 and j <= buffer.drawLimit.y2 then
|
||||
@@ -148,7 +148,7 @@ function buffer.copy(x, y, width, height)
|
||||
for j = y, (y + height - 1) do
|
||||
for i = x, (x + width - 1) do
|
||||
if i >= 1 and j >= 1 and i <= buffer.width and j <= buffer.height then
|
||||
index = buffer.getBufferIndexByCoordinates(i, j)
|
||||
index = buffer.getIndexByCoordinates(i, j)
|
||||
table.insert(copyArray, buffer.newFrame[index])
|
||||
table.insert(copyArray, buffer.newFrame[index + 1])
|
||||
table.insert(copyArray, buffer.newFrame[index + 2])
|
||||
@@ -172,7 +172,7 @@ function buffer.paste(x, y, copyArray)
|
||||
for i = x, (x + copyArray.width - 1) do
|
||||
if i >= buffer.drawLimit.x1 and j >= buffer.drawLimit.y1 and i <= buffer.drawLimit.x2 and j <= buffer.drawLimit.y2 then
|
||||
--Рассчитываем индекс массива основного изображения
|
||||
index = buffer.getBufferIndexByCoordinates(i, j)
|
||||
index = buffer.getIndexByCoordinates(i, j)
|
||||
--Копипаст формулы, аккуратнее!
|
||||
--Рассчитываем индекс массива вставочного изображения
|
||||
arrayIndex = (copyArray.width * (j - y) + (i - x + 1)) * 3 - 2
|
||||
@@ -224,7 +224,7 @@ function buffer.text(x, y, textColor, text, transparency)
|
||||
end
|
||||
end
|
||||
|
||||
local index, sText = buffer.getBufferIndexByCoordinates(x, y), unicode.len(text)
|
||||
local index, sText = buffer.getIndexByCoordinates(x, y), unicode.len(text)
|
||||
for i = 1, sText do
|
||||
if x >= buffer.drawLimit.x1 and y >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and y <= buffer.drawLimit.y2 then
|
||||
buffer.newFrame[index + 1] = not transparency and textColor or color.blend(buffer.newFrame[index], textColor, transparency)
|
||||
@@ -238,7 +238,7 @@ end
|
||||
-- Отрисовка изображения
|
||||
function buffer.image(x, y, picture)
|
||||
local xPos, xEnd, bufferIndexStepOnReachOfImageWidth = x, x + picture[1] - 1, (buffer.width - picture[1]) * 3
|
||||
local bufferIndex = buffer.getBufferIndexByCoordinates(x, y)
|
||||
local bufferIndex = buffer.getIndexByCoordinates(x, y)
|
||||
local imageIndexPlus2, imageIndexPlus3
|
||||
|
||||
for imageIndex = 3, #picture, 4 do
|
||||
@@ -388,13 +388,13 @@ end
|
||||
function buffer.semiPixelSet(x, y, color)
|
||||
local yFixed = math.ceil(y / 2)
|
||||
if x >= buffer.drawLimit.x1 and yFixed >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and yFixed <= buffer.drawLimit.y2 then
|
||||
buffer.semiPixelRawSet(buffer.getBufferIndexByCoordinates(x, yFixed), color, y % 2 == 0)
|
||||
buffer.semiPixelRawSet(buffer.getIndexByCoordinates(x, yFixed), color, y % 2 == 0)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.semiPixelSquare(x, y, width, height, color)
|
||||
-- for j = y, y + height - 1 do for i = x, x + width - 1 do buffer.semiPixelSet(i, j, color) end end
|
||||
local index, indexStepForward, indexStepBackward, jPercentTwoEqualsZero, jFixed = buffer.getBufferIndexByCoordinates(x, math.ceil(y / 2)), (buffer.width - width) * 3, width * 3
|
||||
local index, indexStepForward, indexStepBackward, jPercentTwoEqualsZero, jFixed = buffer.getIndexByCoordinates(x, math.ceil(y / 2)), (buffer.width - width) * 3, width * 3
|
||||
for j = y, y + height - 1 do
|
||||
jPercentTwoEqualsZero = j % 2 == 0
|
||||
|
||||
@@ -537,7 +537,7 @@ end
|
||||
|
||||
-- Функция группировки изменений и их отрисовки на экран
|
||||
function buffer.draw(force)
|
||||
local changes, index, indexStepOnEveryLine, indexPlus1, indexPlus2, sameCharArray, x, xCharCheck, indexCharCheck, currentForeground = {}, buffer.getBufferIndexByCoordinates(buffer.drawLimit.x1, buffer.drawLimit.y1), (buffer.width - buffer.drawLimit.x2 + buffer.drawLimit.x1 - 1) * 3
|
||||
local changes, index, indexStepOnEveryLine, indexPlus1, indexPlus2, sameCharArray, x, xCharCheck, indexCharCheck, currentForeground = {}, buffer.getIndexByCoordinates(buffer.drawLimit.x1, buffer.drawLimit.y1), (buffer.width - buffer.drawLimit.x2 + buffer.drawLimit.x1 - 1) * 3
|
||||
|
||||
for y = buffer.drawLimit.y1, buffer.drawLimit.y2 do
|
||||
x = buffer.drawLimit.x1
|
||||
|
||||
@@ -127,7 +127,7 @@ function syntax.highlightString(x, y, str, indentationWidth)
|
||||
if x > buffer.drawLimit.x2 then
|
||||
break
|
||||
elseif x >= buffer.drawLimit.x1 then
|
||||
bufferIndex = bufferIndex or buffer.getBufferIndexByCoordinates(x, y)
|
||||
bufferIndex = bufferIndex or buffer.getIndexByCoordinates(x, y)
|
||||
buffer.newFrame[bufferIndex + 1] = colors[symbol] or syntax.colorScheme.text
|
||||
buffer.newFrame[bufferIndex + 2] = symbols[symbol]
|
||||
bufferIndex = bufferIndex + 3
|
||||
|
||||
Reference in New Issue
Block a user