forked from eordano/warrolight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {ColorUtils} from "../../utils/ColorUtils"; | ||
import {TimeTickedFunction} from "../TimeTickedFunction"; | ||
|
||
export class Func extends TimeTickedFunction { | ||
constructor(config, leds) { | ||
super(config, leds); | ||
this.time = 0; | ||
} | ||
|
||
drawFrame(draw, done) { | ||
this.time += this.config.speed; | ||
const punta = this.time; | ||
const newColors = new Array(this.numberOfLeds) | ||
|
||
for (let i = 0; i < this.numberOfLeds; i++) { | ||
newColors[i] = ColorUtils.HSVtoHex( | ||
0, | ||
0, | ||
0 | ||
) | ||
} | ||
const colorTime = this.config.colorTime * 1000 | ||
for (let i = 0; i < this.config.spearLength; i++) { | ||
newColors[(punta + i) % this.numberOfLeds] = ColorUtils.HSVtoHex( | ||
((this.time + i * this.config.colorVariety) % colorTime) / colorTime, | ||
1, | ||
this.config.brillo, | ||
) | ||
} | ||
draw(newColors); | ||
} | ||
|
||
static presets() { | ||
return { | ||
fastMarks: {speed: 3, sameColorLeds: 5}, | ||
} | ||
} | ||
|
||
// Override and extend config Schema | ||
static configSchema() { | ||
let config = super.configSchema(); | ||
config.speed = {type: Number, min: 5, max: 20, default: 4}; | ||
config.brillo = {type: Number, min: 0, max: 1, step: 0.01, default: 0.3}; | ||
config.colorTime = {type: Number, min: 0, max: 10, step: 0.1, default: 1}; | ||
config.spearLength = {type: Number, min: 30, max: 540, step: 1, default: 180}; | ||
config.colorVariety = {type: Number, min: 1, max: 10, step: 1, default: 2}; | ||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {TimeTickedFunction} from "../TimeTickedFunction"; | ||
import {ColorUtils} from "../../utils/ColorUtils"; | ||
|
||
export class Func extends TimeTickedFunction{ | ||
drawFrame(draw, done) { | ||
const colors = new Array(this.numberOfLeds) | ||
const elapsed = (this.timeInMs) / 1000; | ||
|
||
this.extraTime = (this.extraTime || 0) + Math.random()*10; | ||
|
||
const centerX = this.config.moveX | ||
? Math.sin(this.extraTime / 1000) * 60 - 30 | ||
: this.config.centerX | ||
|
||
for (let i = 0; i < this.numberOfLeds; i++) { | ||
const dx = this.position.x[i] - 30 - centerX; | ||
const dy = this.position.y[i] - 34.6 + this.config.centerY; | ||
|
||
const distance = Math.sqrt(dx*dx + dy*dy) * 255 / (300*this.config.escala); | ||
|
||
const v = Math.max(0, Math.sin(distance + elapsed * this.config.velocidad)); | ||
colors[i] = ColorUtils.HSVtoHex((distance/5+ this.extraTime/1000) % 1, 1, Math.pow(v, this.config.power)) | ||
} | ||
draw(colors) | ||
} | ||
|
||
// Override and extend config Schema | ||
static configSchema(){ | ||
let res = super.configSchema(); | ||
res.escala = {type: Number, min: 0.1, max: 100, step: 0.1, default: 1} | ||
res.velocidad = {type: Number, min: -50, max: 50, step: 0.1, default: -5} | ||
res.centerY = {type: Number, min: 0, max: 40, step: 0.1, default: 0} | ||
res.centerX = {type: Number, min: -30, max: 30, step: 0.1, default: 0} | ||
res.power = {type: Number, min: 0, max: 10, step: 0.1, default: 1} | ||
res.randomEscala = {type: Boolean, default: false } | ||
res.randomSpeed = {type: Boolean, default: false } | ||
res.moveX = {type: Boolean, default: true } | ||
return res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {ColorUtils} from "../../utils/ColorUtils"; | ||
import {TimeTickedFunction} from "../TimeTickedFunction"; | ||
|
||
export class Func extends TimeTickedFunction { | ||
constructor(config, leds) { | ||
super(config, leds); | ||
|
||
this.time = 0; | ||
} | ||
|
||
drawFrame(draw, done) { | ||
this.time += this.config.speed; | ||
const elapsed = this.time; | ||
const newColors = new Array(this.numberOfLeds) | ||
const sameColorLeds = this.config.sameColorLeds * 10 | ||
|
||
for (let i = 0; i < this.numberOfLeds; i++) { | ||
newColors[i] = ColorUtils.HSVtoHex( | ||
(this.position.x[i] - elapsed % sameColorLeds + sameColorLeds) / sameColorLeds, | ||
1, | ||
this.config.brillo | ||
) | ||
} | ||
draw(newColors); | ||
} | ||
|
||
static presets() { | ||
return { | ||
fastMarks: {speed: 3, sameColorLeds: 5}, | ||
} | ||
} | ||
|
||
// Override and extend config Schema | ||
static configSchema() { | ||
let config = super.configSchema(); | ||
config.speed = {type: Number, min: 1, max: 20, default: 1}; | ||
config.sameColorLeds = {type: Number, min: 1, max: 100, default: 30}; | ||
config.brillo = {type: Number, min: 0, max: 1, step: 0.01, default: 0.3}; | ||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {ColorUtils} from "../../utils/ColorUtils"; | ||
import {TimeTickedFunction} from "../TimeTickedFunction"; | ||
|
||
export class Func extends TimeTickedFunction { | ||
constructor(config, leds) { | ||
super(config, leds); | ||
this.time = 0; | ||
} | ||
|
||
drawFrame(draw, done) { | ||
this.time += this.config.speed; | ||
const punta = this.time; | ||
const newColors = new Array(this.numberOfLeds) | ||
|
||
for (let i = 0; i < this.numberOfLeds; i++) { | ||
newColors[i] = ColorUtils.HSVtoHex( | ||
0, | ||
0, | ||
0 | ||
) | ||
} | ||
for (let i = 0; i < this.config.spearLength; i++) { | ||
newColors[(punta + i) % this.numberOfLeds] = ColorUtils.HSVtoHex( | ||
0, | ||
0, | ||
this.config.brillo, | ||
) | ||
} | ||
draw(newColors); | ||
} | ||
|
||
static presets() { | ||
return { | ||
fastMarks: {speed: 3, sameColorLeds: 5}, | ||
} | ||
} | ||
|
||
// Override and extend config Schema | ||
static configSchema() { | ||
let config = super.configSchema(); | ||
config.speed = {type: Number, min: 5, max: 20, default: 4}; | ||
config.brillo = {type: Number, min: 0, max: 1, step: 0.01, default: 0.3}; | ||
config.spearLength = {type: Number, min: 30, max: 540, step: 1, default: 180}; | ||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const _ = require('lodash') | ||
|
||
import {programsByShape} from "./Transformations"; | ||
|
||
const Spear = require("./components/color-spear").Func; | ||
|
||
// las formas que se pueden usar están definidas en Transformation | ||
const mapping = { | ||
"reloj": [Spear, { spearLength: 100}], | ||
} | ||
|
||
export const Func = programsByShape(mapping) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const _ = require('lodash') | ||
|
||
import {programsByShape} from "./Transformations"; | ||
|
||
const Rainbow = require("./components/rainbow-horizontal").Func; | ||
|
||
// las formas que se pueden usar están definidas en Transformation | ||
const mapping = { | ||
"Warro": [Rainbow, { spearLength: 100}], | ||
} | ||
|
||
export const Func = programsByShape(mapping) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const _ = require('lodash') | ||
|
||
import {programsByShape} from "./Transformations"; | ||
|
||
const Spear = require("./components/color-spear").Func; | ||
|
||
// las formas que se pueden usar están definidas en Transformation | ||
const mapping = { | ||
"reloj": [Spear, { spearLength: 100}], | ||
} | ||
|
||
export const Func = programsByShape(mapping) |