Exemplo n.º 1
0
SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime,
                                  SkMSec nextTime, const SkScalar blend[4]) {
    SkASSERT(time > prevTime && time < nextTime);

    SkScalar t = SkScalarDiv((SkScalar)(time - prevTime),
                             (SkScalar)(nextTime - prevTime));
    return blend ?
            SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t;
}
Exemplo n.º 2
0
bool SkDisplayRandom::getProperty(int index, SkScriptValue* value) const {
    switch(index) {
        case SK_PROPERTY(random): {
            SkScalar random = fRandom.nextUScalar1();
            SkScalar relativeT = SkUnitCubicInterp(random, SK_Scalar1 - blend, 0, 0, SK_Scalar1 - blend);
            value->fOperand.fScalar = min + SkScalarMul(max - min, relativeT);
            value->fType = SkType_Float;
            return true;
        }
        default:
            SkASSERT(0);
    }
    return false;
}