I would not worry about efficiency, preserveDrawingBuffer has warnings on
it - that it is notoriously inefficient. (It's just an easy way of copying
content forward from previous renders.)

And I suspect that your vanishing turtles problem is also a result of
misplaced concerns about efficiency.

Mind you, efficiency can and will be important, but it needs to take back
seat to correctness.

And, when using webgl, you need to somehow do a complete render of the
entire webgl scene every time you draw something. But without looking at
your code I cannot be more specific.

(0) The arrows get a bit involved because of browser compatibility issues.
But basically you'll probably define a window variable that says whether
arrow keys are on or off, and have your arrow key handler do nothing if
they are off. Next, you need to define (a) the mechanism for turning it on
and turning it off, and (b) the visual feedback for the user. For example,
you might turn off arrows with the onfocus event for your input box or text
area. But how to turn them back on? You'll want to turn them back on when
the user hits enter, but you'll also want to define a "cancel" mechanism
(maybe just a button on screen, maybe the ESC key, perhaps both) so the
user does not have to execute a turtle command to have the arrow keys work
for opengl.

It's tempting to think about using focus or mouseover to have arrow keys
work again, and that introduces other problems (like what if the user moves
their mouse habitually before typing - it's a visual obstacle... and also,
the focus and blur events probably aren't quite what you want.)

(1) You probably do not really want to change the locale of jijx. Instead,
you probably want to emit html along the lines of: <a href="/tgsj"
target="_tgsj">turtle graphics</a>

(2) I do not have enough information to reason about this issue. I need
more detail.

(3) turtle graphics paths? You might use html5 local storage. This has some
limitations (browser support, and of course some students might use
multiple browsers or different machines - lots of potential issues there,
trading security and usability along with ease of access and time to build,
and at some point you have to tell them to just deal with whatever you've
choosen). Another approach stores them on the server - J can write them to
disk if you want them to survive server restarts (but this requires some
sort of naming mechanism and if you're doing this for students that might
introduce other issues). Another approach involves copy and paste (student
can store wherever). Another approach involves generating bookmarkable urls.

If you are generating urls, they might be javascript: urls (a function call
with arguments, perhaps), or data: urls or urls into jhs (which pass query
string parameters, maybe). It's probably worth a few moments thinking about
the failure modes of each and deciding what you are comfortable working
with. (A javascript url has to assume you are in the right context, while a
reference to jhs will to some degree force the right context but still
requires the server is running).

I hope this is enough.

Thanks,

-- 
Raul



On Mon, Mar 17, 2014 at 12:51 PM, Brian Schott <[email protected]>wrote:

> In this thread in its original post (to which I am replying here), I was
> not able to view old turtle path lines when new lines were added. Raul
> correctly pointed out a property of canvas, preserveDrawingBuffer (pDB),
>  that preserves the old lines and shows the new lines, too.
>
> However, because there are some other features in webg; 3D canvas rendering
> which only work with pDB set to false, I have found ways to send all of the
> paths via ajax, not just the new lines, each time an update occurs. That
> does not seem very efficient, but I really want the other features, one of
> which permit the whole drawing to be rotated or zoomed according to user
> requests and these features are undermined by pDB being true instead of
> false.
>
> I have implemented a version of this app that does send the whole history
> of paths and turtles every time and have not tested the time or the stack
> growth, but this may be the only viable alternative.
>
> http://www.jsoftware.com/jwiki/BrianSchott/code/turtleGraphics/tgsjhs
> http://youtu.be/eb6d9KbStM0
>
> (0) A major issue of tgsjhs is that there are 2 conflicting drawing modes
> used. One of the modes is the original one where the arrow keys are used to
> reorient the viewer's viewpoint. This mode is very desirable, but there are
> at least two problems: not only does the use of the arrow keys erase the
> turtle drawing temporarily, but I like to use the left and right arrow key
> often in the text field to edit the entry slightly, but now the arrow keys
> cannot be used for that. So I would really like ideas for fixing these 2
> problems.
>
> For example is there a way to ignore the arrow key that is used in the
> graphic while the focus is in the text field?
>
> I can always recover the turtle graphics screen by entering a do-nothing
> movement or turn command like fd 0 or rt 0, but another idea is to add one
> of those do-nothing commands to the javascript draw() function so that each
> such refresh is followed by a turtle images/paths refresh. A problem with
> this idea is that already each time the turtle moves or turns,
> drawTurtles() is called and it already calls draw(), so wouldn't that
> produce an endless loop, which I do not know how to break out of.
>
> Other niggling problems that I have no solution for are the following.
>
> (1) I have implemented a 3-frame browser page like the one in JHS demo9.ijs
> but it is not pretty. What I would most like to do is correctly add an
> automatic J command in jijx frame that makes the locale  cocurrent 'tgsj' .
>
> (2) The lighting does not work well when I turn the js variable lit to 1,
> so I have turned off lighting. I suspect the problem is related to a webgl
> feature called  CULL_FACE, but I am not sure.
>
> (3) Does it make sense to send the whole history of paths each time the
> system is updated by the user, or is there some way to save the history in
> javascript or html, for example?
>
>
>
> Thank you,
>
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to