Jump to content




Glucose - A small but nifty graphics API


3 replies to this topic

#1 MrObsidy

  • Members
  • 62 posts
  • LocationHesse, Germany

Posted 16 April 2017 - 09: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:
Spoiler

Concept:

Spoiler

DOCUMENTATION
Spoiler


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]
[code]
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 © 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 by MrObsidy, 11 May 2019 - 08:09 PM.


#2 Exerro

  • Members
  • 800 posts

Posted 17 April 2017 - 12:08 PM

Hey, this is really cool! I played with a ribbon-like idea with an old OS framework, looked like this:

Posted Image

Animations would really help imo.

Nice name :P

#3 MrObsidy

  • Members
  • 62 posts
  • LocationHesse, Germany

Posted 17 April 2017 - 02:54 PM

 Exerro, on 17 April 2017 - 12:08 PM, said:

Animations would really help imo.

Added to To-Do list

I think i'll make a glucose.disableAnimationFunction() or something for servers or so (too bad there is
no os.isRemote() function to auto-disable animations - oh well)

EDIT:
I think I will not add animations as that would
1) require a rewrite of the drawing system, the drawRibbonContents() method gets called weirdly from a closing dialogue box (don't ask)
2) probably will slow things down quite a bit, especially when waiting for something pointless.

EDIT 2:
Currently completely rewriting glucose from scratch to support animations and be buffer based instead of statically drawing everything. :)

Edited by MrObsidy, 18 April 2017 - 07:42 PM.


#4 MrObsidy

  • Members
  • 62 posts
  • LocationHesse, Germany

Posted 11 May 2019 - 07:42 PM

Bump: If people still use this, I changed the installation method from pastebin to EMPaM which can be found here: http://www.computerc...960#entry278960





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users