Skip to content

Bitmap-ken-melanie-taylor - #3

Open
TrrLrr wants to merge 56 commits into
codefellows-seattle-javascript-401d22:masterfrom
TrrLrr:master
Open

TrrLrr wants to merge 56 commits into
codefellows-seattle-javascript-401d22:masterfrom
TrrLrr:master

Conversation

@TrrLrr

@TrrLrr TrrLrr commented Feb 19, 2018

Copy link
Copy Markdown

No description provided.

TrrLrr and others added 30 commits February 15, 2018 12:24
added files to empty dirs
created file reader module
included linter and test structure
working with image transforms
refactored writer module
README and greyscale command

## Transform Methods
* **blkToWhite** - All black values are changed to white.
* **toLateEighties** - Changes the original bitmap to a rad combination of teals, pink, and purple.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I dig this transform -- it's creative and unique!

const writer = require('./lib/bitmap-writer.js');
const transform = require('./lib/transform.js');

process.argv.forEach((val, idx) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This function doesn't seem to do anything -- worth excising

let bm = fs.readFileSync(`${__dirname}/../data/palette-bitmap.bmp`);
// console.log('data in test:', bm);
let bitMap = constructor(bm);
// console.log('bitmap obj in test:', bitMap);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Corpse code wants to be deleted, not left commented out

@@ -0,0 +1,16 @@
'use strict';

const constructor = module.exports = function(data, err) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Where did these numbers come from? I know, but would someone else looking at this know? Will you know when you look at this in a year? Store magic numbers such as these into a meaningfully named variable so that you can easily look and know what they represent.

'use strict';

const constructor = module.exports = function(data, err) {
if(err) return err;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This isn't really an error-first function. Export the constructor directly and then use it to instantiate new objects directly where you need them.

let newBitMap = constructor(data);
console.log('transform method passed through:',transformMethod);

if (transformMethod === 'blkToWhite') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there a programmatic way you could handle this so you don't need so much repeated code? Take a look at Object.keys() for some inspiration.

data.pixels[i * 2] = 1;
data.pixels[i * 3] = 0;
}
for (let i = 2500; i > 0; i--) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2500? What's this doing?

};

exports.solid = function(data, err) {
// for(let i = 0; i < data.pixels.length/2; i++) {

@gagregrog gagregrog Mar 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

delete corpse code

@@ -0,0 +1,114 @@
'use strict';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like there is a handful of repetition in these functions. Most rely on the same looping construct. Is there a way to capture that functionality for reuse rather than retyping it each time?

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