java - 用长方形做一个圆
问题描述
因为我数学不太好。我需要一些帮助。
我想创建一个圆,但我不想使用 (x,y, rad),而是使用矩形创建一个圆。我的画布宽度和高度是 1200(像素)。我想按以下方式放置我的圆圈:x = WIDTH/3*2,y = HEIGHT/3。半径为500。
我已经开始创建一个矩形的 for 循环,但是出了点问题。这是我所做的:
//not really important, just colors
Color Planet1 = new Color(68,243,252);
Color Planet2 = new Color(179, 225, 249);
int nbDegrade = 100;
// What I wanted to make is 2 for loops, to make 2 half circles.
for(int i = 1; i < 250; ++i) {
//this is setting a color with color mixture code
painter.setColor(mixture(Planet1, Planet2,(double)i/nbDegrade));
//fillRectangle code (x, y, width, height)
painter.fillRectangle(WIDTH/3*2 + i,HEIGHT/3 - i,1,i *2);
}
我觉得我必须使用 tan 函数,但不知道该怎么做。
解决方案
推荐阅读
- automation - 在 UFT 中的 javatree 中查找子节点的文本
- hyperledger-fabric - 是否可以在 Hyperledger Composer 设置中部署链代码?
- python-3.x - 如何打包 PySide2 应用程序以进行分发?
- python - Airflow 网络服务器为 dags 提供 cron 错误,其中 None 作为计划间隔
- android - 我很困惑他们俩哪一个是最好的 GoogleApiClient 或 FusedLocationProviderClient
- python - 创建具有多个数据框和多个条件的列
- powerbi-desktop - sameperiodlastyear 当会计日历不是逐月时
- python - 初学者在 Python 中循环
- c# - Kendo mvc 在下拉列表中加入文本
- python - python的`in`函数在通过`__getitem__()`'触发时如何工作?