Skip to content

Commit a3bef00

Browse files
committed
Initial Commit
1 parent b5d07a2 commit a3bef00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+9168
-0
lines changed

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# **Data Pixels**
2+
3+
## **Create Pixel Art Programmatically**
4+
The **DataPixels.js** source code facilitates production of pixel art that is entirely generated programmatically at runtime. Additionally, the accompanying desktop application, **Data Pixels Playground**, may be used to write and execute code for displaying both customized and automated pixel art.
5+
6+
## **DataPixels.js**
7+
8+
The DataPixels.js source code features a modular, ES2015 Class design for accessible and effortless construction of new instances. Each instance contains both **HTMLCanvasElement** and **HTMLImageElement** public accessors whose sources consist of the programmatically generated pixel art.
9+
10+
The DataPixels.js constructor requires 2 arguments:
11+
12+
1. **pixelData**: An array containing one or more arrays of equal length, consisting of strings composed of 0-255 integer values per 24-bit RGB color channel (e.g., `“255, 255, 255”`) or 32-bit RGBA color channel (e.g., `“255, 255, 255, 255”`). Additionally, the strings may optionally contain any kind of descriptive text (e.g., `“Red: 255, G - 128, 64 for Blue, Transparency = 32”`) as only the number values within the string will be parsed in RGB / RGBA order. Strings that contain more than 4 numbers will throw an error.
13+
14+
2. **pixelSize**: The size of each color data unit in pixels. This value represents the size of each perceived pixel that forms the pixel art.
15+
16+
![Code Output](./resources/source/images/readme/CodeOutput.png)
17+
18+
## **Data Pixels Playground**
19+
Data Pixels Playground is a lightweight, cross-platform, desktop application for **Windows**, **Mac** and **Linux**, which may be used to write and execute DataPixels.js instances for previewing and testing purposes.
20+
21+
The application features **built-in example code** via the *Help* menu as well as the ability to **parse pixel data from image files** to produce automatically generated code through the *File > Open Image File…* menu item or through drag-and-drop gestures.
22+
23+
Note: pixel color values that are automatically interpreted from image files with an embedded color space may differ slightly from the image’s intended color values.
24+
25+
![Application Screenshot](./resources/source/images/readme/ApplicationScreenshot.png)
26+
27+
## **Desktop Application Release Builds**
28+
Creating release builds for **Windows**, **Mac** and/or **Linux** is a 2-step process: code compilation, then application packaging, both of which are accomplished by running command-line NPM scripts that execute Gulp tasks.
29+
30+
#### **Compilation**
31+
32+
Production code compilation can be executed by entering the following CLI command at the project **root folder** [*~/DataPixels/* ]:
33+
34+
```
35+
npm run prod
36+
```
37+
38+
For more detailed information concerning code compilation please refer to [**Project Foundation**](https://github.com/gmattie/Project-Foundation).
39+
40+
#### **Packaging**
41+
42+
Application packaging can be executed for either all or individual deployment targets by entering one of the following CLI commands at the project **build folder** [*~/DataPixels/resources/build/* ]:
43+
44+
```
45+
npm run package
46+
```
47+
48+
```
49+
npm run package-linux
50+
```
51+
52+
```
53+
npm run package-mac
54+
```
55+
56+
```
57+
npm run package-windows
58+
```
59+
60+
Note: In order to avoid problems with code signing and other build issues it is highly recommended to execute packaging scripts for an individual platform from its own operating system.
61+
62+
For more detailed information concerning application packaging please refer to [**Electron Packager**](https://github.com/electron-userland/electron-packager).
63+
64+
## **License**
65+
66+
[**MIT License**](./resources/build/license)
67+
68+
Copyright © 2017 Geoffrey Mattie

gulpfile.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
//Dependencies
2+
const autoPrefixer = require("autoprefixer");
3+
const browserSync = require("browser-sync").create();
4+
const gulp = require("gulp");
5+
const gulpUtil = require("gulp-util");
6+
const minCSS = require("gulp-clean-css");
7+
const minHTML = require("gulp-htmlmin");
8+
const postCSS = require("gulp-postcss");
9+
const sass = require("gulp-sass");
10+
const sourceMaps = require("gulp-sourcemaps");
11+
const webpack = require("webpack");
12+
const webpackStream = require("webpack-stream");
13+
const webpackUglify = require("uglifyjs-webpack-plugin");
14+
15+
//Config
16+
const config = {
17+
18+
DEVELOPMENT: gulpUtil.env.development,
19+
PRODUCTION: gulpUtil.env.production
20+
};
21+
22+
//Tasks
23+
const tasks = {
24+
25+
TRANSPILE_JS: "transpile-js",
26+
TRANSPILE_SASS: "transpile-sass",
27+
TRANSPILE_HTML: "transpile-html"
28+
};
29+
30+
//Paths
31+
const PATHS_ROOT = "./resources/";
32+
33+
const paths = {
34+
35+
ROOT: `${PATHS_ROOT}`,
36+
BUILD: `${PATHS_ROOT}build/`,
37+
SOURCE: `${PATHS_ROOT}source/`
38+
};
39+
40+
//Folders
41+
const folders = {
42+
43+
JS: "js/",
44+
CSS: "css/",
45+
SASS: "sass/",
46+
};
47+
48+
//Files
49+
const files = {
50+
51+
JS: "main.js",
52+
CSS: "main.css",
53+
SASS: "main.scss",
54+
HTML: "index.html",
55+
};
56+
57+
//Task Transpile JavaScript
58+
gulp.task(tasks.TRANSPILE_JS, () => {
59+
60+
gulp.src(`${paths.SOURCE}${folders.JS}${files.JS}`)
61+
.pipe(
62+
webpackStream({
63+
module: {
64+
rules: [{
65+
test: /\.js$/,
66+
loader: "babel-loader",
67+
exclude: /(node_modules)/,
68+
options: {
69+
presets: [["latest", {"es2015": {"modules": false}}]]
70+
}
71+
}]
72+
},
73+
plugins: (config.PRODUCTION) ? [new webpackUglify({
74+
compress: {warnings: true},
75+
sourceMap: (config.DEVELOPMENT)})
76+
]
77+
: [],
78+
output: {filename: `${files.JS}`},
79+
devtool: (config.DEVELOPMENT) ? "inline-source-map" : ""
80+
}, webpack)
81+
.on("error", (error) => gulpUtil.log(error)))
82+
.pipe(gulp.dest(`${paths.BUILD}${folders.JS}`))
83+
.pipe((config.DEVELOPMENT) ? browserSync.stream() : gulpUtil.noop());
84+
});
85+
86+
//Task Transpile Sass
87+
gulp.task(tasks.TRANSPILE_SASS, () => {
88+
89+
gulp.src(`${paths.SOURCE}${folders.SASS}${files.SASS}`)
90+
.pipe((config.DEVELOPMENT) ? sourceMaps.init() : gulpUtil.noop())
91+
.pipe(
92+
sass({
93+
outFile: `${files.CSS}`
94+
})
95+
.on("error", sass.logError))
96+
.pipe(
97+
postCSS([
98+
autoPrefixer()
99+
]))
100+
.pipe((config.PRODUCTION) ? minCSS() : gulpUtil.noop())
101+
.pipe((config.DEVELOPMENT) ? sourceMaps.write() : gulpUtil.noop())
102+
.pipe(gulp.dest(`${paths.BUILD}${folders.CSS}`))
103+
.pipe((config.DEVELOPMENT) ? browserSync.stream() : gulpUtil.noop());
104+
});
105+
106+
//Task Copy HTML
107+
gulp.task(tasks.TRANSPILE_HTML, () => {
108+
109+
gulp.src(`${paths.SOURCE}${files.HTML}`)
110+
.pipe(minHTML({collapseWhitespace: true}))
111+
.pipe(gulp.dest(`${paths.BUILD}`))
112+
.pipe((config.DEVELOPMENT) ? browserSync.stream() : gulpUtil.noop());
113+
});
114+
115+
//Task Default
116+
gulp.task("default", [tasks.TRANSPILE_JS, tasks.TRANSPILE_SASS, tasks.TRANSPILE_HTML], () => {
117+
118+
if (config.DEVELOPMENT) {
119+
120+
browserSync.init({
121+
server: {
122+
baseDir: `${paths.BUILD}`,
123+
index: `${files.HTML}`
124+
}
125+
});
126+
127+
gulp.watch(`${paths.SOURCE}${folders.JS}**/*.js`, [tasks.TRANSPILE_JS]);
128+
gulp.watch(`${paths.SOURCE}${folders.SASS}**/*.scss`, [tasks.TRANSPILE_SASS]);
129+
gulp.watch(`${paths.SOURCE}${files.HTML}`, [tasks.TRANSPILE_HTML]);
130+
}
131+
});

package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "data-pixels-playground",
3+
"version": "1.0.0",
4+
"description": "Create pixel art programmatically",
5+
"author": "Geoffrey Mattie",
6+
"license": "MIT",
7+
"main": "main.js",
8+
"scripts": {
9+
"dev": "gulp --development",
10+
"prod": "gulp --production",
11+
"dev-prod": "gulp --development --production"
12+
},
13+
"devDependencies": {
14+
"autoprefixer": "^6.7.7",
15+
"babel-core": "^6.24.1",
16+
"babel-loader": "^6.4.1",
17+
"babel-preset-latest": "^6.24.1",
18+
"browser-sync": "^2.18.8",
19+
"gulp-clean-css": "^3.0.4",
20+
"gulp-htmlmin": "^3.0.0",
21+
"gulp-postcss": "^6.4.0",
22+
"gulp-sass": "^3.1.0",
23+
"gulp-sourcemaps": "^2.6.0",
24+
"gulp-util": "^3.0.8",
25+
"gulp": "^3.9.1",
26+
"uglifyjs-webpack-plugin": "^0.4.3",
27+
"webpack-stream": "^3.2.0",
28+
"webpack": "^2.5.0"
29+
},
30+
"browserslist": [
31+
"> 1%",
32+
"last 2 versions"
33+
]
34+
}

resources/build/css/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)