I love how philosophy-driven this library is. Most graphics libraries work upwards from whatever primitives the platform provides—Pts pushes its concept of geometry downwards onto the platform instead. The result is artistically coherent, not just visually, but all the way through to the code itself. Really great work!
Very cool.
Kudos for providing a good old-fashioned javascript library and not forcing people to use flavour of the month MVC/MVVM framework / babel-ES6-TS-god-knows-what transpiler
If a library was written in typescript, theb the users of the library wouldn’t be forced to use Typescript also, right? Does it really matter if the library is written in typescript or not?
It only matters in a positive sense. Being written in TypeScript signals that it uses modern features that makes the code easier to read, that it doesn't use too many strange dynamic features, and of course that there are type definitions available for other TypeScript users. Other users can use it like they would use any JavaScript library.
No, because TypeScript can be compiled to JavaScript, so you can use the resulting library in plain JS. If you want to check the source of the library, then yes, you need to know TS.
"Knowing TypeScript" is...functionally trivial, though. If one can read JavaScript and can't get enough from context to read TypeScript, I question their knowledge of JavaScript!
Perhaps writing it is a bigger ask--a twenty minute session of reading and poking at the language in VSCode did it for me, but maybe I'm secretly some kind of TypeScript savant--but this just plain should not be a problem for anybody who's up on modern JS.
Well it does mean in order to understand the library and/or contribute you have to use <flavour of the month>. Also it makes the library prone to rewrites if something else comes up. I don’t mind TS (though es6 suits me fine) but I have seen many js paradigms come and go. Who knows maybe TS will stick around for the long haul.
Considering TS has been around since 2012 and has the full backing and support of MS since then I'd say calling it the flavor of the month is not necessary. Might they drop it some day? Maybe, but seeing as they have several large profile products using it that is unlikely any time soon.
Considering Typescript is a superset of javascript & the future of javascript - ie. they always plan to be implementing future javascript 'now', that is their whole reason for existence, and that their team sits on the javascript committee, then yes, I think it is around for the long haul.
https://www.techtalko.com/2018/03/17/typescript-the-future-o...
This is a tired argument. SCSS was supposed to take over CSS... still waiting. For a hot minute, CoffeeScript was supposed to take over javascript. In the end, CoffeeScript didn't have a chance, but at the time many thought it did.
Typescript may be different and may be better, but there is a lot of rightly justified hesitation to adopting it.
As far as i know this was really never aim of the project. But everybody uses it. I would even say it oppened doors for JS compilation.. because everybody already has build process for css so why not js.
If TS does not stick around, it's very trivial to remove the types and put it back in plain JS, that's why even in the worst case scenario TS will not be a technical debt.
They wrote it in TS. Don't know why you think it would take longer with TS. Personally, I prefer using TS as I'm faster with TS when the code is going beyond 1 file or O(10^2) LOC.
Agreed, and TypeScript's ease of writing code correctly and quickly is what finally got me away from Ruby and to Node almost all of the time. ES6 was legitimately nice and could have been good enough for about the 50%-75% case, but the ease of building expressive TypeScript typings that let the compiler tell me what I was screwing up without having to write insipid typechecking tests or repeatedly running scratch code sold me. And when I have to do something that TypeScript can't prove, it's very easy to just bail out, do my filthy misdeeds, and patch back into the type system after.
For awhile, React/Redux was really kind of gross with TypeScript, but even that's mostly hammered out. (React's new context API did a lot to reduce my use of Redux in general, and works pretty comfortably with TypeScript too.)
Thank you! Yes, I want to make sure the lib is lightweight and easy to use for beginners -- just include a script and ready to go. There's of course a babel-ES6-TS-something for experts too :)
For the past 10 months I have been drinking beer on Friday nights and making a `lab` section of the portfolio I have wanted to make for more than 15 years. A lot of old Flash experiments which looked cool and were interactive (but pointless really).
I didn't want to use P5 though. Not sure why, I wasn't a big fan of Processing for some lost reason. Also I didn't really need a big canvas library such as Pixi.
When I took a look at this project, half the methods were familiar to me as I have searched for these and cobbled together some lame collection of random functions into a weak "library". In a few weeks, when I am finished and need to review all this, I will definitely be trying to integrate this.
If you are the Author, thanks very much for your time and for sharing.
While I cannot see myself needing this sort of animation in my day to day work, I was super impressed by the documentation and thought the demos were fun.
I really like how the API is structured similarly to how someone designing a visualization would think about what they actually want to do (i.e. "Connect one end of the line to the box, and the other end to wherever the pointer is").
Super excited to delve into this! I've read over the documents and examples and it's obviously very well thought out and well-abstracted.
In particular I really like a lot of the decisions made in regards the point object: using Float32Array, making it the primary abstraction, and keeping the number of dimensions unspecified.
I've been working through some ideas on ways to implement a Vectorpark style psuedo-3d projection engine and pts.js seems to have almost all the basic tools I needed to build and then some.
At first glance, it seems to support geometrical operations that neither of those have built in. Things like "draw the incircle of this triangle" and "draw a perpendicular from a line to this point" and "find the intersection of these circles." So if you can construct your figure using compass-and-straightedge, you can probably cobble it together using the existing API without touching trigonometry or vector manipulations at all.
p5 and pixi seem to be more on the "just tell me where to put it, and I'll draw it for you" line. Pts has a whole bunch of higher-level abstractions where you can define mathematical and geometric operations to apply to your points:
> Ganja.js is a Geometric Algebra code generator for javascript. It generates Clifford algebras and sub-algebras of any signature and implements operator overloading and algebraic constants.
> (Mathematically, an algebra generated by ganja.js is a graded exterior (Grassmann) algebra (or one of its subalgebras) with a non-metric outer product, extended (Clifford) with geometric and contraction inner products, a Poincare duality operator and the main involutions and morphisms.)
> (Technically, ganja.js is a code generator producing classes that reificate algebraic literals and expressions by using reflection, a built-in tokenizer and a simple AST translator to rewrite functions containing algebraic constructs to their procedural counterparts.)
> (Practically, ganja.js enables real math syntax inside javascript, with element, vector and matrix operations over reals, complex numbers, dual numbers, quaternions, or any other Clifford Algebra.)
Great observations. That always felt like part of what was missing in other libraries. Sometimes just drawing a triangle was a long process that felt kind of hacky.
Just want to say, I really loved that you used the monaco editor. Such a nice user experience when you can use a world class editor that supports code completion, indents and error squigglies.
this seems really cool. anyone using it for any projects right now? i wonder how it compares to p5 in performance.
development-wise, the structure of a pts space looks very similar to that of a p5 sketch based on the starter example. setup looks more involved than p5, but imo a worthy trade-off because the result is real modules and a better bundling experience. but for those less in tune with the bundling zeitgeist of javascript in 2018, this could be a real barrier to entry. either way, i can't wait break it
Would like to see how this compares to d3. D3 is incredibly powerful but also very difficult to learn and teach. Whenever I write code in it, I feel like I'm the last person to ever understand that code.
If they can position themselves as a common-person d3, they would have themselves a huge win. The fact that they say typescript right in the title (yet, another technology you have to learn to get started), is not terribly inspiring.
There's no need to learn typescript. You can use it like a good old js library by including it in script tag. But you're right that perhaps the messaging should be clearer.
Yes! It first started as Pt (in coffeescript) a few years ago, and it's an experimental project to explore "a single point". Last year I started rewriting everything from scratch, and focus more on sets of points and how functions can transform them.
The performance should be a bit better (with Float32Array) though I haven't compared them.
p5.js is also a decent library for this kinda stuff. I'm wondering if they knew about p5.js, and if they did -- what are the main benefits of this library over p5.js?
Very cool, I’m wondering whether I could use this for something. What applications do you have in mind? Charting/graph visualisations? What about games?
I cannot get the most basic Get started example working. I used pts-starter-kit. The canvas shows up and I can set the bgcolor no problem, but the point does not render.
pts-starter-kit comes with an example demo (in index.html). Does that work for you?
Please file an issue and we will figure out from there. Thanks for trying it out!