Example #1
0
void Beacon::paint(RNLights & lights) {
    
    float angle = getAnimationCycles();


    float height = (float)info.z / (float)constants.pyramidRadiusFromGround;
    uint32_t platformZValue = height * 255;
    
    for(int i = 0; i < lights.getNumPixels(); i++) {
        if (parameters.onlyExterior && !info.isExteriorLED(i)) {
            lights.setPixelColor(i, parameters.baseGradient.getColor(platformZValue));
            continue;
        };
        float diff = (info.getGlobalAngle(i) - angle) * parameters.numBeacons;
        
        float a = diff - roundf(diff);
        if (a < 0) a = -a;
        if (a < parameters.width) {
            uint8_t gradientPosition = a*256/parameters.width;
            uint32_t color = parameters.gradient.getColor(gradientPosition);
            lights.setPixelColor(i,color);
        } else {
            lights.setPixelColor(i, parameters.baseGradient.getColor(platformZValue));
        }
    }

    info.showActivityWithSparkles(lights);
    
}
void Beacon::paint(RNLights & lights) {
    
    float angle = getAnimationMillis() * parameters.rpm/60000.0;


    for(int i = 0; i < lights.getNumPixels(); i++) {
        float diff = info.getGlobalAngle(i) - angle;
        
        float a = diff - roundf(diff);
        if (a < 0) a = -a;
        if (a < parameters.width) {
            uint8_t gradientPosition = a*256/parameters.width;
            uint32_t color = parameters.gradient.getColor(gradientPosition);
            lights.setPixelColor(i,color);
        }
    }

    info.showActivityWithSparkles(lights);
    
}
Example #3
0
void MovingFaces::paint(RNLights & lights) {

    unsigned long now = info.getGlobalMillis();

    if (now > targetTime) {
        // Rotate points A, B and D. Point C stay the top platform.
        short * backupA = pointA;
        pointA = pointB;
        pointB = pointD;
        pointD = backupA;

        distanceAD = distancePointFromPoint(pointA, pointD);
        startTime = now;
        targetTime = now + parameters.duration;
    }

    float ratio = (float) (now - startTime) / (float) (targetTime - startTime);
    AHEasingFunction easingFunction = getEasingFunction(parameters.easingMode,
            parameters.curveType);
    ratio = easingFunction(ratio);

    float vector[3] = {
        (pointD[0] - pointA[0]) * ratio,
        (pointD[1] - pointA[1]) * ratio,
        (pointD[2] - pointA[2]) * ratio
    };

    long a, b, c, d;
    getPlanEquation(
            pointA[0] + vector[0], pointA[1] + vector[1], pointA[2] + vector[2],
            pointB[0], pointB[1], pointB[2],
            pointC[0], pointC[1], pointC[2],
            a, b, c, d);

    for (int i = 0; i < lights.getNumPixels(); i++) {
        float xLED = getLEDXPosition(i) + info.x;
        float yLED = getLEDYPosition(i) + info.y;
        float zLED = info.z;
        long distance = distancePointFromPlan(
                a, b, c, d,
                xLED, yLED, zLED);

        if (parameters.summitColorMode) {
            if (abs(distance) <= parameters.thickness) {
                lights.setPixelColor(i, gradient3Colors.getPixelColor(i));
            }
        } else {
            RNGradient *gradientToUse = 0;
            float point = 0;
            if (abs(distance) <= parameters.thickness) {
                gradientToUse = &(parameters.gradientInside);
                point = (float) (parameters.thickness - abs(distance)) /
                        (float) parameters.thickness;
            } else {
                gradientToUse = &(parameters.gradientOutside);
                point = (float) abs(distance) / (float) distanceAD;
            }
            uint32_t color = gradientToUse->getColor(point * 255);
            lights.setPixelColor(i, color);
        }
    }

    lastUpdate = now;
}