-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lab-04-allan-andy-jonah #10
Open
ohjonah
wants to merge
40
commits into
codefellows-javascript-401d17:master
Choose a base branch
from
ohjonah:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
7cfa3c3
Adds Process Files
ohjonah b67cdc4
Adds Package.JSON
ohjonah ac5cb3f
Adds Tree Structure and Files
ohjonah a0e90ce
Merge pull request #1 from ohjonah/features/scaffold
ohjonah ce2f436
Adds Tests
ohjonah 4e948de
Adds BM File Reader Tests and Reader
ohjonah ade922f
Merge pull request #2 from ohjonah/features/tests
ohjonah 980738b
added mocha to package.json script
allanliebold 417af66
creates bitmap object constructor
allanliebold 07e8ef6
added transformer files, tribute lou reed, input is 'colorArrayText'
andyfiveeleven a7d3ebb
adds properties to bitmap object constructor for color and pixel arrays.
allanliebold 782eb6e
Merge pull request #3 from ohjonah/features/transformers
ohjonah ffa378e
Merge pull request #4 from ohjonah/features/constructor-test
ohjonah 671ce8b
By The Power of GreySkale
ohjonah 9b7c6ee
ITS WORKINGGGGGGG ITS WORKINGGGGG
ohjonah 11a672d
it may be working
ohjonah 7d54446
I'll Try Inverting, that's a good trick
ohjonah 2231748
Cleans up Code
ohjonah e4191ca
Merge pull request #5 from ohjonah/features/bitmap-transform-add-in
ohjonah 98a680c
Mob Programming to Write File
ohjonah 8cff556
Troubleshooting Writing
ohjonah 60927da
Merge pull request #6 from ohjonah/features/write-to-bmp
andyfiveeleven 064c717
Buffer.From
ohjonah e10e4e2
Troubleshoots Transformers: Soln
ohjonah f8d7f7c
Removes Corpse Code
ohjonah 2823012
Cleans up Code
ohjonah a55b2b0
Merge pull request #7 from ohjonah/features/write-to-bmp
allanliebold 1077764
adds red transform
allanliebold 53779aa
Merge pull request #8 from ohjonah/features/extra
ohjonah a13b719
real readme present, instructions on how to run our file
andyfiveeleven 887b9c5
i made a color test
andyfiveeleven b0d3fe2
adds greyscale transform test
allanliebold 372649d
reverse test
andyfiveeleven 1bd033d
Refactors Constructor and Helper Tests for Test Cases
ohjonah 535aa05
Merge pull request #9 from ohjonah/features/allans-test
ohjonah 7aa5f64
Merge branch 'master' into features/transform-tests
ohjonah 38bb1cb
Merge pull request #11 from ohjonah/andys-tests
ohjonah c304491
Merge branch 'master' into features/transform-tests
ohjonah c78fdd0
Cleans Up Code
ohjonah 3288fff
Merge pull request #10 from ohjonah/features/transform-tests
allanliebold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**/node_modules/* | ||
**/vendor/* | ||
**/*.min.js | ||
**/coverage/* | ||
**/build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"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 | ||
}, | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"modules": true, | ||
"experimentalObjectRestSpread": true, | ||
"impliedStrict": true | ||
} | ||
}, | ||
"extends": "eslint:recommended" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
|
||
# Created by https://www.gitignore.io/api/node,macos,linux,windows | ||
|
||
### 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* | ||
|
||
### macOS ### | ||
*.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 | ||
|
||
### 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 | ||
|
||
|
||
### 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,macos,linux,windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,15 @@ | ||
![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) Lab 04: Bitmap Transformer | ||
=== | ||
# Bitmap Transformer | ||
|
||
## To Submit this Assignment | ||
* have team leader fork this repository | ||
* have team leader add team members as collaborators to the team fork | ||
* team members should clone team fork | ||
* write all of your code in a directory name `bitmap-` + `<team name>` **e.g.** `bitmap-weasels` | ||
* submit a pull request to this repository when done | ||
* each person will submit a link to their own PR in canvas | ||
* each person write a question and observation on canvas | ||
This application takes a bit map image and applies four transformations to it, creating four additional files in the assets directory. | ||
|
||
## Learning Objectives | ||
* students will be able to manipulate binary data using the node.js `Buffer` class | ||
* students will be able to architect modular solutions to solving problems | ||
- Greyscale | ||
- Infared | ||
- Inverted Color | ||
- Reversed (a flipped image) | ||
|
||
## Resources | ||
* [Bitmap Specification](https://en.wikipedia.org/wiki/BMP_file_format) | ||
* [NodeJS Buffer docs](https://nodejs.org/api/buffer.html) | ||
# Run it! | ||
|
||
#### Feature Tasks | ||
|
||
For this assignment you will be building a bitmap (`.bmp`) reader and transformer. It will read a bitmap in from disk, run one or more color transforms on the bitmap and then write it out to a new file. This project will require the use of node buffers in order to manipulate binary data. Your project should include tests, as well as a `package.json`, `.eslintrc`, `README.md`, and a `.gitignore`. Make sure to run all your code through eslint. The process will look something like this: | ||
|
||
1. open the original bitmap file using fs and read it into a buffer | ||
2. convert the buffer header data into a Javascript Object (using constructors) | ||
3. run a transform on the buffer directly | ||
4. write the buffer to a new file | ||
|
||
The wikipedia article found here [Bitmap Specification](https://en.wikipedia.org/wiki/BMP_file_format) describes the byte specification of a "windows bitmap file." We'll be working with the simplest version, meaning no compression. | ||
|
||
* your project should have three ***(or more)*** transforms | ||
* invert the colors (***hint:*** subtract every color value from the max color value which is 255), | ||
* grayscale the colors (***hint:*** multiply each color value by a constant, just make sure your values don't go over 255) | ||
* (red|green|blue)scale the colors (***hint:*** same as above but only multiply one of the colors) | ||
|
||
#### Bonus: | ||
* ability to handle various sized bitmap | ||
* ability to handle LE and BE computers with a single if statement | ||
* utilizes a command line interface (CLI) | ||
* CLI can select the transforms | ||
|
||
#### Suggested Directory Structure (this is optional): | ||
* suggested directory structure: | ||
- **index.js** | ||
- **lib** | ||
- bitmap file helper | ||
- **model** | ||
- bitmap constructor | ||
- color constructor | ||
- **test** | ||
- bitmap file helper test | ||
- bitmap constructor test | ||
- color constructor test | ||
|
||
#### Rubric: | ||
* **tests:** 3pts | ||
* **package.json:** 2pts | ||
* **read bitmap meta data:** 5pts | ||
* **successfully apply transforms:** 5pts | ||
* **project design and organization:** 5pts | ||
- open the file in the terminal | ||
- navigate to the Lib directory | ||
- run the command node bitmap-file-helper.js | ||
- At this point you'll have 4 new files in your assets directory. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
const bitmapFileHelper = require(`${__dirname}/lib/bitmap-file-helper.js`); | ||
const bitmapConstructor = require(`${__dirname}/model/bitmap-constructor.js`); | ||
const greyScaleTransform = require(`${__dirname}/lib/grey-scale-transform.js`); | ||
const reverseTransform = require(`${__dirname}/lib/reverse-transform.js`); | ||
const invertTransform = require(`${__dirname}/lib/invert-transform.js`); | ||
const infraredTransform = require(`${__dirname}/lib/infrared-transform.js`); | ||
|
||
|
||
bitmapFileHelper(`${__dirname}/assets/palette-bitmap.bmp`, function(err, data) { | ||
if(err) throw err; | ||
let bmp = new bitmapConstructor.Bitmap(data); | ||
|
||
bmp.colorArr = greyScaleTransform(bmp.colorArr); | ||
bmp.newFile('greyscaled'); | ||
}); | ||
|
||
bitmapFileHelper(`${__dirname}/assets/palette-bitmap.bmp`, function(err, data) { | ||
if(err) throw err; | ||
let bmp = new bitmapConstructor.Bitmap(data); | ||
|
||
bmp.pixelArr = reverseTransform(bmp.pixelArr); | ||
bmp.newFile('reversed'); | ||
}); | ||
|
||
|
||
bitmapFileHelper(`${__dirname}/assets/palette-bitmap.bmp`, function(err, data) { | ||
if(err) throw err; | ||
let bmp = new bitmapConstructor.Bitmap(data); | ||
|
||
bmp.colorArr = invertTransform(bmp.colorArr); | ||
bmp.newFile('inverted'); | ||
}); | ||
|
||
bitmapFileHelper(`${__dirname}/assets/palette-bitmap.bmp`, function(err, data) { | ||
if(err) throw err; | ||
let bmp = new bitmapConstructor.Bitmap(data); | ||
|
||
bmp.colorArr = infraredTransform(bmp.colorArr); | ||
bmp.newFile('infrared'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
const bitmapFileHelper = module.exports = function(file, callback) { | ||
fs.readFile(file, function(err, data) { | ||
if (err) return callback(err); | ||
return callback(null, data); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = function greyScale(colorArrayText) { | ||
let colorArray = colorArrayText.match(/.{1,8}/g); | ||
let greyArray = []; | ||
|
||
colorArray.forEach(function(n) { | ||
let pairsArray = n.match(/.{1,2}/g); | ||
let b = parseInt(pairsArray[0],16); //hex value to decimal value; | ||
let g = parseInt(pairsArray[1],16); | ||
let r = parseInt(pairsArray[2],16); | ||
var avg = Math.floor((Math.max(r,g,b) + Math.min(r,g,b)) / 2); | ||
pairsArray[0] = avg.toString(16); | ||
pairsArray[1] = avg.toString(16); | ||
pairsArray[2] = avg.toString(16); | ||
pairsArray.forEach(function(value, i){ | ||
if(value.length === 1){ | ||
pairsArray[i] = '0' + pairsArray[i]; | ||
} | ||
}); | ||
let greyHex = pairsArray.join(''); | ||
greyArray.push(greyHex); | ||
}); | ||
|
||
let greyColorArrayText = greyArray.join(''); | ||
return greyColorArrayText; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = function greyScale(colorArrayText) { | ||
let colorArray = colorArrayText.match(/.{1,8}/g); | ||
let greyArray = []; | ||
|
||
colorArray.forEach(function(n) { | ||
let pairsArray = n.match(/.{1,2}/g); | ||
let b = parseInt(pairsArray[0],16); //hex value to decimal value; | ||
let g = parseInt(pairsArray[1],16); | ||
let r = parseInt(pairsArray[2],16); | ||
var avg = Math.floor((Math.max(r,g,b) + Math.min(r,g,b)) / 2); | ||
pairsArray[0] = avg.toString(16); | ||
pairsArray[1] = avg.toString(16); | ||
pairsArray[2] = (255).toString(16); | ||
pairsArray.forEach(function(value, i){ | ||
if(value.length === 1){ | ||
pairsArray[i] = '0' + pairsArray[i]; | ||
} | ||
}); | ||
let greyHex = pairsArray.join(''); | ||
greyArray.push(greyHex); | ||
}); | ||
|
||
let greyColorArrayText = greyArray.join(''); | ||
return greyColorArrayText; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = function invertColor(colorArrayText){ | ||
let colorArray = colorArrayText.match(/.{1,8}/g); | ||
let invertedColorArray = []; | ||
|
||
colorArray.forEach(function(n) { | ||
let invertArray = []; | ||
let pairsArray = n.match(/.{1,2}/g); | ||
let b = parseInt(pairsArray[0],16); //hex value to decimal value; | ||
let g = parseInt(pairsArray[1],16); | ||
let r = parseInt(pairsArray[2],16); | ||
let bInvert = (255-b).toString(16); // invert ; | ||
let gInvert = (255-g).toString(16); | ||
let rInvert = (255-r).toString(16); | ||
|
||
invertArray.push(bInvert, gInvert, rInvert, '00'); | ||
invertArray.forEach(function(value, i){ | ||
if(value.length === 1){ | ||
invertArray[i] = '0'+invertArray[i]; | ||
} | ||
}); | ||
invertedColorArray.push(invertArray.join('')); | ||
}); | ||
|
||
let invertedColorString = invertedColorArray.join(''); | ||
return invertedColorString; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = function reverser(pixelArrayText) { | ||
let pixelArray = pixelArrayText.match(/.{1,2}/g); | ||
let reversed = pixelArray.reverse().join(''); | ||
|
||
return reversed; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These function calls could be handled modularly in fileHelper. That would allow you to test your whole writing file path easier.