Hello all,
I'd like to provide some more clarity on how the prototype draws
things. There are a number of options and we can start simple and add
features as we go.
First, there is the already existing "switch statement in a loop" that
takes an infon list of primitive drawing commands (circle, line,
rectangle, etc.) and 'draws' then. Currently, this uses SDL_Draw but
we are switching to SDL_gfx for transparency and other features.
Eventually we will add openGL, Cuda, etc.
Currently, the list of drawing command primitives is hand-coded in
display.pr. The next step is to change this so that it is generated
from myStuff, a theme, preferences, etc.
Let's look at a pseudo code, C-like example then think about how to
convert it to proteus. The following 'code' is supposed to produce the
stream of drawing primitives to be displayed.
--------------------
For each item in items-to-draw
Based on item's type, // and perhaps other things like size,
i.e., very large lists may display differently
EITHER
Find a C++ routine to do the drawing // e.g., circle,
line, text-in-a-font, etc.
OR
Find a pixel-map in Proteus that mathematically tells
whether pixels are in/out what color
Search these for the pixel-map:
preferences
User's Theme
The object itself // e.g., a circle should
know it's own pixel-map. (all pixel in a radius from the center)
In a library of maps for various things. //
Some of these could be generic visualization methods, others could be
maps to those visualizations. Addresses, generic 'structs', text-
files, hex-files.
--------------------
What are some options for doing this in Proteus?
1) The above code could be written in C++ in slip.cpp just about like
it is. But if we did it that way we would loose the flexibility of
having the engine try different thing, optimize processes, etc.
On the other hand we could mix and match the following:
2) Put the "for each" loop in Proteus. Eventually this makes sense as
it will allow the engine to farm the work out as needed.
3) Write a C++ function that will choose a way to translate item to a
list of drawing primitives.
3a) Call that function from slip.cpp
3b) Put the function into functions.h and 'call' it from Proteus
* The function could do low-level shapes in Proteus or C++
* It could use C++ or Proteus to search for pixel-maps
Ultimately, we want all of it to be written in Proteus as a command
like "Interact with user X via touchscreen Y using theme Z" But that's
a big step. Better to do a little at a time.
ASIDE: Why would we want all of it to be written in Proteus? Many
reasons some of which are:
* The engine will be able to optimize the process or farm it out
to a grid or GPU or threads.
* When the engine knows it is supposed to interact with "User X"
it will automatically use valid security measures to ensure it is
doing that correctly. If a new security flaw is discovered it will
take the form "that might not be user X if ____" That assertion alone
will make the engine use additional checks on your identity to form a
valid inference.
* What if we later have a new thing which isn't a touch screen? Or
if we want it do some something other than "interact"? E.g., maybe
there will be a theme that requires two touchscreen.
* We may want to change it to interact with User X or User X's
friends if they are currently holding the phone.
Coding it in Proteus and not C++ gives us that flexibility.
For now, we should code all or some of it C++ in slip.cpp. Let me know
if you are working on this and don't want to have a collision.
Bruce
P.S., The next topic might be switching from a hard-coded 'items-to-
draw' to a generated one.