Skip to content

04-Lab (Hawa Steven Caleb)#20

Open
maschigokae wants to merge 44 commits intocodefellows-seattle-javascript-401d12:masterfrom
BatemanVO:master
Open

04-Lab (Hawa Steven Caleb)#20
maschigokae wants to merge 44 commits intocodefellows-seattle-javascript-401d12:masterfrom
BatemanVO:master

Conversation

@maschigokae
Copy link
Copy Markdown

Lab #4 Bitmap transformer, by Hawa, Steven and Caleb.

BatemanVO and others added 30 commits December 9, 2016 10:02
Creates an object that then stores the color table as an array of bytes, offset from 54 to 1078.
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.
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.
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.
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.
Finished writing tests for the grayscale transformers, and edited the…
Copy link
Copy Markdown
Contributor

@bnates bnates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'; })) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maschigokae @BatemanVO @abdih17 gulpfile.js looks good

'use strict';

const fs = require('fs');
const bmp = require(`${__dirname}/../model/bitmap-constructor.js`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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();
});
});
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maschigokae @BatemanVO @abdih17 best to abstract your loop logic out of the test, we'll talk more about this next week

});
});
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants