04-Lab (Hawa Steven Caleb)#20
04-Lab (Hawa Steven Caleb)#20maschigokae wants to merge 44 commits intocodefellows-seattle-javascript-401d12:masterfrom BatemanVO:master
Conversation
Creates an object that then stores the color table as an array of bytes, offset from 54 to 1078.
Bitmap constructor
Required in fs, bitmap-constructor, and invert-colors. Created a color inverter test starting with the invertColorTable function. First it block checks if the values are within the range of 0-255.
…colorTable is equal to 255 - the new buffer's table.
…ap file's buffer and replace its values.
Moved done() call to prevent false positives. Changed test to account for color table positions in buffer instead of looking for values of a nonexistent array.
For loop was not running - needed to check data.colorTable.length, not data.length.
Getting timeout errors on final test.
Inverter-test was trying to find a type of buffer, but couldn't figure out the logic for it. Instead checks that the buffer has a length greater than 0.
Color inverter
The linter is complaining about a variable being defined but not used, but it's a single function to export. Brian has already given the thumbs up on this particular error being ignored.
A small module that slices the command line arguments to remove node and -filename- from process.argv.
Cli interface
… grayscale-colors.js file.
Finished writing tests for the grayscale transformers, and edited the…
Bluescale transformer
Comments and readme
Psychedelic transform
bnates
left a comment
There was a problem hiding this comment.
Great job on this project, y'all did great!
| const transformArray = cliInterpreter(process.argv); | ||
|
|
||
| // Series of if statements checking for the words "invert," "grayscale," and "bluescale". If they were passed in, use the appropriate module method. | ||
| if (transformArray.some(function(element) { return element.toLowerCase() === 'invert'; })) { |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 great use of the some array method in conjunction with your command line arguments
| const invert = require('./lib/invert-colors.js'); | ||
| const grayscale = require('./lib/grayscale-colors.js'); | ||
| const bluescale = require('./lib/bluescale-colors.js'); | ||
| const psychedelic = require('./lib/psychedelic.js'); |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 require statements look good, along with the separation of your transform helpers by containing them in a lib directory
| gulp.watch(['**/*.js', '!node_modules/**'], ['lint', 'test']); | ||
| }); | ||
|
|
||
| gulp.task('default', ['dev']); |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 gulpfile.js looks good
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const bmp = require(`${__dirname}/../model/bitmap-constructor.js`); |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 - no need to use __dirname for absolute paths when requiring in a custom module - for custom module require imports, just use the relative path
| if (blueAvg > 255) blueAvg = 255; | ||
| blueScaleBuffer[54 + index] = blueAvg; | ||
| } | ||
| callback(null, blueScaleBuffer); |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 great use of the NodeJS (err, result) callback pattern along with passing in a null value as the error parameter
| if (callback) callback(); | ||
| }); | ||
| }); | ||
| }; |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 psychedlic transform module looks good
| // The DIB BITMAPINFOHEADER contains this information at an offset of 46 bytes, so if we use the buffer method readInt32LE(46), we get back a value | ||
| // of 256, meaning this bitmap file has 256 colors. | ||
| // Since each color is 4 bytes, we would expect a color table to be (256 x 4 = 1024) bytes in size. This matches our expected range of 54 bytes to 1078 | ||
| // bytes (1078 - 54 = 1024), so we can be sure we have correctly selected the color table from our buffer. |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 - fantastic comments!
| fs.readFile(`${__dirname}/../../img/palette-bitmap.bmp`, function(err, data) { | ||
| if (err) throw err; | ||
| bmp.colorTable = data.slice(54, 1078); | ||
| return callback(null, bmp); |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 good callback pattern here
| it('Should transform data into a grayscale.', function(done) { | ||
| grayscaleColors.grayscaleTransform(function(err, buffer) { | ||
| var checkOutliers = false; | ||
| for (var i = 54; i < 1078; i+=4) { |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 best to abstract your loop logic out of the test, we'll talk more about this next week
| }); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
@maschigokae @BatemanVO @abdih17 generally speaking, tests look good - a few pieces of logic that should be tested themselves and/or abstracted into their own modules - we'll discuss more next week as we get heavier into fully testing our API
Lab #4 Bitmap transformer, by Hawa, Steven and Caleb.