CANVASOBJECT SomeFamily.newCanvas(integer SizeX, integer SizeY, [color_spec InitialColor])
Perhaps the
SomeFamily may be
forms, but I don't know the best fit.
The function should spawn a new window large enough to contain the drawing area (
which means figuring out some way to decide how large the window itself needs to be, based on the boarder size of the scheme). The drawing area will simply be a rectangle of color
InitialColor, or straight black if that parameter isn't provided.
The function should return an object. Not a handle number like with form calls, an actual object that can be indexed like a table. A list of indices this object should have:
CANVASOBJECT.open --
Boolean value that becomes false if window is closed
CANVASOBJECT.onClose --
Starts nil; Can be assigned a function to call when window is closed
CANVASOBJECT.autoClear --
Starts false; If assigned true, clears canvas every frame
CANVASOBJECT.InitialColor --
Used for clearGraphics; Alpha should be ignored
CANVASOBJECT:clearGraphics
CANVASOBJECT:draw<various> --
I expect all related gui functions here
A call to CANVASOBJECT:drawRectangle should have an effect virtually identical to the similarly named gui.drawRectangle, except that the target area would be this canvas we created earlier. Extrapolate this example with other such draw functions.
If you're confused as to the use of this CANVASOBJECT, I will provide a sample code:
Language: lua
local MyCanvas = SomeFamily.newCanvas(200,200)
MyCanvas.autoClear = true
while MyCanvas.open do
MyCanvas:drawText(0,0,"Hello World")
MyCanvas:drawBox(10,30,190,190,0xFFFFFFFF,0xFF0000FF)
MyCanvas:drawText(12,32,memory.read_s8(0x0080))
emu.frameadvance()
end
In case it is necessary for those who don't know lua syntax,
SomeTable:FunctionCall(x,y,z) is the same as
SomeTable.FunctionCall(SomeTable,x,y,z) -- Note the colon or period. This will allow a way for the attached function to identify the object in question. Although, generating a new function that "already knows" when spawning multiple canvas objects would mean we don't need the colon, but it might be best to have the identifier.
If such a function already exists, please point me to such function, since I missed it while looking through the functions list.