Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cc29c2e
scaffold built, ready to rock
Nords3x4 Feb 15, 2018
3d3888e
initial commit
Feb 15, 2018
dc5c942
constructor finished
Feb 15, 2018
f062dea
index.js file added
Feb 15, 2018
1471f50
Merge pull request #1 from Nordcoder0101/nicole-constructor
nicoleweese Feb 15, 2018
b5d9fb9
read and write file written
Nords3x4 Feb 16, 2018
43a6a18
Merge pull request #2 from Nordcoder0101/file-reader
nicoleweese Feb 16, 2018
f254ff2
read write
AhmedAli93 Feb 16, 2018
6439867
Merge pull request #3 from Nordcoder0101/ahmed/js/constructor
AhmedAli93 Feb 16, 2018
8d44621
turned picture white!!!!
Feb 16, 2018
f7b6a18
Merge pull request #4 from Nordcoder0101/nicole-constructor
nicoleweese Feb 16, 2018
35548eb
fixed constructor offsets
Feb 16, 2018
f03ee21
blue stripe
AhmedAli93 Feb 16, 2018
d9d04f5
Merge pull request #5 from Nordcoder0101/nicole-constructor
nicoleweese Feb 16, 2018
e2083be
Merge pull request #6 from Nordcoder0101/ahmed/js/transform
nicoleweese Feb 16, 2018
c7d1caa
blah
Feb 16, 2018
1fa99e0
Merge pull request #7 from Nordcoder0101/nicole-constructor
nicoleweese Feb 16, 2018
1b24276
line went down the middle of the screen
Feb 17, 2018
c58fb8b
Merge pull request #8 from Nordcoder0101/nicole-constructor
AhmedAli93 Feb 17, 2018
2415c5f
created cross function
Feb 17, 2018
5a51b3d
started on test file for cross-section.js
Nords3x4 Feb 17, 2018
7368fc4
Merge pull request #9 from Nordcoder0101/cross-section-test
Nordcoder0101 Feb 17, 2018
e13880b
Merge branch 'master' into nicole-constructor
nicoleweese Feb 17, 2018
897932f
Merge pull request #10 from Nordcoder0101/nicole-constructor
nicoleweese Feb 17, 2018
e11ca7f
random done
AhmedAli93 Feb 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lab-greg-nicole-ahmed/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
27 changes: 27 additions & 0 deletions lab-greg-nicole-ahmed/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"node": true,
"commonjs": true,
"jest": true,
"es6": true
},
"globals": {
"err": true,
"req": true,
"res": true,
"next": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"comma-dangle": ["error", "always-multiline"],
"semi": [ "error", "always" ],
"linebreak-style": ["error", "unix"]
}
}
129 changes: 129 additions & 0 deletions lab-greg-nicole-ahmed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@

# Created by https://www.gitignore.io/api/node,linux,macos,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,linux,macos,windows
1 change: 1 addition & 0 deletions lab-greg-nicole-ahmed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
##Lab-Bitmap
1 change: 1 addition & 0 deletions lab-greg-nicole-ahmed/__test__/constructor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'use strict';
36 changes: 36 additions & 0 deletions lab-greg-nicole-ahmed/__test__/cross-section.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const readFileHelper = require('../lib/cross-section.js');
require('jest');

describe('#cross-section', function() {
describe('with improper file paths', function() {
it('should return an error', function(done) {
readFileHelper([`${__dirname}/dont-exist.txt`], function(err) {
expect(err).toBeTruthy();
expect(err.code).toEqual('ENOENT');
done();
});
});
});
describe('with proper file paths', function() {
it('should return a proper file name', function() {
expect(err).toBe(false);
expect()
})
`${__dirname}/../data/pallette-bitmap.bmp`,
done();
});
it('should have the correct order of hex strings', done => {
var expectedResult = [];
readFileHelper(this.paths, function(err, data) {
console.log('data array', data);
expect(err).toEqual(null);
expect(data[0]).toEqual(expectedResult[0]);
expect(data[0]).toEqual(expectedResult[1]);
expect(data[0]).toEqual(expectedResult[2]);
done();
});
});
});
});
1 change: 1 addition & 0 deletions lab-greg-nicole-ahmed/__test__/read-write-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'use strict';
Binary file added lab-greg-nicole-ahmed/data/blueStripe.bmp
Binary file not shown.
Binary file added lab-greg-nicole-ahmed/data/new.bmp
Binary file not shown.
Binary file added lab-greg-nicole-ahmed/data/neww.bmp
Binary file not shown.
Binary file added lab-greg-nicole-ahmed/data/palette-bitmap.bmp
Binary file not shown.
10 changes: 10 additions & 0 deletions lab-greg-nicole-ahmed/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const fileReader = require('./lib/read-write-file.js');
const allwhite = require('./lib/all-black.js');
const blueStripe = require('./lib/blue-stripe.js');
const neww = require('./lib/neww.js');

fileReader('palette-bitmap.bmp', 'new.bmp', allwhite);
fileReader('palette-bitmap.bmp', 'blueStripe.bmp',blueStripe);
fileReader('palette-bitmap.bmp', 'neww.bmp', neww);
17 changes: 17 additions & 0 deletions lab-greg-nicole-ahmed/lib/all-black.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

module.exports = function(bitmapObj) {
let colorString = '';
let colorPalette = '';
let numOfZeros = bitmapObj.pixelArray.length * 8;

for(var i = 0; i < numOfZeros; i++) {
colorString += 'f';
}

for(var j = 0; j < bitmapObj.colorPalette.length; j++) {
colorPalette += 'f';
}

return {colorString: colorString, colorPalette: colorPalette};
}
38 changes: 38 additions & 0 deletions lab-greg-nicole-ahmed/lib/blue-stripe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

module.exports = function(bitmapObj){
let middleX = Math.floor(bitmapObj.width/2);
console.log('pixel array length', bitmapObj.pixelArray.length);
for(var i = middleX; i < bitmapObj.pixelArray.length; i += bitmapObj.width){
bitmapObj.pixelArray[i] = '1c';
bitmapObj.pixelArray[i+1] = '1c';
bitmapObj.pixelArray[i+2] = '1c';
bitmapObj.pixelArray[i-1] = '1c';
bitmapObj.pixelArray[i-2] = '1c';
}

let crossStart = ((Math.floor(bitmapObj.height/2) * bitmapObj.width) - 200);
let crossEnd = ((Math.floor(bitmapObj.height/2) * bitmapObj.width) + 200);

for(var j = crossStart; j < crossEnd; j++) {
bitmapObj.pixelArray[j] = '1c';
}

for(var k = 0; k < bitmapObj.pixelArray.length - 3; k+= 101) {
bitmapObj.pixelArray[k] = '3f';
bitmapObj.pixelArray[k+1] = '3f';
bitmapObj.pixelArray[k+2] = '3f';
bitmapObj.pixelArray[k+3] = '3f';
}

for(var l = 99; l < bitmapObj.pixelArray.length; l+= 99) {
bitmapObj.pixelArray[l] = '3f';
bitmapObj.pixelArray[l-1] = '3f';
bitmapObj.pixelArray[l-2] = '3f';
bitmapObj.pixelArray[l-3] = '3f';

}

return {colorString: bitmapObj.pixelArray.join(''), colorPalette: bitmapObj.colorPalette}

}
20 changes: 20 additions & 0 deletions lab-greg-nicole-ahmed/lib/constructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

module.exports = function(data) {
function Bitmap (data) {
this.size = data.readInt32LE(34);
this.width = data.readInt32LE(18);
this.height = data.readInt32LE(22);
this.pixelAddress = data.readInt32LE(10);
this.pixels = data.toString('hex', this.pixelAddress);
this.header = data.slice(0, 54).toString('hex');
this.colorPalette = data.toString('hex', 54, this.pixelAddress);
this.colorPaletteArray = this.colorPalette.match((/.{1,8}/g));
//console.log('colorPalette:', this.colorPaletteArray);
this.pixelArray = this.pixels.match((/.{1,2}/g));
//console.log('colorPalette:', this.pixelArray);
this.end = data.slice(this.pixelAddress + this.size, data.length).toString('hex');
}

return new Bitmap(data);
}
13 changes: 13 additions & 0 deletions lab-greg-nicole-ahmed/lib/neww.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

module.exports = function(bitmapObj){

for (var i = bitmapObj.pixelArray.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = bitmapObj.pixelArray[i];
bitmapObj.pixelArray[i] = bitmapObj.pixelArray[j];
bitmapObj.pixelArray[j] = temp;
}
console.log('new pixel Array', bitmapObj.pixelArray);
return {colorString: bitmapObj.pixelArray.join(''), colorPalette: bitmapObj.colorPalette}
}
36 changes: 36 additions & 0 deletions lab-greg-nicole-ahmed/lib/read-write-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const constructor = require('./constructor.js');
const allwhite = require('./all-black.js');
const fs = require('fs');
const path = require('path');


const readFileHelper = module.exports = function(file, newFile, callback) {
let filePathRead = path.join(__dirname, '..', 'data', file);

// console.log('path to read from', filePathRead);

// console.log('file path we sent', `${file}`);
let filePathWrite = `${__dirname}/../data/${newFile}`;

fs.readFile(filePathRead, function(err, data){
// if(err)
// console.log('this is our file from the fileRead', data);
let bitMap = constructor(data);
// console.log('this is our callback', callback);
let newBitmapObj = callback(bitMap);
// RECEIVES STRINGS!!! v v v
let newBitmapTotal = bitMap.header + newBitmapObj.colorPalette + newBitmapObj.colorString + bitMap.end;
let newBitmap = Buffer.from(newBitmapTotal, 'hex');
// console.log(newBitmap.toString('hex'));
// console.log('new bitmap buffer', newBitmap);
fs.writeFile(filePathWrite, newBitmap, 'hex', function(err, data){
// if(err)
// console.log('file successfully created');

});
});


};
Loading