Пример #1
0
void RgbEffects::DrawCurtainVertical(bool topEdge, int ylimit, const wxArrayInt &SwagArray)
{
    int i,x,y;
    xlColour color;
    for (i=0; i<ylimit; i++)
    {
        GetMultiColorBlend(double(i) / double(BufferHt), true, color);
        y=topEdge ? BufferHt-i-1 : i;
        for (x=BufferWi-1; x>=0; x--)
        {
            SetPixel(x,y,color);
        }
    }

    // swag
    for (i=0; i<SwagArray.Count(); i++)
    {
        y=ylimit+i;
        GetMultiColorBlend(double(y) / double(BufferHt), true, color);
        if (topEdge) y=BufferHt-y-1;
        for (x=BufferWi-1; x>SwagArray[i];x--)
        {
            SetPixel(x,y,color);
        }
    }
}
Пример #2
0
void RgbEffects::RenderColorWash(bool HorizFade, bool VertFade, int RepeatCount)
{
    static int SpeedFactor=200;
    int x,y;
    wxColour color;
    wxImage::HSVValue hsv,hsv2;
    size_t colorcnt=GetColorCount();
    int CycleLen=colorcnt*SpeedFactor;
    if (state > (colorcnt-1)*SpeedFactor*RepeatCount && RepeatCount < 10)
    {
        GetMultiColorBlend(double(RepeatCount%2), false, color);
    }
    else
    {
        GetMultiColorBlend(double(state % CycleLen) / double(CycleLen), true, color);
    }
    Color2HSV(color,hsv);
    double HalfHt=double(BufferHt-1)/2.0;
    double HalfWi=double(BufferWi-1)/2.0;
    for (x=0; x<BufferWi; x++)
    {
        for (y=0; y<BufferHt; y++)
        {
            hsv2=hsv;
            if (HorizFade) hsv2.value*=1.0-abs(HalfWi-x)/HalfWi;
            if (VertFade) hsv2.value*=1.0-abs(HalfHt-y)/HalfHt;
            SetPixel(x,y,hsv2);
        }
    }
}
Пример #3
0
void RgbEffects::DrawCurtain(bool LeftEdge, int xlimit, const wxArrayInt &SwagArray)
{
    int i,x,y;
    xlColour color;
    for (i=0; i<xlimit; i++)
    {
        GetMultiColorBlend(double(i) / double(BufferWi), true, color);
        x=LeftEdge ? BufferWi-i-1 : i;
        for (y=BufferHt-1; y>=0; y--)
        {
            SetPixel(x,y,color);
        }
    }

    // swag
    for (i=0; i<SwagArray.Count(); i++)
    {
        x=xlimit+i;
        GetMultiColorBlend(double(x) / double(BufferWi), true, color);
        if (LeftEdge) x=BufferWi-x-1;
        for (y=BufferHt-1; y>SwagArray[i]; y--)
        {
            SetPixel(x,y,color);
        }
    }
}
Пример #4
0
void RgbEffects::RenderButterfly(int ColorScheme, int Style, int Chunks, int Skip)
{
    int x,y,d;
    double n,x1,y1,f;
    double h=0.0;
    static const double pi2=6.283185307;
    wxColour color;
    wxImage::HSVValue hsv;
    int maxframe=BufferHt*2;
    int frame=(BufferHt * state / 200)%maxframe;
    double offset=double(state)/100.0;

    for (x=0; x<BufferWi; x++)
    {
        for (y=0; y<BufferHt; y++)
        {
            switch (Style)
            {
            case 1:
                n = abs((x*x - y*y) * sin (offset + ((x+y)*pi2 / (BufferHt+BufferWi))));
                d = x*x + y*y+1;
                h=n/d;
                break;
            case 2:
                f=(frame < maxframe/2) ? frame+1 : maxframe - frame;
                x1=(double(x)-BufferWi/2.0)/f;
                y1=(double(y)-BufferHt/2.0)/f;
                h=sqrt(x1*x1+y1*y1);
                break;
            case 3:
                f=(frame < maxframe/2) ? frame+1 : maxframe - frame;
                f=f*0.1+double(BufferHt)/60.0;
                x1 = (x-BufferWi/2.0)/f;
                y1 = (y-BufferHt/2.0)/f;
                h=sin(x1) * cos(y1);
                break;

            }
            hsv.saturation=1.0;
            hsv.value=1.0;
            if (Chunks <= 1 || int(h*Chunks) % Skip != 0)
            {
                if (ColorScheme == 0)
                {
                    hsv.hue=h;
                    SetPixel(x,y,hsv);
                }
                else
                {
                    GetMultiColorBlend(h,false,color);
                    SetPixel(x,y,color);
                }
            }
        }
    }
}
Пример #5
0
void PixelBufferClass::RenderGarlands(int layer, int GarlandType, int Spacing)
{
    int x,y,yadj,ylimit,ring;
    double ratio;
    wxColour color;
    int PixelSpacing=Spacing*BufferHt/100+3;
    int limit=BufferHt*PixelSpacing;
    GarlandsState[layer]=(GarlandsState[layer] + Speed*PixelSpacing/20 + 1) % limit;
    // ring=0 is the top ring
    for (ring=0; ring<BufferHt; ring++) {
        ratio=double(ring)/double(BufferHt);
        GetMultiColorBlend(layer, ratio, false, color);
        y=limit - ring*PixelSpacing - GarlandsState[layer];
        ylimit=BufferHt-ring-1;
        for (x=0; x<BufferWi; x++) {
            yadj=y;
            switch (GarlandType) {
                case 1:
                    switch (x%5) {
                        case 2: yadj-=2; break;
                        case 1:
                        case 3: yadj-=1; break;
                    }
                    break;
                case 2:
                    switch (x%5) {
                        case 2: yadj-=4; break;
                        case 1:
                        case 3: yadj-=2; break;
                    }
                    break;
                case 3:
                    switch (x%6) {
                        case 3: yadj-=6; break;
                        case 2:
                        case 4: yadj-=4; break;
                        case 1:
                        case 5: yadj-=2; break;
                    }
                    break;
                case 4:
                    switch (x%5) {
                        case 1:
                        case 3: yadj-=2; break;
                    }
                    break;
            }
            if (yadj < ylimit) yadj=ylimit;
            if (yadj < BufferHt) SetPixel(layer,x,yadj,color);
        }
    }
}
Пример #6
0
void RgbEffects::RenderSpirals(int PaletteRepeat, int Direction, int Rotation, int Thickness, bool Blend, bool Show3D)
{
    int strand_base,strand,thick,x,y,ColorIdx;
    size_t colorcnt=GetColorCount();
    int SpiralCount=colorcnt * PaletteRepeat;
    int deltaStrands=BufferWi / SpiralCount;
    int SpiralThickness=(deltaStrands * Thickness / 100) + 1;
    long SpiralState=state*Direction;
    wxImage::HSVValue hsv;
    wxColour color;
    for(int ns=0; ns < SpiralCount; ns++)
    {
        strand_base=ns * deltaStrands;
        ColorIdx=ns % colorcnt;
        palette.GetColor(ColorIdx,color);
        for(thick=0; thick < SpiralThickness; thick++)
        {
            strand = (strand_base + thick) % BufferWi;
            for(y=0; y < BufferHt; y++)
            {
                x=(strand + SpiralState/10 + y*Rotation/BufferHt) % BufferWi;
                if (x < 0) x += BufferWi;
                if (Blend)
                {
                    GetMultiColorBlend(double(BufferHt-y-1)/double(BufferHt), false, color);
                }
                if (Show3D)
                {
                    Color2HSV(color,hsv);
                    if (Rotation < 0)
                    {
                        hsv.value*=double(thick+1)/SpiralThickness;
                    }
                    else
                    {
                        hsv.value*=double(SpiralThickness-thick)/SpiralThickness;
                    }
                    SetPixel(x,y,hsv);
                }
                else
                {
                    SetPixel(x,y,color);
                }
            }
        }
    }
}
Пример #7
0
void PixelBufferClass::RenderColorWash(int layer, bool HorizFade, bool VertFade)
{
    int x,y;
    wxColour color;
    wxImage::HSVValue hsv,hsv2;
    size_t colorcnt=GetColorCount(layer);
    int CycleLen=colorcnt*100;
    ColorWashState[layer]+=Speed;
    double ratio= double(ColorWashState[layer]/4 % CycleLen) / double(CycleLen);
    GetMultiColorBlend(layer, ratio, true, color);
    Color2HSV(color,hsv);
    double HalfHt=double(BufferHt-1)/2.0;
    double HalfWi=double(BufferWi-1)/2.0;
    for (x=0; x<BufferWi; x++) {
        for (y=0; y<BufferHt; y++) {
            hsv2=hsv;
            if (HorizFade) hsv2.value*=1.0-abs(HalfWi-x)/HalfWi;
            if (VertFade) hsv2.value*=1.0-abs(HalfHt-y)/HalfHt;
            SetPixel(layer,x,y,hsv2);
        }
    }
}
Пример #8
0
void RgbEffects::RenderSpirals(int PaletteRepeat, int Direction, int Rotation, int Thickness,
                               bool Blend, bool Show3D, bool grow, bool shrink)
{
    int strand_base,strand,thick,x,y,ColorIdx;
    size_t colorcnt=GetColorCount();
    int SpiralCount=colorcnt * PaletteRepeat;
    int deltaStrands=BufferWi / SpiralCount;
    int SpiralThickness=(deltaStrands * Thickness / 100) + 1;
    int spiralGap = deltaStrands - SpiralThickness;
    long SpiralState;
    long ThicknessState = state/10;
    wxImage::HSVValue hsv;
    wxColour color;


    if (fitToTime)
    {
        double position = GetEffectTimeIntervalPosition();
        if (grow&&shrink)
        {
            ThicknessState = position <= 0.5?spiralGap*(position*2):spiralGap*((1-position) * 2);
        }
        else if (grow)
        {
                ThicknessState = spiralGap *position;
        }
        else if (shrink)
        {
            ThicknessState = spiralGap * (1-position);
        }
        SpiralState = position*BufferWi*10*Direction;
    }
    else
    {
        SpiralState=state*Direction;
    }

    spiralGap += (spiralGap==0);
    if (grow && (!shrink || ((ThicknessState/spiralGap)%2)==0))
    {
        SpiralThickness += ThicknessState%(spiralGap);
    }
    else if (shrink && (!grow || ((ThicknessState/spiralGap)%2)==1))
    {
        SpiralThickness +=spiralGap-ThicknessState%(spiralGap);
    }

    for(int ns=0; ns < SpiralCount; ns++)
    {
        strand_base=ns * deltaStrands;
        ColorIdx=ns % colorcnt;
        palette.GetColor(ColorIdx,color);
        for(thick=0; thick < SpiralThickness; thick++)
        {
            strand = (strand_base + thick) % BufferWi;
            for(y=0; y < BufferHt; y++)
            {
                x=(strand + SpiralState/10 + y*Rotation/BufferHt) % BufferWi;
                if (x < 0) x += BufferWi;
                if (Blend)
                {
                    GetMultiColorBlend(double(BufferHt-y-1)/double(BufferHt), false, color);
                }
                if (Show3D)
                {
                    Color2HSV(color,hsv);
                    if (Rotation < 0)
                    {
                        hsv.value*=double(thick+1)/SpiralThickness;
                    }
                    else
                    {
                        hsv.value*=double(SpiralThickness-thick)/SpiralThickness;
                    }
                    SetPixel(x,y,hsv);
                }
                else
                {
                    SetPixel(x,y,color);
                }
            }
        }
    }
}
Пример #9
0
void RgbEffects::RenderButterfly(int ColorScheme, int Style, int Chunks, int Skip, int ButterflyDirection)
{
    int x,y,d;
    double n,x1,y1,f;
    double h=0.0;
    static const double pi2=6.283185307;
    wxColour color;
    wxImage::HSVValue hsv;
    int maxframe=BufferHt*2;
    int frame=(BufferHt * state / 200)%maxframe;
    double offset=double(state)/200.0;
    if(ButterflyDirection==1) offset = -offset;
    for (x=0; x<BufferWi; x++)
    {
        for (y=0; y<BufferHt; y++)
        {
            switch (Style)
            {
            case 1:

                n = abs((x*x - y*y) * sin (offset + ((x+y)*pi2 / (BufferHt+BufferWi))));
                d = x*x + y*y;
                if(d>0.001) h=n/d;
                else
                    h=0.0;
                break;
            case 2:
                f=(frame < maxframe/2) ? frame+1 : maxframe - frame;
                x1=(double(x)-BufferWi/2.0)/f;
                y1=(double(y)-BufferHt/2.0)/f;
                h=sqrt(x1*x1+y1*y1);
                break;
            case 3:
                f=(frame < maxframe/2) ? frame+1 : maxframe - frame;
                f=f*0.1+double(BufferHt)/60.0;
                x1 = (x-BufferWi/2.0)/f;
                y1 = (y-BufferHt/2.0)/f;
                h=sin(x1) * cos(y1);
                break;
            case 4:
                /*
                The butterfly curve is a transcendental plane curve discovered by Temple H. Fay. The curve is given by the following parametric equations:

                x = \sin(t) \left(e^{\cos(t)} - 2\cos(4t) - \sin^5\left({t \over 12}\right)\right)
                y = \cos(t) \left(e^{\cos(t)} - 2\cos(4t) - \sin^5\left({t \over 12}\right)\right)
                or by the following polar equation:

                r=e^{\cos \theta} - 2 \cos (4 \theta ) + \sin^5\left(\frac{2 \theta - \pi}{24}\right)


                x = \cos(a t) - \cos(b t)^j
                y = \sin(c t) - \sin(d t)^k

                x=2*sin(3*t)*cos(t)
                y=2*sin(3*t)*sin(t)
                */
                h=2*sin(double(x)*3.0)*cos(double(y)) * sin (offset + ((x+y)*pi2 / (BufferHt+BufferWi)));
                h =  x*(y^3) - y*(x^3);
                break;
            }
            hsv.saturation=1.0;
            hsv.value=1.0;
            if (Chunks <= 1 || int(h*Chunks) % Skip != 0)
            {
                if (ColorScheme == 0)
                {
                    hsv.hue=h;
                    SetPixel(x,y,hsv);
                }
                else
                {
                    GetMultiColorBlend(h,false,color);
                    SetPixel(x,y,color);
                }
            }
        }
    }
}
Пример #10
0
// use tempbuf for calculations
void RgbEffects::RenderLife(int Count, int Type)
{
    int i,x,y,cnt;
    bool isLive;
    wxColour color;
    Count=BufferWi * BufferHt * Count / 200 + 1;
    if (state == 0 || Count != LastLifeCount || Type != LastLifeType)
    {
        // seed tempbuf
        LastLifeCount=Count;
        LastLifeType=Type;
        ClearTempBuf();
        for(i=0; i<Count; i++)
        {
            x=rand() % BufferWi;
            y=rand() % BufferHt;
            GetMultiColorBlend(rand01(),false,color);
            SetTempPixel(x,y,color);
        }
    }
    long TempState=state % 400 / 20;
    if (TempState == LastLifeState)
    {
        pixels=tempbuf;
        return;
    }
    else
    {
        LastLifeState=TempState;
    }
    for (x=0; x < BufferWi; x++)
    {
        for (y=0; y < BufferHt; y++)
        {
            GetTempPixel(x,y,color);
            isLive=(color.GetRGB() != 0);
            cnt=Life_CountNeighbors(x,y);
            switch (Type)
            {
            case 0:
                // B3/S23
                /*
                Any live cell with fewer than two live neighbours dies, as if caused by under-population.
                Any live cell with two or three live neighbours lives on to the next generation.
                Any live cell with more than three live neighbours dies, as if by overcrowding.
                Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
                */
                if (isLive && cnt >= 2 && cnt <= 3)
                {
                    SetPixel(x,y,color);
                }
                else if (!isLive && cnt == 3)
                {
                    GetMultiColorBlend(rand01(),false,color);
                    SetPixel(x,y,color);
                }
                break;
            case 1:
                // B35/S236
                if (isLive && (cnt == 2 || cnt == 3 || cnt == 6))
                {
                    SetPixel(x,y,color);
                }
                else if (!isLive && (cnt == 3 || cnt == 5))
                {
                    GetMultiColorBlend(rand01(),false,color);
                    SetPixel(x,y,color);
                }
                break;
            case 2:
                // B357/S1358
                if (isLive && (cnt == 1 || cnt == 3 || cnt == 5 || cnt == 8))
                {
                    SetPixel(x,y,color);
                }
                else if (!isLive && (cnt == 3 || cnt == 5 || cnt == 7))
                {
                    GetMultiColorBlend(rand01(),false,color);
                    SetPixel(x,y,color);
                }
                break;
            case 3:
                // B378/S235678
                if (isLive && (cnt == 2 || cnt == 3 || cnt >= 5))
                {
                    SetPixel(x,y,color);
                }
                else if (!isLive && (cnt == 3 || cnt == 7 || cnt == 8))
                {
                    GetMultiColorBlend(rand01(),false,color);
                    SetPixel(x,y,color);
                }
                break;
            case 4:
                // B25678/S5678
                if (isLive && (cnt >= 5))
                {
                    SetPixel(x,y,color);
                }
                else if (!isLive && (cnt == 2 || cnt >= 5))
                {
                    GetMultiColorBlend(rand01(),false,color);
                    SetPixel(x,y,color);
                }
                break;
            }
        }
    }
    // copy new life state to tempbuf
    tempbuf=pixels;
}
Пример #11
0
void RgbEffects::RenderGarlands(int GarlandType, int Spacing)
{
    int x,y,yadj,ylimit,ring;
    double ratio;
    wxColour color;
    int PixelSpacing=Spacing*BufferHt/100+3;
    int limit=BufferHt*PixelSpacing*4;
    int GarlandsState=(limit - (state % limit))/4;
    // ring=0 is the top ring
    for (ring=0; ring<BufferHt; ring++)
    {
        ratio=double(ring)/double(BufferHt);
        GetMultiColorBlend(ratio, false, color);
        y=GarlandsState - ring*PixelSpacing;
        ylimit=BufferHt-ring-1;
        for (x=0; x<BufferWi; x++)
        {
            yadj=y;
            switch (GarlandType)
            {
            case 1:
                switch (x%5)
                {
                case 2:
                    yadj-=2;
                    break;
                case 1:
                case 3:
                    yadj-=1;
                    break;
                }
                break;
            case 2:
                switch (x%5)
                {
                case 2:
                    yadj-=4;
                    break;
                case 1:
                case 3:
                    yadj-=2;
                    break;
                }
                break;
            case 3:
                switch (x%6)
                {
                case 3:
                    yadj-=6;
                    break;
                case 2:
                case 4:
                    yadj-=4;
                    break;
                case 1:
                case 5:
                    yadj-=2;
                    break;
                }
                break;
            case 4:
                switch (x%5)
                {
                case 1:
                case 3:
                    yadj-=2;
                    break;
                }
                break;
            }
            if (yadj < ylimit) yadj=ylimit;
            if (yadj < BufferHt) SetPixel(x,yadj,color);
        }
    }
}