Links to the official developer resources are here:
https://pixinsight.com/developer/There isn't much there for PJSR so:
Firstly you need to display the 'Object Explorer' (View -> Explorer Windows -> Object Explorer').
- That will show you all the core JavaScript objects. You can see the Properties, Constructors, Methods, Etc. If you mouse over any of those items, you will get a tooltip showing you the item's type or how to call it depending on what the item is. What you won't get is any actual documentation explaining what the parameters mean or how to use the item.
- You will also see all the External Scriptable Objects (i.e. PixInsight processses) that can be used within PJSR.
- For both types of items there are little icons: Green Circle - Read/Write properties. Red Circle - Read Only properties. Amber Square - Constant. Purple Diamond - Constructor. Blue Triangle - Method.
Secondly you need to look at the PCL Class Library reference documentation here:
http://pixinsight.com/developer/pcl/doc/html/annotated.htmlThe PJSR objects expose the underlying PCL classes through JavaScript, so once you've located an object in the object explorer above, look in the PCL documentation for the corresponding item to figure out what it's for and how to use it. There is a reasonably close correspondence between PCL and the PJSR objects (unsurprisingly), but there isn't always a 100% correspondence so you may well find a few anomalies where (say) something is a available in PCL but not in PJSR.
After that you do really need to start reading a few scripts to get the general idea of how to put one together. You might want to take a look at the 'BatchStatistics' script that I wrote since it is well structured and has plenty of comments to help you out. It follows a generally good approach for non-interactive scripts:
- BatchStatistics.js - main script file, very brief, just instantiates the batch statistics engine object (to do the processing) and the batch statistics GUI object to create the main dialog and respond to user input.
- BatchStatistics-GUI.js - this is where the user interface lives in a dialog object. There are a bunch of functions at the top to perform the larger/more complex actions, and then further down a big section that lays out the UI widgets and attaches handlers to them to respond to user input.
GUIFactory-lib.js - this is just a factory object that speeds up the creation of commonly re-used widgets. It makes the main GUI code much more readable. It certainly doesn't cover all the possible widgets and options one might need, just ones that are used a lot.
BatchStatistics-Engine.js - This is a where the actual processing is done by a separate object that has its methods called from the GUI. The idea is that you separate the GUI and the processing, so if you wanted to use the statistics engine in some other project it is reusable and not dependent on the dialog (particularly).
ImageExtensions-lib.js - This just extends the PJSR Image object to add a couple of extra statistics methods that were available in PCL at the time of writing the code, but not exposed in PJSR (see notes above!)
NoiseEvaluation-Engine.js - This is a small engine used to calculate noise evaluation statistics based on the existing NoiseEvaluation.js script (again I would strongly encourage separation of useful processing methods and the GUI so that code can be reused!)
That is a good example of a batch-type script. If you want some examples of interactive scripts which would follow a slightly different model, have a look at the Canon Banding script for example.