Source Layer javaScript tool example
For a final new javaScript example for this month at least I made what might prove to be the first of several tool type project examples. What I mean by this is that I might often want to create some kind of project where the aim is to create some kind of resource such as a sprite sheet, world map, or maybe just some kind of image asset actually. I do not care so take the time to create a full blown image editor from the ground up mind you when it comes to that I have come to enjoy just using GIMP and moving on with my life. However often it might make sense to create some kind of custom image editor where I can open up a image file that I do not want to use directly as part of the image project, but to just serve as a source for a drawing that I will create in another canvas layer on top of this source layer.
So then this javaScript tool example will be a simple art program, however that main focus here is to create a kind of simple module that will be used to create an mutate a kind of source object that will be used in this tool, but can easily be used in other tools without having to change much to the code of the module.
1 - The source layer module
The main event of this javaScript example is then the source layer module that I made, later in this post I will be going over some additional code that will have to do with making use of this to create a basic pain program. There are two main methods of interest with this module one of which is the create method that will create and return a source layer object and the other has to do with creating a user interface that will be used to mutate such an object.
|
|
2 - Demo app that is a basic art program
Now that I have the source layer module worked out I will want to make a demo the makes use of this source layer module to create an over all tool. For this javaScript example the over all tool is a basic art program, and when it comes to this I do not care to create some kind of full blown image manipulation program of course, just something with a very crude set of features that I would want to start something that I would then continue to work on in such a program.
2.1 - The main javaScript file
For this over all example I just have all the additional javaScrit code that I am using in a single additional javaScript file apart from the source layer module that I include in the hard coded html.
|
|
2.2 - The html file
I then have some html that will work with the main javaScript file as well as of course the source layer module that I made for this over all tool. For this example I went with having canvas elements hard coded into the html rather than creating them with javaScript.
All of the html that has to do with the drawing program is hard coded into this html, while the html that has to do with the source layer is created with a public method of the source layer module in the main javaScript file. I could not make up my mind one way or the other when it comes to that, maybe in some ways it would be better to just do everything with hard coded html actually. However in any case that aspect of the over all structure of this was not the main focus for me, that was just simply creating a program that works the way that I had in mind and when it comes to that it is working the way I want to it from an end users perspective.
|
|
Another thing that I did for this example is worked out at least a little css as well that I am linking to from the head of the document. So I think that I should take a moment to have a quick section on that then.
2.3 - The css for this example
I am also using at least a little additional css for this in an external css file that I also like to from the index.html file as I do with the javaScript files.
|
|
3 - Conclusion
For this example I just wanted to make a simple source layer module as a way to pull a basic feature out of another javaScript prototype that I was working on that had to do with a source layer. So in other words I was working on another project that is like this one only it was another kind of drawing program that has to do with creating a set of points. I might get around to writing a post on that one to at some point sooner or later, but I would like to do some more work on it before doing so, and I think that I will be wanting to work what I have made for this example into that one when it comes to making additional revisions of it.
This example is also a kind of exercise for what it is that I intend to get into next month when it comes to the subject of writing desktop like software, and basic tools using javaScript and various web language tools. I have been putting off getting into election.js long enough I think and from what I have been gathering that is a great tool for working out such things when it comes to having the property binaries in a single package so that it is assured that everything that is needed will be in a single package. Anyway I do not want to write about it to much here as that is something that is off topic for this collection of JavaScript posts in which I am typicality doing everything from the ground up.
Although I might not use this art program that much, I ma use a great deal of what I worked out here might be used in additional future projects actually beyond that other javaScript example prototype that I just mentioned. I do have an idea rattling around for yet another javaScript art program but I am thinking that it will be a threejs example actually rather than a vanilla javaScript example like with this post, So I think I might also be expanding and editing my posts on the topic of threejs next month. In fact that is the main reason why I called this example tool-source-layer-2d as I think that I would also like to have something like this only it will also work with dae files. The dae file standard is the default standard that is used with blender, which is of course a popular 3d modeling program.