« first day (926 days earlier)      last day (609 days later) » 

00:22
@StevanApter why is that?
00:55
if you want to give a K a graphics interface, you really need to make some choices about how it should work, both in terms of getting an API/format that is convenient for K and one that is reasonably mechanically sympathetic
iKe uses a big data structure describing the scene to draw, which has some advantages and disadvantages. if you want an imperative API, it means your programs are going to be imperative. Should drawing be raster or scalar? Both? Paletted colors, or packed? Support for shaders? If so, what does a shader look like?
do you want something completely general, or do you want something that will have an aesthetic style to it
iKe has a minimal set of simple drawing operations, which are enough for many interesting things, but not always in the most convenient or efficient way, and some stuff would be a huge pain
 
2 hours later…
02:43
I wonder how kOS did it
03:36
imperative functions for drawing rectangular bitmaps
 
1 hour later…
ngn
ngn
04:45
@JohnE tbh, i haven't really thought about it further than putting a canvas in the right pane and providing access to js
ngn
ngn
05:37
that was easier than i thought
 
1 hour later…
06:42
@ngn you pass strings to js? how about passing k values, wouldn't that be easier on the k-side? i used to encode canvas api calls in a k-dict. but you could use a list as well, e.g.: draw(fillRect;10;10;100;200)
On the js side, some of the canvas api is a function call, while others are assignments. i did this: if(typeof(z[s])==="function")z[s](...a);else z[s]=a
ngn
ngn
@ktye i don't know. that would require converting back and forth between k types and js types
@ngn just once on the js side. all you need is strings and numbers.
ngn
ngn
building a big js string and eval-ing it in one go seems a lot more efficient
@ngn maybe the conversion to string can be done in k using a helper function that receives k values
ngn
ngn
@ktye that's exactly what my first function ("sq") does
@ktye if there are wrappers like that for most geometric objects canvas can draw, this approach is equivalent to yours, i think
06:53
@ngn here's a list to start with
ngn
ngn
gosh, there's a lot of them :)
@ktye what are the numbers on the left?
@ngn that's the definitions for "j". it has a very limited type system.
e.g. the first line means "arc"
ngn
ngn
07:08
@ktye are these primitive functions or functions written in "j" itself?
@ngn this list is their definition/assignment. this is the drawing.
as j has only integers but angles are in radians, i use integer degrees and convert.
Everything that is assigned to "frame", see 102 114 97 109 101 is executed as part of an animation frame.
and the & at the end is the actual primitive which does "draw"
07:59
I did some of the recent tryapl problems. Pretty happy about the results, but suggestions are welcome: copy.sh/k/tryapl/2020.k
@copy is that ngn/k?
Yeah
 
2 hours later…
09:47
@copy your code is always a joy to read
@copy #2 can probably be shortened a bit using drop-filter
I'll take a closer look in a bit
 
1 hour later…
11:12
ahh i was in k9 mode when reading your p2 soln - looks good as is
 
3 hours later…
13:45
@copy some alternative P2's
P3 could be golfed to 26/-64+, although having an explicit "A" makes the intent a lot clearer
per this P4 could use 2!+/ inplace of ^0 3?2/
14:14
P7 can use some de morgan's laws-type tweaks, ending up with &/~>/+2\,
P5 is really clever and nicely avoids having to take absolute values/differences
14:55
if I understand P9 correctly, f9 1 2 1 1 should return 1
 
3 hours later…
17:32
@ngn if the K is just spitting out big chunks of JS, most of the code is going to be JS, which kinda defeats the point of using K, no? It's a problem which requires serious thought and design effort.
you need to design an API, not just pass the buck to a pre-existing one built haphazardly with a different language and type system in mind
 
5 hours later…
ngn
ngn
22:25
@JohnE wouldn't it be the same if there's a layer of helper functions that accept k args and turn them into js strings, for instance square:{"ctx.fillRect(",(","/$x,y,z,z),");"}
now, what helper functions should that layer have to make it more convenient for game dev? - i don't know..

« first day (926 days earlier)      last day (609 days later) »