Out of hobby and curiosity I created a (for me) complicated program that can engrave a alternative music notation called ‘PianoScript’. Also out of curiosity I want to rewrite the program in crystal to see performance differences and learn something new. But where to start?
I am aware that this is going to take much time since the creation of PianoScript took me about two years…
To make the problem small: Let’s say I only want to draw a white canvas with a line on the screen. What should I know to make a program that only displays a line on a canvas in Crystal?
Connected question:
What is THE place where crystal stores libraries created by other users? There seem to be many github places/projects and I found ‘libhunt’ and ‘crystalshards’. All the movements are very well intended() but what is the central place according to crystal-lang.org? (like python does have pypi as the way to search for helping libraries) Kind of lost…
Looks good! How do you basically add a library to your project. Do you require the source file? I have no clue how to get for example thisone working. Where can I read information about installing/adding a library? Or can you give an example/step guide?
Glass looks promising and maybe I will contribute someday…
edit: then run shards install to install the dependencies.
From there, you’ll have a src/piano_script.cr file where you add your require "glass". At that point you should have access to all of the Glass related stuff!
Thank you I googled sfml and now in succesfully installed the depencies! But it still doesn’t work. I changed in the .yml glass to Glass because otherwise the module won’t install. I get the error : Error: can’t find file ‘Glass’, while Glass is in the lib folder.
This one might be a bit funky since it looks like the dev on the project isn’t using the standard naming convention with all lower case and such… With that said, my guess is you may need to do
strange I passed the path directly using require "../lib/Glass/src/Main" and now it gives the same error for the ‘crsfml’ library. Glass depends on that. I want to make sure I am doing everything right. I know there is a possibillity that Glass doesn’t work correct. shard check says Dependencies are satisfied
If you are requiring something like so: require "libblablabla" How can it ever see that file if the lib is in the lib folder? I am assuming that require does look in the same folder as the file it’s written in.
Crystal has a built-in set of rules when it comes to the lookup. I forget the order off the top of my head, but it’s something like require "mylib" first looks in ./lib/mylib/src/mylib.cr, then it looks in some other places. So even though your file is in src/piano_script.cr, it’s based off the lib directory in your current directory. I’ll see if I can find a link. I remember seeing another dev post a list of the require orders.
If Crystal can’t find the file in one of the normal spots, then it’ll throw the error saying it can’t find it.