simple graphic with newLISP

Started by didi, May 04, 2007, 10:52:57 PM

Previous topic - Next topic

didi

What about  pure  newLISP  and the browser  like explorer or firefox as an

userinterface -  at least as an output ?  

Generating text is not a problem, but how can one generate graphic for that. I'm thinking about a simple x-y 2D-graph  to show some functions like in good old basic 20 years ago.

One idea is to generate a ppm-file ,  which seems to have the simplest format i found .  Speed is no problem ,  it should be easy to use .



Do you have any idea ?

newdep

#1
Generating a 2d graph is as easy as it comes... you can use any 2d graph / draw library and inport functions and draw directly to a graphicas format,

display it in firefox..et..voila.. (g2-library..gd-library...cairo...gdk...tk..opengl..gnu-plot..

on windows you can use direct drawing API too...it can all be called directly)



If you want realtime graph generating thats possible to with the use of cgi via those library's or with opengl or else...



If you want integration with XUL or javascript you could first have to dig through

the programming bible of mozilla..(not exactly an easy example on how to program graphics..)





But one thingsis not default..and thats that newlisp is not by default

integrated with any graphice format..



Example below does GD libray , cairo works fine...

(load "gdlib-init.lsp")



(setq img   (gdImageCreate 200 200))

(setq pitch (gdImageColorAllocate img 0 0 0))

(setq snow  (gdImageColorAllocate img 240 240 240))



(gdImageRectangle img 25 25 175 75 snow)

(gdImageArc       img 50 25 98 48 0 360 snow)



(setq points (dup "x00" 6))



;; x1 y1 x2 y2 x3 y3

(setq points (pack "uuuuuu" 25 25 150 25 150 75 25 150 ))



(gdImagePolygon img points 4 snow)



(setq outf (fopen "./test-polygon.png" "wb"))

(gdImagePng img outf)

(fclose outf)

(gdImageDestroy img)

(exit)









Norman.
-- (define? (Cornflakes))

cormullion

#2
Have you seen grapher on the code page of newlisp.org?



Personally i use mainly postscript for graphics work -



http://newlisper.blogspot.com/2006/11/whats-new.html">http://newlisper.blogspot.com/2006/11/whats-new.html

http://newlisper.blogspot.com/2006/10/noodling-around.html">http://newlisper.blogspot.com/2006/10/n ... round.html">http://newlisper.blogspot.com/2006/10/noodling-around.html

http://newlisper.blogspot.com/2006/01/quickie-postscript-graphics.html">http://newlisper.blogspot.com/2006/01/q ... phics.html">http://newlisper.blogspot.com/2006/01/quickie-postscript-graphics.html



Although it would be useful if newLISP could generate PNG or GIF graphics as well...

didi

#3
@newdep , thankyou for your fast answer :-)  

I will try the  GD-library . On the first view  i have to load the gtk+ environment with 6MB up to 12 MB ,  that's what i don't like very much , in some way it doesn't fit  to the 0.2MB of newlisp. I'm not happy with the tk environment, too.

But maybe this is the best way and  i want to try your example , it looks easy , where do i get the "gdlib-init.lsp" ?  



@cormullion

Thanks  for the postscript tipp and the links to the newlisper .  I have a win2000 system ,  and i think i have  to install my ghost-script/viewer for that.  Now i have a lot to play with  :-)



I hope i don't bother you, but that is the point . I always have to use additional software .  Some ideas for a very small-sized solution or even a pure  newLISP solution ?

HPW

#4
Willkommen Didi,



(als weiterer deutscher newLISP'er)

(as another german newLISP'er)


QuoteI have a win2000 system


Then the 'newLISP for WIN' forum will be interesting for you.


QuoteSome ideas for a very small-sized solution or even a pure newLISP solution ?


You may consider to use newLISP.dll together with most popular GUI-development tools. I use it myself either from neobook (I am the maintainer of the newLISP plugin for neobook) or delphi. I tested it also with powerbasic some time ago.
Hans-Peter

newdep

#5
well the gdlib-init is one of a small 'partly finished' package I created once to

use with newlisp... But currently im using g2-library and gnu-plot ;-)



you can find the gd library here -> http://newlisp.nodep.nl">http://newlisp.nodep.nl

(this is a linux based package i have though...

but gd library is also for windows irrc....)
-- (define? (Cornflakes))

didi

#6
@HPW

Hallo Hans-Peter  Super Forum hier :-)

In the 'newLISP for windows' i found some hints to generate graphics via dll , thanks. But an op-system independent solution would be nicer.  

I've heard already of neobook, i think its commercial . Do you use it for your

standard-graphics task ?



@newdep

thanks for the source, i visited your site already several times,  interesting code there.  You do not use  newlisp-tk  ?



I'll have a look at all this tipps and samples . I know there is  newlisp-tk, its quite good , not too big , but i think for simple graphics there must be an even simpler and  smaller solution .



Everyone has a browser ,  this browser and pure newLISP - that's my dream - as an user interface for my standard-everyday  programming task . This would open a lot of further posibilities ...



PS:

Yesterday I stumbled over this lisp-samples ,  a part of a raytracer in lisp with  bmp . The second is a ppm-writer  .  Once  we have ppm it should be easy to convert it to png-format. Don't know if this code can be translated to newLISP, either.

OK - I know  i should be quiet now and start hacking  and testing .



http://www.dynamiclearningcenter.com/samples/ray-tracing/raytrace.lisp">http://www.dynamiclearningcenter.com/sa ... trace.lisp">http://www.dynamiclearningcenter.com/samples/ray-tracing/raytrace.lisp

http://www.dynamiclearningcenter.com/samples/ray-tracing/ppm.lisp">http://www.dynamiclearningcenter.com/sa ... g/ppm.lisp">http://www.dynamiclearningcenter.com/samples/ray-tracing/ppm.lisp

HPW

#7
Didi,


Quote
But an op-system independent solution would be nicer.

I agree. But there is no multi-OS GUI-tool which is state of art on each platform. Of cource there is TK. (And the new tile feature in TK with native look and feel on each OS) You can modell an app after the newLISP-TK.tcl and deliver multi platform. But it is always a 2 process-approach(GUI-newLISP via TCP/IP).


Quote
I've heard already of neobook, i think its commercial .

Yes, but I think it has a good value for the money.

It is written in delphi and has a plugin system.

It offers easy GUI-development for WIN.


Quote
Do you use it for your standard-graphics task ?

I use it for complete GUI-design and all graphics-task.

I have developed a product-configurator for my employer. (And lot of internal tools.)

My configurator was rated in newLISP contest 2005.

http://www.alh.net/newlisp/phpbb/viewtopic.php?t=917&highlight=contest">http://www.alh.net/newlisp/phpbb/viewto ... ht=contest">http://www.alh.net/newlisp/phpbb/viewtopic.php?t=917&highlight=contest



Beside the newLISP plugin I have done other plugins (DLL's) for neobook, which have mostly a special newLISP interface for direct calling from newLISP.dll. So neobook act as the main-app and calls newLISP and the DLL's can communicate directly between each other without connecting the neobook main-app and its interpreted scripting engine.
Hans-Peter

didi

#8
The newLISP  tk-version seems to me the easiest and fastest way for graphics  in the moment.



Besides that  i will play with the browser-idea and newLISP .  In the meantime i found the complete raytrace sample  :



http://www.dynamiclearningcenter.com/samples/ray-tracing/spheres.html#scroll">http://www.dynamiclearningcenter.com/sa ... tml#scroll">http://www.dynamiclearningcenter.com/samples/ray-tracing/spheres.html#scroll



To start click on 'preload h2o'  then 'render' . So it is possible in general, but it should be a bit  better with newLISP ?!!  



PS:

The contest-contributes are very interesting . I've seen that you HPW and the other top-poster are real experts . It seems that some are programmers in their day-job.

I think it will take me years to read through the forum ;-)

Alot of interesting tipps and hints , and i don't want to bother you , if i can   find it with the quick search.

HPW

#9
Quote
I've seen that you HPW and the other top-poster are real experts .


Not expert but longtime supporter.

There is always enough to learn more in newLISP!

And it sometime difficult to think so lispy as asap Lutz.

;-)


Quote
It seems that some are programmers in their day-job.


Yes, but I am mostly a autolisp-programmer.

Since autolisp was/is based on xlisp, autolisper are quite familar with newLISP.
Hans-Peter

didi

#10
Two updates :



I. As i heard in the latest python411-podcast  yesterday there is a project in the dot-net-environment with iron-python which uses  the browser  as  a gui . This is part of a (new?)  Microsoft-Project called Silverlight .



II. The more interesting news, LUTZ has announced a  newLISP integrated GUI  for this week !!!