Skip to content

Commit

Permalink
Merge branch 'master' into handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Nov 24, 2023
2 parents 4909f3b + 5bb5436 commit 9afbf6d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
9 changes: 8 additions & 1 deletion VortexEngine/src/Colors/Colorset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,14 @@ void Colorset::randomize(Random &ctx, uint8_t numColors)
ValueStyle valStyle = (ValueStyle)ctx.next8(0, VAL_STYLE_COUNT);

for (uint8_t i = 0; i < numColors; ++i) {
addColorWithValueStyle(ctx, ctx.next8(), ctx.next8(), valStyle, numColors, i);
// call next8 explicitly in this order because the order they
// are called is undefined when called as parameters to another function.
// ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler.
// So different compilers may produce different results,
// but like this it is explicit
uint8_t sat = ctx.next8();
uint8_t hue = ctx.next8();
addColorWithValueStyle(ctx, hue, sat, valStyle, numColors, i);
}
}

Expand Down
60 changes: 38 additions & 22 deletions VortexEngine/src/Menus/MenuList/Randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,40 +230,56 @@ bool Randomizer::rollPattern(Random &ctx, Mode *pMode, LedPos pos)

void Randomizer::traditionalPattern(Random &ctx, PatternArgs &outArgs)
{
outArgs.init(
ctx.next8(1, 20), // on duration 1 -> 20
ctx.next8(8, 60) // off duration 0 -> 60
);
// call next8 explicitly in this order because the order they
// are called is undefined when called as parameters to another function.
// ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler.
// So different compilers may produce different results,
// but like this it is explicit
uint8_t off = ctx.next8(8, 60); // off duration 0 -> 60
uint8_t on = ctx.next8(1, 20); // on duration 1 -> 20
outArgs.init(on, off);
}

void Randomizer::gapPattern(Random &ctx, PatternArgs &outArgs)
{
outArgs.init(
ctx.next8(1, 10), // on duration 1 -> 10
ctx.next8(0, 6), // off duration 0 -> 6
ctx.next8(40, 100) // gap duration 40 -> 100
);
// call next8 explicitly in this order because the order they
// are called is undefined when called as parameters to another function.
// ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler.
// So different compilers may produce different results,
// but like this it is explicit
uint8_t gap = ctx.next8(40, 100); // gap duration 40 -> 100
uint8_t off = ctx.next8(0, 6); // off duration 0 -> 6
uint8_t on = ctx.next8(1, 10); // on duration 1 -> 10
outArgs.init(on, off, gap);
}

void Randomizer::dashPattern(Random &ctx, PatternArgs &outArgs)
{
outArgs.init(
ctx.next8(1, 10), // on duration 1 -> 10
ctx.next8(0, 10), // off duration 0 -> 10
ctx.next8(20, 30), // need gap 20 -> 30
ctx.next8(20, 30) // dash duration 20 -> 30
);
// call next8 explicitly in this order because the order they
// are called is undefined when called as parameters to another function.
// ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler.
// So different compilers may produce different results,
// but like this it is explicit
uint8_t dash = ctx.next8(20, 30); // dash duration 20 -> 30
uint8_t gap = ctx.next8(20, 30); // need gap 20 -> 30
uint8_t off = ctx.next8(0, 10); // off duration 0 -> 10
uint8_t on = ctx.next8(1, 10); // on duration 1 -> 10
outArgs.init(on, off, gap, dash);
}

void Randomizer::crushPattern(Random &ctx, PatternArgs &outArgs)
{
outArgs.init(
ctx.next8(1, 10), // on duration 1 -> 10
ctx.next8(0, 10), // off duration 0 -> 5
ctx.next8(20, 40), // need gap 20 -> 40
0, // dash 0
ctx.next8(0, 8) // groupsize 0 to 8
);
// call next8 explicitly in this order because the order they
// are called is undefined when called as parameters to another function.
// ex: f(a,b,c) may call in the order a,b,c or c,b,a depending on compiler.
// So different compilers may produce different results,
// but like this it is explicit
uint8_t group = ctx.next8(0, 8); // groupsize 0 to 8
uint8_t dash = 0; // dash 0
uint8_t gap = ctx.next8(20, 40); // need gap 20 -> 40
uint8_t off = ctx.next8(0, 10); // off duration 0 -> 5
uint8_t on = ctx.next8(1, 10); // on duration 1 -> 10
outArgs.init(on, off, gap, dash, group);
}

PatternID Randomizer::rollPatternID(Random &ctx)
Expand Down

0 comments on commit 9afbf6d

Please sign in to comment.