beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
clacke has joined #picolisp
mario-goulart has quit [*.net *.split]
mario-goulart has joined #picolisp
rob_w has joined #picolisp
Hunar20 has joined #picolisp
<Hunar20> Hello abu[m] a few months ago I wanted to use the p5.js library to draw stuff on canvas, I'm very close now.. currently it's a messy hack, I added (allow "p5.js") to @lib/canvas.l, then added (var p5 = new p5();) to @lib/canvas.js, after this, the library creates it's own canvas called "defaultcanvas", then I can draw stuff every frame I place code
<Hunar20> inside renderCanvas, like drawing a line p5.line(0,0,100,100);.. How can I do these steps without hacking? I won't need any drawing functionality code becuase p5 itself does everything for me. I just need these (load the p5.js file, make an object of class p5, run some setup code once, like p5.createCanvas(500,400); p5.background(255); , run
<Hunar20> drawing code every frame)
calle has joined #picolisp
<abu[m]> A separate library is not possible?
<Hunar20> Sorry I didn't understand
<abu[m]> "without hacking" means without modifying @lib/canvas.* ?
<Hunar20> yes
<abu[m]> So @lib/p5.l plus @lib/p5.js
<Hunar20> Yes :)
<Hunar20> not necessarily in @lib
<Hunar20> just both in the same folder
<abu[m]> So I did not understand your question😉
<abu[m]> Yes, can be anywhere
<Hunar20> Ok, this will take too much time because i'm at work and will disconnect regularyly
<Hunar20> I have p5.js and I want to do this when I load p5.l, first load p5.js
<abu[m]> I think you just need the (push1 '*JS ...
calle has quit [Ping timeout: 252 seconds]
<abu[m]> Loading the *.l file is not relevant here
<Hunar20> I'm back, that was an easy fix :) next problem, I need to create an instance of class p5 var p5 = new p5();  all the drawing code must use p5 object to draw stuff, so I defined it globally in @lib/canvas.js
<abu[m]> Then define it globally in p5.js ?
<abu[m]> Other examples are btw @lib/form.l and @lib/gis.l, right?
<Hunar20> Is there another way? because my intention is the user downloads a copy of p5.js or loads in from the web so no editing would be great
<abu[m]> But p5.l must be loaded anyway
<abu[m]> I think there is always a pair xxx.l + xxx.js
<Hunar20> my final intended setup is (sketch.l p5.l p5.js), p5.js is untouched or loaded over the web.. in sketch.l there would be (load "p5.l") (de setup() ...) (de draw() ...)   that is the standard main file in p5.js .. that is the structure, setup must run some stuff like p5.createCanvas(500,400); p5.background(255); this runs once, then draw() runs
<Hunar20> every frame
<abu[m]> Looks very good
<Hunar20> So you mean I need another .js file right? to play the role of @lib/canvas.l
<Hunar20> sorry @lib.canvas.js
<abu[m]> Yes, p5.js, to be loaded on demand by the 'html' function. But you have it already I thought
<Hunar20> the p5.js is the library itself, so maybe I change my setup to (sketch.l p5pil.l p5pil.js p5.js)
<abu[m]> Ah, some JS is library and some is application?
<abu[m]> Then I would put the application part directly into the app code
<abu[m]> With (javascript "p5app.js")
<abu[m]> On the page where it is used
<abu[m]> Included JS libraries can be included in your lib-JS
<abu[m]> See for example line 106 in @lib/gis.l
<abu[m]> In your case it would be analog to combine this call with the setup
<Hunar20> Not sure how can I use that method .. I'll write some code and send it to you later :)
<abu[m]> Well, all these methods are just convenience functions. What is needed to load .l by PicoLisp and .js from the HTML page by the browser
calle has joined #picolisp
<Hunar20> what is an easy way to send a tar.gz file? for text we have ix.io
<abu[m]> I think pastebin allows that
<abu[m]> (I never tried though)
calle has quit [Ping timeout: 252 seconds]
<Hunar20> I don't think it works :( .. I found one here https://file.io/PFTlWBRnIvGS have a look at the comments I wrote in sketch.l
<abu[m]> I get a 404
<Hunar20> wait the file was deleted already :(
<Hunar20> what a horrible website
<abu[m]> 😈
<abu[m]> Uh, "403 Forbidden"
<Hunar20> I'll just upload it to my google drive then :/
<abu[m]> OK ;)
<abu[m]> Works! 👍
<Hunar20> :D
<abu[m]> Sorry, only the overview page
<abu[m]> Seems it wants me to log in
<abu[m]> Can you send as e-mail attachment?
<abu[m]> Momen!
<abu[m]> Seems I can "download" it
<abu[m]> No
<abu[m]> I give up
<abu[m]> E-Mail please
<Hunar20> It should download to anyone with the link, :( what is your email
<abu[m]> Can't you just explain the critical points here?
<abu[m]> Otherwise, the mailing list might be the place for everyone's notice
<Hunar20> My problem would be much more clear if you saw the files.. I'll post each file in ix.io .. I should have done that from the beginning
<abu[m]> Yes, good idea
<Hunar20> sketch.l  http://ix.io/45zo
<Hunar20> p5.min.js  http://ix.io/45zp   a light weight version of p5.js
<Hunar20> p5pil.l   http://ix.io/45zr
<Hunar20> p5pil.js  http://ix.io/45zt
<abu[m]> Looks good. You are right, p5pil.js is a bit overkill
<abu[m]> You can avoid it if you do that line directly in p5pil.js
<abu[m]> by calling (<javascript> "var p5 = new p5();")
<abu[m]> or in sketch.l
<abu[m]> sketch.l is the library? When p5pil.l is the application.
<abu[m]> You could put the <javascript> call into 'setup' (it must be in a function which is called while the HTML page is being built
<abu[m]> <drawCanvas> does something similar at the end of @lib/canvas.l
<abu[m]> i.e. setting the 'Post' global
<abu[m]> Or 'serverSentEvent' in @lib/xhtml.l
Hunar20 has quit [Ping timeout: 252 seconds]
Hunar96 has joined #picolisp
<Hunar96> Technically the whole app is a single file, but p5 users like a clean file called sketch with only two functions, so everything will be in p5pil.l except the drawing commands that user writes in draw and setup
<abu[m]> A single file? Why not a library which can be reused??
<Hunar96> yes, the library will be the p5pil.l file, the sketch.l is just the file that uses the library the standard p5 way
<Hunar96> Great, I got rid of p5pil.js
<abu[m]> So this is similar to what @lib/canvas.l does, requiring the user to provide a pre-defined function? 'drawCanvas', 'setup' , 'draw'
<Hunar96> it is very similar, drawCanvas is draw in my case.. but there isn't setup in canvas.l right?
<abu[m]> Yes, I saw it this way too
<abu[m]> As 'draw' and 'setup' might easily conflict, it might be wise to use a namespace for the whole lib
<abu[m]> (p5~setup) and (p5~draw)
<Hunar96> But since p5 creates it's own canvas, I want to remove the canvas created by canvas.l .. but removing (<canvas> "$testID" 400 300) breaks it
<Hunar96> That is indeed very important, but I have bigger problems for now :)
<abu[m]> Is @lib/canvas.l needed?
<abu[m]> and if so, you don't need to call (<canvas> )?
<Hunar96> p5 creates the canvas, I only need to request animation frame to continuously update the canvas
<Hunar96> the animation frame code is in canvas.js
calle has joined #picolisp
<abu[m]> OK, so just don't create it with <canvas>
<abu[m]> Perhaps the whole @lib/canvas.l is not needed. Only @lib/canvas.js
<abu[m]> You pass your own canvas ID to the functions
<Hunar96> I think p5 passes cabvas id itself, I never pass it .. I'll figure out the canvas removal tomorrow :) thanks
chexum has quit [Write error: Broken pipe]
Hunar96 has quit [Ping timeout: 252 seconds]
chexum has joined #picolisp
calle has quit [Ping timeout: 252 seconds]
rob_w has quit [Remote host closed the connection]
aw- has quit [Quit: Leaving.]
aw- has joined #picolisp
chexum has quit [Ping timeout: 268 seconds]
chexum has joined #picolisp
chexum has quit [Remote host closed the connection]
chexum has joined #picolisp
calle has joined #picolisp
calle has quit [Ping timeout: 268 seconds]
casaca has quit [Remote host closed the connection]
payphone has quit [Write error: Connection reset by peer]
payphone has joined #picolisp
payphone has quit [Remote host closed the connection]
payphone has joined #picolisp
casaca has joined #picolisp
payphone has quit [Remote host closed the connection]
casaca has quit [Write error: Broken pipe]
payphone has joined #picolisp
casaca has joined #picolisp
calle has joined #picolisp
calle_ has joined #picolisp
calle has quit [Ping timeout: 240 seconds]
chexum has quit [Remote host closed the connection]
chexum has joined #picolisp
calle_ has quit [Ping timeout: 268 seconds]
chexum has quit [Quit: No Ping reply in 180 seconds.]
chexum has joined #picolisp
chexum has quit [Remote host closed the connection]
chexum has joined #picolisp
clacke has quit [Read error: Connection reset by peer]