C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[48537] Re:원의 그라데이션 효과 방법.
착한아들 [miru0418] 1125 읽음    2007-03-23 09:12
혹시 Fram3D와 같은 API함수를 찾으시는지요?
저두 예전에 찾다가 못찾구 직접구했습니다.
이거 고수들 앞에서 올려두 될려나?? ㅋㅋㅋ
암턴 참조하세요.

불러와서 쓰는법.
Round3DEx(ACanvas, ARect, AColor1, AColor2, ARound, 2);

함수
void __fastcall TForm1::Round3DEx(TCanvas *Canvas, TRect &Rect, TColor TopColor, TColor BottomColor, int Round, int Width)
{
    unsigned char ucRGB[3][3];
    ucRGB[0][0] = GetRValue(TopColor);  ucRGB[1][0] = GetRValue(BottomColor);
    ucRGB[0][1] = GetGValue(TopColor);  ucRGB[1][1] = GetGValue(BottomColor);
    ucRGB[0][2] = GetBValue(TopColor);  ucRGB[1][2] = GetBValue(BottomColor);

    if(TopColor - BottomColor < 0)
    {
        ucRGB[2][0] = ucRGB[1][0] - ucRGB[0][0];
        ucRGB[2][1] = ucRGB[1][1] - ucRGB[0][1];
        ucRGB[2][2] = ucRGB[1][2] - ucRGB[0][2];
    }
    else
    {
        ucRGB[2][0] = ucRGB[0][0] - ucRGB[1][0];
        ucRGB[2][1] = ucRGB[0][1] - ucRGB[1][1];
        ucRGB[2][2] = ucRGB[0][2] - ucRGB[1][2];
    }

    Canvas->Pen->Width = Width;
    Canvas->Pen->Color = TopColor;
    Canvas->MoveTo(Rect.left, Rect.bottom - Round);
    Canvas->LineTo(Rect.left, Rect.top    + Round);
    RoundDraw(Canvas, Rect, 180, 270, Round);
    Canvas->LineTo(Rect.right - Round, Rect.top);
    RoundDraw(Canvas, Rect, ucRGB[0], ucRGB[2], 270, 360, Round, (TopColor - BottomColor < 0));

    Canvas->Pen->Color = BottomColor;
    Canvas->LineTo(Rect.right -1, Rect.bottom - Round);
    RoundDraw(Canvas, Rect,   0,  90, Round);
    Canvas->LineTo(Rect.left  + Round, Rect.bottom -1);
    RoundDraw(Canvas, Rect, ucRGB[1], ucRGB[2],  90, 180, Round, (BottomColor - TopColor < 0));

    Rect.top + Width;
    Rect.left + Width;
    Rect.right - Width;
    Rect.bottom - Width;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RoundDraw(TCanvas *Canvas, TRect &Rect, int StartPos, int EndPos, int Round)
{
    double x, y;
    double addx, addy;
    switch(StartPos)
    {
        case   0:
            addx = Rect.right  -Round;
            addy = Rect.bottom -Round;
            break;
        case  90:
            addx = Rect.left   +Round;
            addy = Rect.bottom -Round;
            break;
        case 180:
            addx = Rect.left   +Round;
            addy = Rect.top    +Round;
            break;
        default:
            addx = Rect.right  -Round;
            addy = Rect.top    +Round;
            break;
    }

    for(int i = StartPos +1; i < EndPos; i++)
    {
        x = cos(i *M_PI /180.0) *Round +addx;
        y = sin(i *M_PI /180.0) *Round +addy;
        Canvas->LineTo(x, y);
    }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RoundDraw(TCanvas *Canvas, TRect &Rect, unsigned char* ucRGB, unsigned char* ucRGBD,
                                  int StartPos, int EndPos, int Round, bool Direction)
{
    double x, y;
    double addx, addy;
    switch(StartPos)
    {
        case   0:
            addx = Rect.right  -Round;
            addy = Rect.bottom -Round;
            break;
        case  90:
            addx = Rect.left   +Round;
            addy = Rect.bottom -Round;
            break;
        case 180:
            addx = Rect.left   +Round;
            addy = Rect.top    +Round;
            break;
        default:
            addx = Rect.right  -Round;
            addy = Rect.top    +Round;
            break;
    }

    for(int i = StartPos +1; i < EndPos; i++)
    {
        x = cos(i *M_PI /180.0) *Round +addx;
        y = sin(i *M_PI /180.0) *Round +addy;
        Canvas->LineTo(x, y);
        if(Direction)
        {
            Canvas->Pen->Color = (TColor)RGB(ucRGB[0] + MulDiv(i -StartPos, ucRGBD[0], 90),
                                             ucRGB[1] + MulDiv(i -StartPos, ucRGBD[1], 90),
                                             ucRGB[2] + MulDiv(i -StartPos, ucRGBD[2], 90));
        }
        else
        {
            Canvas->Pen->Color = (TColor)RGB(ucRGB[0] - MulDiv(i -StartPos, ucRGBD[0], 90),
                                             ucRGB[1] - MulDiv(i -StartPos, ucRGBD[1], 90),
                                             ucRGB[2] - MulDiv(i -StartPos, ucRGBD[2], 90));
        }
    }
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
48534 원의 그라데이션 효과 방법. newhuni 1028 2007/03/22
48540     Re:원의 그라데이션 효과 방법. WARSHIP 1104 2007/03/23
48579         Re:Re:조언감사합니다. 지금 리전 공부중~~ ^^; newhuni 804 2007/03/27
48537     Re:원의 그라데이션 효과 방법. 착한아들 1125 2007/03/23
48580         Re:Re:도움 감사드립니다.. 멋있네요.. 잘 쓰겠습니다. ^^ newhuni 779 2007/03/27
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.