首页 > 解决方案 > Floodfill 未正确着色指定参数

问题描述

我正在使用 floodfill() 并且它没有为我想要的地方着色,而是为整个窗口着色。

我想要矩形内的青色背景和线 line(conx(30) - 2, cony(0)+2, conx(100) + 2, cony(30) - 2); 下的洋红色背景;但仍在矩形边界内。

这是代码,包括相关库:

#include <iostream>
#include <graphics.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

using namespace std;

//convert to pixel value (scale of 6)
double conx(double x)
{
    return x * (600/100) + 50;
}

double cony(double y)
{
    return -y * (600/100) + 650;
}

int main()
{
initwindow(700,700);

rectangle(50, 0, 650, 650);
setfillstyle(SOLID_FILL, CYAN);
floodfill(100, 100, CYAN);
setfillstyle(SOLID_FILL, MAGENTA);
floodfill(620, 620, MAGENTA);


settextstyle(DEFAULT_FONT, HORIZ_DIR, 3);
outtextxy(150, 655, "ELASTIC PARTICLE");
setcolor(15);

setcolor(15);
line(0, 0, 700, 0);
line(50, 0, 50, 650);
line(650, 0, 650, 652);
line(50, 650, 652, 650);

//drawing the line for the wedge/incline
line(conx(30) - 2, cony(0)+2, conx(100) + 2, cony(30) - 2);

//borders
setcolor(15);
line(0, 0, 700, 0);
line(50, 0, 50, 650);
line(650, 0, 650, 652);
line(50, 650, 652, 650);
}

这是输出的示例

标签: c++dev-c++

解决方案


推荐阅读