Use this for discussion of advanced techniques for Task #4.
And for finding as short a solution as possible.
Use this for discussion of advanced techniques for Task #4.
And for finding as short a solution as possible.
I’m going to have a try at this from several different angles this week - here’s something short and simple to start with.
var limiter = 0.04;
var t1;
export function beforeRender(delta) {
// generate sawtooth wave for timing and reshape it to a
// curve for better contrast between low and high.
t1 = time(.015)
t1 = t1 * t1 * t1;
// the 'limiter' variable lets us light a small
// area in the center of the strip while our pulse
// is growing, then as it nears maximum brightness,
// we let 'limiter' grow so the lighted region expands
// towards the ends of the strip.
limiter = (t1 > 0.6) ? t1 / 1.6 : 0.04;
}
export function render(index) {
// calculate the current pixel's distance from center
v = abs(0.5 - (index/pixelCount));
// limiter controls how big an area around the center
// we light up. Smaller values mean a smaller region
v = (v < limiter) ? 1-(v / limiter) : 0;
// multiply by our timer for pulsing effect, and
// gamma correct.
v = t1 * v * v * v;
// display in a 1950s radar-ish looking palette
hsv(0.5+v, 1-v,v)
}
Here goes! I feel I am beating @zranger1 on obfuscation
export function render(index) {
if (index < pixelCount / 2) index = pixelCount - index
p = index / pixelCount
v = p - time(.05)
v = 10 * v % 1 * square(v, .1)
hsv(.3, 1, v * v * v * (1 - p))
}
or, visually similar:
export function render(index) {
p = triangle(index / pixelCount)
v = ((1 - p) / 2 - 2 * time(.1) + 1) % 1 * 6 - 5
hsv(.3, 1, v * v * v * p * p)
}
Nice. I’ll have to walk thru how that works.
I really like the use of the square wave to limit which pixels can be turned on. That’s a trick I’ll definitely be borrowing in the future!
I’m not sure exactly how to organize this, but I think we ought to collect the information we develop in these golfing topics and other places where people are playing with code and post it as “Lore” or “Collected Wisdom”, or “Handy Stuff to Know”, or something.
Beyond basic coding, there’s a lot of information here that would be helpful to everyone. For example, as a newcomer looking at the discussion & code for the last couple of exercises, I might like to know:
What do you think? Is this worth topic in the “Pixelblaze Academy”?
Yes to all of those…
As for the Wit and Wisdom of Golfing/etc, I was planning on collating the bits in here, because you are correct, so much good stuff.