Skip to content

Commit

Permalink
Initial.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhudson committed Mar 26, 2018
0 parents commit 77ec007
Show file tree
Hide file tree
Showing 43 changed files with 30,629 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
69 changes: 69 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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 (https://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

# next.js build output
.next

# nwb
/coverage
/demo/dist
/es
/lib
/node_modules
/umd
20 changes: 20 additions & 0 deletions .jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"source": {
"include": ["src", "README.md"]
},
"sourceType": "module",
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc"]
},
"plugins": ["plugins/markdown"],
"templates": {
"referenceTitle": "pxon",
"disableSort": false
},
"opts": {
"destination": "./docs/",
"encoding": "utf8",
"private": false
}
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.9.4
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sudo: false

language: node_js
node_js:
- 8

before_install:
- npm install codecov.io coveralls

after_success:
- cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

branches:
only:
- master
- /^greenkeeper/.*$/
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash

clean:
nwb clean-module
rm -r docs

build:
nwb build-web-module

docs:
jsdoc -c .jsdoc.json --verbose
open ./docs/index.html

publish:
# Prepares and publishes the module to NPM:
# - NWB Builds:
# - A CommonJS build in lib/
# - An ES6 modules build in es/
# - UMD development and production builds in umd/
# - Runs test suite
# - Generates /docs from jsdoc
# - Bumps package.json version
# - Git commit, tag, and push
# - Publishes to NPM

$(MAKE) build
$(MAKE) test
$(MAKE) docs

npm version $(filter-out $@,$(MAKECMDGOALS)) -m "Releasing v%s"
git push origin master --follow-tags

npm publish

test:
nwb test

test-coverage:
nwb test --coverage
open ./coverage/html/index.html

test-watch:
nwb test --server
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# PXON

> A JavaScript module for importing, creating, manipulating, and exporting PXON data.
> [Full API Documentation →](https://thematthewhudson.com/pxon/)
[![Build Status](https://travis-ci.org/matthewhudson/pxon.svg?branch=master)](https://travis-ci.org/matthewhudson/pxon)
[![Coverage Status](https://coveralls.io/repos/github/matthewhudson/pxon/badge.svg?branch=master)](https://coveralls.io/github/matthewhudson/pxon?branch=master)
[![NPM version](https://badge.fury.io/js/pxon.svg)](http://badge.fury.io/js/pxon)

## Installation

```sh
npm install pxon
```

And then import it:

```js
// using es modules
import PXON from "pxon";

// common.js
const PXON = require("pxon").default;

// AMD
// I've forgotten but it should work.
```

Or use script tags and globals.

```html
<script src="https://unpkg.com/pxon/umd/pxon.min.js"></script>
```

And then grab it off the global like so:

```js
const PXON = PXON.default;
```

## Example Usage

```js
const PXON = require("pxon").default;
const pxon = new PXON();

// Import PXON-formatted JSON.
pxon.import({ ... });

// Set some EXIF data.
pxon.artist = "Matthew Hudson";
pxon.software = "https://make8bitart.com/";

// Set a single pixel's value.
pxon.setPixel(x, y, color, size);

// Iterate over an ES6 HashMap of all pixels.
for (let [key, pixel] of pxon.pixels) {
console.log(`${key}, ${pixel}`);
// <- 0:0, { x: 0, y: 0, size: 1, color: 'rgba(0, 0, 0, 1)' }
}

// Returns a PXON-formatted object.
console.log(pxon.export());
```

### [Full API Documentation &rarr;](https://thematthewhudson.com/pxon/)

## Additional Resources

* [PXON Specification](http://jennmoney.biz/pxon/) - specs for the "pixel art object notation" format
* [make8bitart.com](https://make8bitart.com/) - pixel art painting app
* [pxonloop](http://pxonloop.glitch.me/) - a pxon playground
* [image-to-pxon](http://image-to-pxon.glitch.me/) - app that converts image to pxon

## Notes

* The non-canonical `dataURL` field is not currently supported.
* The non-canonical `size` field defaults to `1`.
Loading

0 comments on commit 77ec007

Please sign in to comment.