c++ - 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# - 如何在统一 c# 脚本和 android 活动之间正确通信?
- python - 在按钮按下时运行并在按钮按下时中断
- python - 如何重塑数组数组?
- spring-security - Webflux - Spring Boot - 具有 http 代理支持的 oAuth2 客户端
- python - 如何在一段时间后自动注销用户。Python Tkinter
- struct - rust:如何编写一个带有引用外部值的回调的`impl`
- vb6 - vb6 Treeview1 问题将状态添加到 For 语句
- reactjs - 如何从子组件访问状态?
- python - Pandas 根据 DataFrame 中的另一列填充 NA 的增量值
- python - 如何在 python 中可视化/动画化一维数组?