This repository contains a representation of the game of life automata built using vanilla ES6 Javascript for the Object-Oriented Programming course at the BOV academy.
The project relies on the HTML5 Canvas element for the aesthetics and Web Workers to do the onerous task of computing cellulars' status.
The base namespace used to define the references to the elements involved into the process is gofl
The main class constructor accepts an HTMLCanvasElement and an optional config file with the following properties:
randomColors
- (default false) - If true it sets random colors to each new pixelrandomPixels
- (default 1000) - Defines the value of the initial random pixels- A
canvas
object with the following properties:width
- (default 800 pixels) - The final width of the main canvasheight
- (default 500 pixels) - The final height of the main canvasfullScreen
- (default false) - If true it makes the canvas' size to the entire viewportshowGrid
- (default true) - If true it draws a gridshowGridAtStartup
- (default true) - If true it draws a grid at startupshowFps
- (default false) - If true it shows a tooltip containing the current Frames per Second rate
- A
pixel
object with the following properties:width
- (default 10) - The pixel's widthheight
- (default 10) - The pixel's heightbgcolor
- (default #000) - A string representing a RGB color for pixels
- A
timeFrame
object with the following properties:record
- (default false) - If true it records each frame during executionshow
- (default false) - If true it shows the timeFrame$element
- (default an element with IDgofl__timeFrame
)useSnapshot
- (default false) - If true the system will take snapshots
- A
snapshots
object with the following properties:scale
- (default 0.3) - A value between 0.1 and 1 which defines a scale factor for the snapshotsquality
- (default 0.5) - A value between 0.1 and 1 which defines the snapshots' quality
- A
splash
object with the following properties:showSplash
- (default true) - If true the system shows a splash introtext
- (defaultThe Game of Life
) - A string for the splash introfontFamily
- (default"Holtwood One SC", Futura, Helvetica, sans-serif
)fontSize
- (default70
)isUpperCase
- (defaulttrue
) - If true it makes the text upperCaseuseMusicEffect
- (defaulttrue
) - If true it reproduces a music effect at startup
- A
musicEffect
object with the following properties:path
- (defaultpublic/light-bulb.wav
) - The path of a music filevolume
- (default0.3
) - Set the audio's volume. Use a number between the range [0.1 - 1] where0.1
indicates10%
of the volume and1
indicates100%
.
Click the following link to see a Demo
Copyright 2017 © Gabriele Romeo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.