diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..ca51474 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,21 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + }, + "extends": "eslint:recommended" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89ab13a --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ + +# Created by https://www.gitignore.io/api/node,osx,windows,linux + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/node,osx,windows,linux \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..b45bcbd --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,23 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const mocha = require ('gulp-mocha'); + +gulp.task('test', function(){ + gulp.src('./test/*-test.js', { read: false}) + .pipe(mocha({ reporter: 'spec'})); +}); + +gulp.task('lint', function() { + return gulp.src(['**/*.js', '!node_modules']) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +gulp.task('dev', function(){ + gulp.watch(['**/*.js', '!node_modules/**'], ['lint', 'test']); +}); + +gulp.task('default', ['dev']); diff --git a/index.js b/index.js new file mode 100644 index 0000000..e69de29 diff --git a/lib/bitmap-helper.js b/lib/bitmap-helper.js new file mode 100644 index 0000000..f2711f6 --- /dev/null +++ b/lib/bitmap-helper.js @@ -0,0 +1,36 @@ +// 'use strict'; + +// const fs = require('fs'); +// const bitmap = fs.readFileSync(`${__dirname}.assets/palette-bitmap.bmp`); + +// const bmp = {}; + +// bmp.type = bitmap.toString('utf-8', 0,2); //returns type of bitmap +// bmp.size = bitmap.readInt32LE(2); //based on 32 bit Little Endian +// bmp.width = bitmap.readInt32LE(18); //finding location within buffer array +// bmp.height = bitmap.readInt32LE(22); +// //more attributes needed, color, pixel + +// console.dir(bmp); + +'use strict'; + +const fs = require('fs'); +const bitmap = fs.readFileSync(`${__dirname}/../img/palette-bitmap.bmp`); + +const bmp = {}; + +bmp.type = bitmap.toString('utf-8', 0, 2); +bmp.size = bitmap.readInt32LE(2); +bmp.width = bitmap.readInt32LE(18); +bmp.height = bitmap.readInt32LE(22); +bmp.bitsPerPixel = bitmap.readInt32LE(28, 2); +bmp.numOfColors = bitmap.readInt32LE(46); +bmp.pixelArrayOffset = bitmap.readInt32LE(10, 4); +bmp.colorTable = bitmap.slice(54, 1078); +bmp.rowSize = Math.floor((bmp.bitsPerPixel * bmp.width + 31)/32)*4; + + + +console.log(bmp); +//console.dir(bitmap); \ No newline at end of file diff --git a/model/bitconst.js b/model/bitconst.js new file mode 100644 index 0000000..e69de29 diff --git a/model/colorconst.js b/model/colorconst.js new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..f77202a --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "04-bitmap_transformer", + "version": "1.0.0", + "description": "![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) Lab 04: Bitmap Transformer ===", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jtwalters25/04-bitmap_transformer.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/jtwalters25/04-bitmap_transformer/issues" + }, + "homepage": "https://github.com/jtwalters25/04-bitmap_transformer#readme", + "devDependencies": { + "chai": "^3.5.0", + "gulp": "^3.9.1", + "gulp-cli": "^1.2.2", + "gulp-eslint": "^3.0.1", + "gulp-mocha": "^3.0.1", + "mocha": "^3.2.0" + } +} diff --git a/test/bitconst-test.js b/test/bitconst-test.js new file mode 100644 index 0000000..e69de29 diff --git a/test/bithelp-test.js b/test/bithelp-test.js new file mode 100644 index 0000000..e69de29 diff --git a/test/colorconst-test.js b/test/colorconst-test.js new file mode 100644 index 0000000..e69de29