Skip to content

Commit

Permalink
spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
staltz committed Jul 18, 2016
0 parents commit c699389
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Andre Medeiros

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

13 changes: 13 additions & 0 deletions README.md
@@ -0,0 +1,13 @@
# hyperpunk

> Cyberpunk HyperTerm theme
![](screenshot.png)

## Install

Add `hyperpunk` to the plugins list in your `~/.hyperterm.js` config file.

## License

MIT, by [Andre Staltz](https://staltz.com)
109 changes: 109 additions & 0 deletions index.js
@@ -0,0 +1,109 @@
const noise1Png = require('./noise1');
const noise2Png = require('./noise2');
const noise3Png = require('./noise3');
const HUE_SHIFT_INTENSITY = 4;

exports.decorateConfig = (config) => {
return Object.assign({}, config, {
foregroundColor: '#28FC91',
backgroundColor: '#0F2218',
borderColor: '#28FC91',
cursorColor: '#40FFFF',
});
}

exports.decorateHyperTerm = (HyperTerm, { React, notify }) => {
return class extends React.Component {
constructor(props, context) {
super(props, context);
this.state = { noise: 0 };
this._flip = this._flip.bind(this);
this._intervalID = null;
}

_flip () {
this.setState({ noise: (this.state.noise + 1) % 3 });
}

componentWillMount() {
this._intervalID = setInterval(this._flip, 120);
}

render() {
const noisePng = [noise1Png, noise2Png, noise3Png][this.state.noise];
const overridenProps = {
backgroundColor: 'black',
customCSS: `
body {
background-image: ${noisePng};
background-size: 100px 100px;
}
`,
};
return React.createElement(HyperTerm, Object.assign({}, this.props, overridenProps));
}

componentWillUnmount() {
clearInterval(this._intervalID);
}
}
}

exports.decorateTerm = (Term, { React, notify }) => {
return class extends React.Component {
constructor (props, context) {
super(props, context);
this._drawFrame = this._drawFrame.bind(this);
this._onTerminal = this._onTerminal.bind(this);
this._injectStyles = this._injectStyles.bind(this);
this._div = null;
this._body = null;
this._globalStyle = null;
this._term = null;
this._intervalID = null;
}

_onTerminal (term) {
if (this.props.onTerminal) this.props.onTerminal(term);
this._div = term.div_;
this._term = term;
this._body = term.cursorNode_.parentElement;
this._window = term.document_.defaultView;
this._injectStyles();
this._intervalID = setInterval(() => {
this._window.requestAnimationFrame(this._drawFrame);
}, 80);
}

_injectStyles() {
if (this._term) {
this._term.prefs_.set('background-color', 'transparent');
this._term.prefs_.set('background-image', 'none');
}
this._globalStyle = document.createElement('style');
this._globalStyle.setAttribute('type', 'text/css');
this._term.scrollPort_.document_.body.appendChild(this._globalStyle);
}

_drawFrame () {
let x = -1 + 2 * Math.random();
x = x * x;
const intensity = HUE_SHIFT_INTENSITY * x;
this._globalStyle.innerHTML = `
x-screen {
text-shadow: ${intensity}px 0 1px rgba(0,30,255,0.5), ${-intensity}px 0 1px rgba(255,0,80,0.3), 0 0 3px;
}
`;
}

render () {
return React.createElement(Term, Object.assign({}, this.props, {
onTerminal: this._onTerminal
}));
}

componentWillUnmount () {
clearInterval(this._intervalID);
}
}
};
1 change: 1 addition & 0 deletions noise1.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions noise2.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions noise3.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions package.json
@@ -0,0 +1,8 @@
{
"name": "hyperpunk",
"version": "1.0.0",
"keywords": ["hyperterm"],
"description": "Hyperterm extension to make your terminal look Cyberpunk / Sci-fi",
"dependencies": {
}
}
Binary file added screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c699389

Please sign in to comment.