Skip to content

Commit

Permalink
Move demo to branch ♻️
Browse files Browse the repository at this point in the history
  • Loading branch information
SubZtep committed Nov 25, 2020
1 parent 2599cc8 commit e9a1c59
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 145 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Simple usage is simple, [download](https://raw.githubusercontent.com/SubZtep/afr
<a-box warpspeed></a-box>
```

For more detailed usage check the [example source](index.html) and its [**LIVE demonstration** page](https://subztep.github.io/aframe-warpspeed-texture/) with GUI for properties.
For more detailed usage check the [demo branch](https://github.com/SubZtep/aframe-warpspeed-texture/tree/demo) and its [**LIVE demonstration** page](https://subztep.github.io/aframe-warpspeed-texture/) with GUI for the properties.

### API

Expand Down
2 changes: 1 addition & 1 deletion awt.min.js

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions colorft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const defaultRGB = {
r: 255,
g: 255,
b: 255,
}

// detect

const isHex = color => color.charAt(0) === "#" && color.length === 7
const isRGBA = color => color.startsWith("rgba")

// convert

// "rgba(44,44,44,1)"

const hex2rgb = color => ({
r: parseInt(color.substr(1, 2), 16),
g: parseInt(color.substr(3, 2), 16),
b: parseInt(color.substr(5, 2), 16),
})

const rgba2rgb = color => {
const [, r, g, b, a] = /^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/.exec(color)
return {
r,
g,
b,
}
}

export const toRGB = color => {
if (isHex(color)) {
return hex2rgb(color)
}
if (isRGBA(color)) {
return rgba2rgb(color)
}

return defaultRGB
}
Binary file removed doc.pdf
Binary file not shown.
126 changes: 0 additions & 126 deletions index.html

This file was deleted.

25 changes: 21 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"rollup": "^2.33.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-web-worker-loader": "^1.4.0"
},
"dependencies": {
"color-parse": "^1.4.2"
}
}
16 changes: 3 additions & 13 deletions warpspeed.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { toRGB } from "./colorft"

const randPos = () => (Math.random() - 0.5) * 1000
const hex2rgb = webColor =>
webColor.charAt(0) === "#" && webColor.length === 7
? {
r: parseInt(webColor.substr(1, 2), 16),
g: parseInt(webColor.substr(3, 2), 16),
b: parseInt(webColor.substr(5, 2), 16),
}
: {
r: 255,
g: 255,
b: 255,
}

class Star {
constructor(x, y, z) {
Expand Down Expand Up @@ -53,7 +43,7 @@ export default class WarpSpeed {
}
break
case "starColor":
const color = hex2rgb(value)
const color = toRGB(value)
this.starR = color.r
this.starG = color.g
this.starB = color.b
Expand Down

0 comments on commit e9a1c59

Please sign in to comment.