Re: Great canvas article and demo

2013-09-16 Thread Alexander Burger
Hi Tomas,

 as a proof of concept, I have implemented your zapper demo using svg and
 without any javascript, see http://logand.com:2234/

Very nice indeed! SVG is a good alternative to Canvas, it seems.


 1) It uses svg instead of canvas, meaning that:
 
   - There is no javascript required for drawing stuff.  The same
 approach to generating html can be used to generate svg.
 
   - It's easy to define parts of the picture to be clickable, so if you
 click on a point in the graph, the text clicked will be updated with
 the y axis value, as an example.  Also it displays a buuble if you
 leave cursor above a point.
 
   - svg used to be slow, broken and non-portable across browsers a few
 years ago but these days, it's rather good for many use-cases.
 There are still some things broken on some browsers, but it's
 getting steadily better.
 
   - Graphics transformation can be easily specified in svg, so there is
 no need to do complicated coordinate calculations. e.g.
 
 g transform=translate(0 300) scale(1 -1) translate(0.5 150.5)
 
 changes the orientation and origin of the coordinate system, and
 also moves the centres of lines a bit so that 1px lines are sharp
 (which is what you discussed with Jon I guess, and which your
 example doesn't do for the horizontal axis I think).
 
 2) The example doesn't use any javascript meaning that the maximum
refresh speed is 1s.  This is good enough for many use-cases.  If
not, a bit of javascript can be added in a similar way like the
current picolisp refresh is implemented.  As you mentioned, something
like the +Auto class.
 
If the automatic refresh is not desirable for the whole page, the
whole svg graph could be put into an iframe which would refresh, but
the surounding html would stay.  But it's not critical for this demo.

This makes a lot of sense. Thanks!

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Great canvas article and demo

2013-09-16 Thread Klaus Schilling
From: Alexander Burger a...@software-lab.de
Subject: Re: Great canvas article and demo
Date: Mon, 16 Sep 2013 08:25:25 +0200

 Hi Tomas,
 
  as a proof of concept, I have implemented your zapper demo using svg and
  without any javascript, see http://logand.com:2234/
 
 Very nice indeed! SVG is a good alternative to Canvas, it seems.
 
 
Would it also be feasible to use (encapsulated?) postscript instead of
SVG? 

Or is there maybe even a way to use the Canvas widgets of Tcl/Tk over 
the ffi or generating appropriate tcl code on the fly?

Klaus Schilling
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Great canvas article and demo

2013-09-16 Thread Alexander Burger
On Mon, Sep 16, 2013 at 10:20:03AM +0200, Klaus Schilling wrote:
 Would it also be feasible to use (encapsulated?) postscript instead of
 SVG? 

Probably.

But what surely works well is Gnuplot. We used it in the mentioned
project to draw the final data. Code fragments:

In a library file:

   # Draw Gnuplot
   # Data in (tmp gp.csv)
   # Result in (tmp gp.{typ})
   (de gnuplot (Typ SizeX SizeY Flags Col)
  (out (tmp gp.cmd)
 (if (== Typ 'eps)  # 'eps' or 'png'
(prinl
   set terminal postscript eps  size 
   SizeX
   , 
   SizeY
enhanced color )
(prinl
   set terminal png  font helvetica 9  size 
   SizeX
   , 
   SizeY ) )
 (prinl set encoding utf8)
 (prinl set xlabel \Netzteil [mA]\)
 (prinl set y2label \Drehmoment [Nm]\)
 (prinl set ytics)
 (prinl set ytics nomirror)
 (prinl set y2tics)
 (prinl set grid xtics)
 (prinl set grid y2tics)
 (prinl set key outside bottom)
 (prinl set style data lines)
 (prinl set output \ (tmp gp. Typ) \)
 (prin plot \ (tmp gp.csv)
\ using 1:3  axes x1y2  lc rgb \red\  t \Drehmoment [Nm]\ )
 (mapc
'((F L I)
   (and
  F
  I
  (prin , \ (tmp gp.csv)
 \ using 1: I
  lc rgb \ (caddr L)
 \ t \ (cadr L) \ ) ) )
Flags
Col
(2 NIL 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18) )
 (prinl) )
  (call 'gnuplot (tmp gp.cmd)) )

The chart with data in the GUI:

   (gui '(+E/R +Chart) '(sel : home obj) 19)
   (table 'chart Selektion
  (mapcar
 '((L)
(list
   (cons 'style (pack color: (caddr L)))
   (cadr L) ) )
 (with '*DrawMes
(cons (: col 1) (: col -2)) ) )
  (do 6
 (row (alternating)
(gui 1 '(+Checkbox))
(gui 2 '(+Checkbox))
(gui 3 '(+Checkbox))
(gui 4 '(+Checkbox))
(gui 5 '(+Checkbox))
(gui 6 '(+Checkbox))
(gui 7 '(+Checkbox))
(gui 8 '(+Checkbox))
(gui 9 '(+Checkbox))
(gui 10 '(+Checkbox))
(gui 11 '(+Checkbox))
(gui 12 '(+Checkbox))
(gui 13 '(+Checkbox))
(gui 14 '(+Checkbox))
(gui 15 '(+Checkbox))
(gui 16 '(+Checkbox))
(gui 17 '(+Rid +Able +Tiny +Button) '(curr) Anzeigen
   '(let (F (cons (curr 1) T (curr -1))  C (get '*DrawMes 'col))
  (out (tmp gp.csv)
 (for L (: home obj lst)
(prinl (glue ^I L)) ) )
  (gnuplot 'png 1200 600 F C)
  (call 'mv (tmp gp.png) (tmp full.png))
  (gnuplot 'png 800 300 F C) ) )
(gui 18 '(+DelRowButton))
(gui 19 '(+BubbleButton)) ) ) )
   (scroll 6 T)

and finally the display in the GUI:

   (gui '(+Upd +Img)
  '(let F (tmp gp.png)
 (and (info F) F) )
  Grafik
  '(let F (tmp full.png)
 (and (info F) (pack + F)) ) )
   (--)
   (Für eine vergrößerte Ansicht in einem neuen Tab bitte auf die Grafik 
klicken) ) )

Hope this helps
♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Great canvas article and demo

2013-09-16 Thread Jakob Eriksson


On September 16, 2013 at 9:30 AM Tomas Hlavaty t...@logand.com wrote:

 3) I guess most of the overhead of the http request is probably
establishing the connection.  My bett is that it doesn't really
matter if you send 1kB or 5kB of data.  For example, if I run this


It might matter, the only way to make sure is to measure. For instance
you can fit an answer inside an IP packet completely, it may make a
difference. (There are also many other things to consider, for instance
if there are CSS or Javascript resources which are blocking start of
browser rendering, until those are loaded.)

best regards,
Jakob
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (path @lib/) does not work with local installation?

2013-09-16 Thread Alexander Burger
Hi Thorsten,

 Ok, but then the question remains how to get (in a program) the absolute
 path to the PicoLisp installation the programs runs in when you assume a
 local installation was invoked - but you have no idea how?
 
 I thought about combining (cmd) and (path ...), but that doesn't help either

How about (pwd) and (path ...)?

   : (pack (pwd) / (path @lib/misc.l))

If a local installation is invoked, then the path must be relative to
the current working directory.


A minor drawback is that the resulting path may contain .., e.g.:

   $ ../../pil +
   : (path @lib/misc.l)
   - ../../lib/misc.l

   : (pack (pwd) / (path @lib/misc.l))
   - /bla/laber/picoLisp/foo/bar/../../lib/misc.l


To make it practically useful, it should work transparently for both
local and global installations. For that, I would recommend:

   : (let P (path @lib/misc.l)
  (or
 (pre? / P)
 (pack (pwd) / P) ) )

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Great canvas article and demo

2013-09-16 Thread Tomas Hlavaty
Hi Jakob,

Jakob Eriksson ja...@aurorasystems.eu writes:
 On September 16, 2013 at 9:30 AM Tomas Hlavaty t...@logand.com wrote:

 3) I guess most of the overhead of the http request is probably
establishing the connection.  My bett is that it doesn't really
matter if you send 1kB or 5kB of data.  For example, if I run this

 It might matter, the only way to make sure is to measure. For instance
 you can fit an answer inside an IP packet completely, it may make a
 difference. (There are also many other things to consider, for instance
 if there are CSS or Javascript resources which are blocking start of
 browser rendering, until those are loaded.)

yeah, but this is getting too theoretical.

  The IPv4 packet length field is 16 bits, for a maximum size of 65535
  bytes.

  IPv6 - The extended length option provides for a 32 bit length field,
  supporting packet length's up to 4294967295 bytes.

but those are further fragmented

  maximum length Ethernet II frames (1518 bytes, with a payload of 1500
  bytes) 

Alex' example might fit in one Ethernet frame.  My too, if you remove
the additional feature (clickable graph and popup bubbles) and gzip the
page source.

But then there is sync, and all the communication slows down on ack...

Anyway, it's fast enough, and the and it doesn't make any difference if
it loads in 3ms (locally) or 60ms (from logand.com).  Btw, both times
are somewhere around the frame rate of TV (40ms) and human eye needs
about 100ms to not notice :-D The example doesn't contain any CSS or
Javascript, intentionally.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe