java - 为什么不将这些东西用作颜色并用它来决定颜色?
问题描述
//我试图让它采用我为颜色创建的方法,以便它可以创建不同的红色阴影
导入 java.util.Scanner;公共类流行音乐{
public static void main(String[] args) throws java.io.IOException {
StdDraw.enableDoubleBuffering();
java.util.Scanner scan = new java.util.Scanner(new java.io.FileReader("numfile.txt"));
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
//asks user for input to choose colors
Scanner myObj = new Scanner(System.in);
System.out.println("Enter a number between 1 and 10");
int number = myObj.nextInt(); // Read user input
System.out.println("The number you selected is " + number + ". Good choice! One moment...");
//creates new variables by multiplying the input number and file numbers
StdDraw.enableDoubleBuffering();
rerectangle(0.0, 0.5);
color(a*number);
StdDraw.show();
}
static void rerectangle(double x, double radius) {
if (radius > 0.01) {
StdDraw.setPenColor(color(), 0, 0);
StdDraw.filledRectangle(0.5, radius, radius, radius);
rerectangle(x + radius * 0.2, radius * 0.9);
}
}
static int color(int color1) {
return (color1 * 2);
}
}
解决方案
推荐阅读
- java - 如何从服务器获取 CasToken?
- javascript - 如何在 TypeScript / JavaScript 中缩写驼峰式文本字符串
- angular - 如何有条件地允许导航到用户
- javascript - Jquery 动画滑块
- python - 为什么 Django 开发人员使用 Django 内置管理面板?是否说必须使用而不是 html 主题?
- node.js - 如何在 JSON 中表示元数据
- sql-server - PERFORMANCE - 按 SELECT UNION 中的特定查询块过滤
- android - Android Kotlin - Webview 数据库
- java - 我如何从数据库中选择一个特定的值
- sharepoint - 使用powerapps将元素从列表移动到共享点中的另一个列表