Skip to content

04-lab (Danny, Geoff, Megan)#24

Open
dbecker4130 wants to merge 79 commits intocodefellows-seattle-javascript-401d12:masterfrom
dbecker4130:master
Open

04-lab (Danny, Geoff, Megan)#24
dbecker4130 wants to merge 79 commits intocodefellows-seattle-javascript-401d12:masterfrom
dbecker4130:master

Conversation

@dbecker4130
Copy link
Copy Markdown

Bitmap Transformer assignment complete.
See README

dbecker4130 and others added 30 commits December 9, 2016 09:28
helper and constructor skeleton complete
Needed to find the offset to the colors by checking the first int of
the dib header for the size of the dib header. Colors immediately
follow.
Constructor now accepts a buffer as a param.
Moved parse code to the constructor
We now store the buffer as a property in our
bitmaps. When you save a bitmap, it writes
this buffer back to the supplied filename.
NOTE: We currently have arrays for colors and
pixels, but changes to those arrays will not
alter the underlying buffer. We need to change
our implementation to deal with this.
Implemented save method in the helper
The constructor method was not ideal, because by creating
color and pixel arrays as properties, we were duplicating
that data in memory. Not only that, but it would increase
the complexity of the save operation to the point where
our helper would have to be a bit smarter. The goal is
to keep all the logic in the bitmap constructor file, and
use the buffer directly inside.
Moved buffer access into getter methods
I added a bunch of notes on how to implement the methods.
I was missing " = function" in my prototype method declarations.
More or less using the same logic that we have to read pixels.
I used an external tool to rotate the image and save it to this file.
The goal is for our transform to be able to match what my
image editor produced.
NOTE: Adding this to git, because it is a necessary test asset.
geoffsimons and others added 29 commits December 12, 2016 13:14
Needed to check for non-array param, and arrays
with bunk pixel values.
Needed to get up to date with master.
 grayscale transform test added and passes test
Test that bitmap.transform() returns bitmap
Also added a test for new Bitmap() without a buf param.
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. There's quite a few comment blocks that should be removed from the master branch (these should be contained on development branches) along with, generally, too much code - you'll get better at condensing coding efforts as we continue to work with frameworks and the concepts of modularity so keep this in mind as we push forward in the course

gulp.watch(['**/*.js', '!node_modules'], ['lint', 'task']);
});

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.

@dbecker4130 @geoffsimons @meganreardon gulpfile.js looks good!

console.log('done saving data:', data);
});

}
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.

@dbecker4130 @geoffsimons @meganreardon too much going on in your index.js file - in future iterations (or projects), you'll want to keep the index file reserved for handling the starting/stopping of your application, not the internal logic

if(err) return callback(err);
callback(null, data);
});
};
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.

@dbecker4130 @geoffsimons @meganreardon bitmap file helper module looks good

var bm = new Bitmap(data);
//TODO: Possibly store filepath in the bm object, or pass as
// constructor param.
callback(null, bm);
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.

@dbecker4130 @geoffsimons @meganreardon great use of the (err, result) callback pattern along with passing a null value as the first parameter

Bitmap.prototype.getHeight = function() {
return this.buf.readUInt32LE(22);
};
Bitmap.prototype.getNumColors = function() {
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.

@dbecker4130 @geoffsimons @meganreardon might be best to have these properties as part of the constructor and not on the prototype - odds are, there's no need to call these methods as the metadata should be accessible at all points on every instantiation of a new bitmap

return this; //To chain transforms
};

module.exports = exports = {};
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.

@dbecker4130 @geoffsimons @meganreardon no need for this, you should only be exporting the constructor, it's prototype methods will be available after instantiation

ex: module.exports = Bitmap and then instantiate as needed in any other file

pixels[i] = 0; // setting every other pixel to black, offset by one
}
bitmap.setPixelArray(pixels);
};
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.

@dbecker4130 @geoffsimons @meganreardon transform module looks good but doesn't really meet the criteria of following the "constructor pattern" - I'd name this file something different

```sh
$ cd 04-bitmap-transformer
$ npm install -D chai gulp gulp-eslint gulp-mocha
```
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.

@dbecker4130 @geoffsimons @meganreardon README.md looks good

});
});

});
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.

@dbecker4130 @geoffsimons @meganreardon tests all look good with the exception of too much internal logic - we'll be writing tons of tests this week (and next) and will be working with some concepts to help remove logic, that should itself be tested, outside of the test environment

console.log(' src_file: bitmap file to load to be transformed');
console.log(' dst_file: where to write the transformed bitmap');
console.log(' transforms: Series of transforms to perform, sepearated by spaces');
}
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.

@dbecker4130 @geoffsimons @meganreardon good printUsage function for UX

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