Posted 16 April 2017 - 10:51 PM
<p>Hey all, so recently I have been busy coding this API that adds a bit of easy, screen-size independent
graphics.
Now on GitHub:
https://github.com/M...ose/tree/master
Features:
-Automatically detects if the screen is color or not, and if not (now comes the magic) instead of erroring, it remaps the color to grayscales (White = white, light colors = light gray, dark colors = dark gray, dark = dark and so on)
-Dialogue Boxes.
Concept:
DOCUMENTATION
Initializes Glucose, sets the color(monochrome) mode and sets the app title and author. Must be called at the beginning of the program.
-glucose.terminate()
Terminated Glucose and closes the program. [WIP]
-glucose.makeEdgeButton(letter, y-line)
Created a button like a "X" or "_" on the right side on the screen at the specified Y Line. Can be used to create the buttons mentioned above.
-glucose.createMenuBand()
Deprecated.
-glucose.setRibbonBaseColor(color)
Sets the ribbon band background color to color.
.glucose.setRibbonContentColor(color)
Sets the BG Color of the ribbon when it is opened.
-glucose.setRibbonAttribute(internalName, attribute, value)
Sets the attribute "attribute" of the ribbon tab "internalName" to "value".
Used attributes:
baseColor: ribbon base color (Can be set via setRibbonBaseColor(…)
textColor: ribbon text color
openColor color of the currently opened ribbon
startPosition: Where the ribbon tab "starts" (X Coord); don't override this as it screws stuff up
endPosition: Where the ribbon tab "ends" (X Coord); again, don't mess with this
ribbonData: Text in the ribbon
ribbonIcon: WIP
-glucose.drawRibbonContents(internalName)
Draws whatever should show when the ribbon "internalName" is opened, internal use
-glucose.addIcon(internalName, iconTable)
WIP
-glucose.addRibbonContent(internalName, content)
Text to draw inside a ribbon, please bear in mind that ribbon content must be a table with
the keys 1-5, each representing a line on the screen
-glucose.openRibbon(internalName)
Opens the ribbon internalName as if you clicked on it. You'll need this, trust me.
-glucose.fillLineWithCharacters(line, char)
Self-Explanatory. Internal use.
-glucose.createDialogBox(text, title)
Creates a "press ok" box with the title title and the text text, which again, must be a table with every key representing a line on the screen.
-glucose.writeCentered(text, yCoord)
Writes text centered. Simple as that.
To get it, you need EMPaM:
http://www.computerc...960#entry278960
Once you have EMPaM, you need to run
Once you have this, you're set!
Just load using os.loadAPI("/lib/glucose"). No fancy dofile stuff.
Example program:
graphics.
Now on GitHub:
https://github.com/M...ose/tree/master
Features:
Spoiler
-Ribbons. You know, the Microsoft-Office-Style ribbons. (Wink wink nudge nudge MS Office in CC coming soon)-Automatically detects if the screen is color or not, and if not (now comes the magic) instead of erroring, it remaps the color to grayscales (White = white, light colors = light gray, dark colors = dark gray, dark = dark and so on)
-Dialogue Boxes.
Concept:
Spoiler
The thing with gfx Apis is that they Window. I personally think that windowing systems in CC are pretty pointless (at least in the terminal window) So I tried to opt this API to be more Tab-Based. Ther Error messages I talked about in "Features" span across the whole Window, though.DOCUMENTATION
Spoiler
-glucose.init(title. author)Initializes Glucose, sets the color(monochrome) mode and sets the app title and author. Must be called at the beginning of the program.
-glucose.terminate()
Terminated Glucose and closes the program. [WIP]
-glucose.makeEdgeButton(letter, y-line)
Created a button like a "X" or "_" on the right side on the screen at the specified Y Line. Can be used to create the buttons mentioned above.
-glucose.createMenuBand()
Deprecated.
-glucose.setRibbonBaseColor(color)
Sets the ribbon band background color to color.
.glucose.setRibbonContentColor(color)
Sets the BG Color of the ribbon when it is opened.
-glucose.setRibbonAttribute(internalName, attribute, value)
Sets the attribute "attribute" of the ribbon tab "internalName" to "value".
Used attributes:
baseColor: ribbon base color (Can be set via setRibbonBaseColor(…)
textColor: ribbon text color
openColor color of the currently opened ribbon
startPosition: Where the ribbon tab "starts" (X Coord); don't override this as it screws stuff up
endPosition: Where the ribbon tab "ends" (X Coord); again, don't mess with this
ribbonData: Text in the ribbon
ribbonIcon: WIP
-glucose.drawRibbonContents(internalName)
Draws whatever should show when the ribbon "internalName" is opened, internal use
-glucose.addIcon(internalName, iconTable)
WIP
-glucose.addRibbonContent(internalName, content)
Text to draw inside a ribbon, please bear in mind that ribbon content must be a table with
the keys 1-5, each representing a line on the screen
-glucose.openRibbon(internalName)
Opens the ribbon internalName as if you clicked on it. You'll need this, trust me.
-glucose.fillLineWithCharacters(line, char)
Self-Explanatory. Internal use.
-glucose.createDialogBox(text, title)
Creates a "press ok" box with the title title and the text text, which again, must be a table with every key representing a line on the screen.
-glucose.writeCentered(text, yCoord)
Writes text centered. Simple as that.
To get it, you need EMPaM:
http://www.computerc...960#entry278960
Once you have EMPaM, you need to run
empam --addrepo mrobsidy-main https://raw.githubusercontent.com/MrObsidy/technical-data-inf/master/empam/mrobsidy-main.repo
empam --install glucose
Once you have this, you're set!
Just load using os.loadAPI("/lib/glucose"). No fancy dofile stuff.
Example program:
Spoiler
os.loadAPI("/disk/devel-alex/glucose")
local errorMsg = {
[1] = "You presed somewhere on the screen",
[2] = "and there is no function here :)/>/>/>/>/>/>/>/>",
[3] = "pres ok to resume working",
[4] = "also this dialogue box is",
[5] = "alot bigger :D/>/>/>/>/>/>/>/>"
}
local fileText = {
[1] = "This is the File Menu.",
[2] = "and this message here",
[3] = "is only a placeholder",
[4] = "for actual messages later",
[5] = "to come! LG Alex"
}
local editText = {
[1] = "This is the Edit Menu.",
[2] = "",
[3] = "",
[4] = "",
[5] = ""
}
local insertText = {
[1] = "This is the Insert Menu.",
[2] = "",
[3] = "",
[4] = "",
[5] = ""
}
local formatText = {
[1] = "This is the Format Menu.",
[2] = "",
[3] = "",
[4] = "",
[5] = ""
}
term.setBackgroundColor(colors.white)
term.setTextColor(colors.gray)
term.clear()
glucose.writeCentered("===============================", 9)
glucose.writeCentered("Test Application (C) MrObsidy24", 10)
glucose.writeCentered(" Fetching necessary data... ", 11)
sleep(5)
glucose.init("Test App", "MrObsidy24")
glucose.setRibbonBaseColor(colors.red)
glucose.makeEdgeButton("X", 1)
glucose.setRibbonBaseColor(colors.lime)
glucose.makeRibbonEntry(" File ", "file")
glucose.setRibbonAttribute("file", "openColor", colors.green)
glucose.setRibbonBaseColor(colors.gray)
glucose.makeRibbonEntry(" Start ", "edit")
glucose.makeRibbonEntry(" Insert ", "insert")
glucose.makeRibbonEntry(" Format ", "format")
glucose.setRibbonAttribute("file", "ribbonData", fileText)
glucose.setRibbonAttribute("edit", "ribbonData", editText)
glucose.setRibbonAttribute("insert", "ribbonData", insertText)
glucose.setRibbonAttribute("format", "ribbonData", formatText)
glucose.openRibbon("edit")
while true do
local event, button, x, y = os.pullEvent("mouse_click")
local filexstart = glucose.getRibbonAttribute("file", "startPosition")
local editxstart = glucose.getRibbonAttribute("edit", "startPosition")
local filexend = glucose.getRibbonAttribute("file", "endPosition")
local editxend = glucose.getRibbonAttribute("edit", "endPosition")
local insertxstart = glucose.getRibbonAttribute("insert", "startPosition")
local formatxstart = glucose.getRibbonAttribute("format", "startPosition")
local insertxend = glucose.getRibbonAttribute("insert", "endPosition")
local formatxend = glucose.getRibbonAttribute("format", "endPosition")
local xbutton = term.getSize()
if button == 1 and x >= filexstart and x = editxstart and x = insertxstart and x = formatxstart and x
Edited on 11 May 2019 - 07:09 PM