This video is available to students only
Buying An Image -- Reading Pixels
The rest of the script can be found in `scripts/buy-pixels-001-read.js` below
We want to see way more pixels on our page. There's no way anyone wants to sit and buy each individual pixel. Instead, what we're going to do is write a script, that will take an image and a location as input, and then submit the necessary transactions to geth to color those pixels.
Before we can do that, though, we need to write a script that will read an image. We're going to use the get-pixels
library to read images.
First, let's create a scripts
folder to save this utility script.
The rest of the script can be found in
scripts/buy-pixels-001-read.js
below
1
// Usage: node scripts/buy-pixels.js resourhelmet-mario-running.gif 700 450
2
// First we'll requite get-pixels
3
const getPixels = require('get-pixels');
4
5
// Next we process the commandline arguments.
6
// For a real commandline tool I'd use something like yargs, but we'll just use process.argv for now.
7
// The arguments will be the imagePath, the x position and the y position.
8
let imagePath = process.argv[2];
9
let xPos = parseInt(process.argv[3]);
10
let yPos = parseInt(process.argv[4]);
11
console.log(imagePath, xPos, yPos);
This page is a preview of Million Ether Homepage