huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


#include <easyx.h>
#include <time.h>

// 得到云朵图像
// img			传出图像指针
// bkColor		云朵背景色
// cloudColor	云朵颜色
// width		整个云朵的宽,由于宽高必须成比例,所以只需要设置宽即可
void DrawCloud(IMAGE* img, COLORREF bkColor = BLACK, COLORREF cloudColor = WHITE, int width = 180)
{
    IMAGE* old = GetWorkingImage();
    SetWorkingImage(img);

    // 比例
    double ratio = width / 180.0;
    Resize(img, width, (int)(100 * ratio));
    setbkcolor(bkColor);
    setfillcolor(cloudColor);
    setlinecolor(cloudColor);
    cleardevice();

    fillcircle((int)(95 * ratio), (int)(40 * ratio), (int)(40 * ratio));
    fillcircle((int)(85 * ratio), (int)(70 * ratio), (int)(27 * ratio));
    fillcircle((int)(40 * ratio), (int)(60 * ratio), (int)(40 * ratio));
    fillcircle((int)(125 * ratio), (int)(75 * ratio), (int)(25 * ratio));
    fillcircle((int)(145 * ratio), (int)(40 * ratio), (int)(30 * ratio));

    SetWorkingImage(old);
}

int main()
{
    initgraph(640,480);
    srand((UINT)time(NULL));
    setbkcolor(RGB(130, 210, 255));
    cleardevice();

    IMAGE cloud[5];
    DrawCloud(&cloud[0], getbkcolor(), WHITE, 180);
    DrawCloud(&cloud[1], getbkcolor(), RED, 200);
    DrawCloud(&cloud[2], getbkcolor(), GREEN, 120);
    DrawCloud(&cloud[3], getbkcolor(), BLACK, 90);
    DrawCloud(&cloud[4], getbkcolor(), LIGHTGRAY, 230);

    for(int i=0;i<5;i++)
        putimage(rand() % 500, rand() % 350, &cloud[i]);

    while(true);
    closegraph();
    return 0;
}




返回首页


Copyright (C) 2018-2024 huidong