我可以获取当前的画布上下文的旋转角度吗?(Can I get the current angle of rotation of my canvas context?)
我想知道是否有方法获得我的画布旋转角度。 而不是用像这样的变量来跟踪它:
var angle = 0; // keeps track of the current angle of the ctx ctx.rotate( Math.PI / 2 ); angle+= Math.Pi / 2; ... ctx.rotate( Math.Pi / 7 ); angle+= Math.Pi / 7;
I was wondering if there is a way of getting an angle of rotation of my canvas. instead of keep tracking of it with a variable like this:
var angle = 0; // keeps track of the current angle of the ctx ctx.rotate( Math.PI / 2 ); angle+= Math.Pi / 2; ... ctx.rotate( Math.Pi / 7 ); angle+= Math.Pi / 7;
原文:https://stackoverflow.com/questions/43346222
更新时间:2024-04-23 16:04
最满意答案
使用
z[i] = inFile.nextDouble();
现在看来你的代码不会编译,你实际上从来没有对从文件中提取的值做任何事情。
z= inFile.nextDouble;
试图取一个双倍并将其分配给一个数组。Use
z[i] = inFile.nextDouble();
As it stands right now your code won't compile and you are never actually doing anything with the values that you pull from the file.
z= inFile.nextDouble;
is trying to take a double and assign it to an array.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
您也可以使用Scanner类。 Scanner in = new Scanner(new File("/path/to/file.txt")); while(in.hasNextLine()) { arrayOfLines.add(in.nextLine()); } 您不必担心\n ,因为Scanner.nextLine()将跳过换行符。 You could alternatively use the Scanner class. Scanner in = new Scanner(new File ...
-
从txt文件中读取每个其他行并保存到数组中(Reading every other line from a txt file and saving into an array)[2022-01-14]
以下可能是一个快速而肮脏的解决方案,但将完成工作: for (soldBoxIndex = 0; soldBoxIndex < numSaleSlips; soldBoxIndex++) { if (soldBoxIndex % 2 != 0 { String soldBoxString; soldBoxString = input.readLine(); //reads in value and assigns/re-assigns so ... -
读取.txt文件并将值存储到Java中的double数组中(Reading in a .txt file and storing the values into a double array in Java)[2022-08-24]
使用 z[i] = inFile.nextDouble(); 现在看来你的代码不会编译,你实际上从来没有对从文件中提取的值做任何事情。 z= inFile.nextDouble; 试图取一个双倍并将其分配给一个数组。 Use z[i] = inFile.nextDouble(); As it stands right now your code won't compile and you are never actually doing anything with the values that you ... -
假设您的成绩在文本文件中为10 20 30 40等,您可以在 for循环中使用此代码: int grade = in.nextInt(); //This code is from your code example grades[i] = grade; 要以相反的顺序打印,您可以使用此for循环: for (int i = 29; i >= 0; i--) { System.out.println(grades[i]); //Print out the value at this array i ...
-
它太简单了; 在读取数据时处理数据; 阅读每个滑雪板并与最佳前值进行比较; 然后选择最佳值作为最佳值; 见下面的代码 import java.io.*; import java.util.*; public class loops { public static void main (String [] args) throws FileNotFoundException{ File myFile = new File("Snowboard_Scores.txt"); Scanner i ...
-
请更改loadGame方法,如下所示: public static void loadGame() throws Exception { //deserialization FileReader fileReader = new FileReader(filename); BufferedReader bufferedReader = new BufferedReader(fileReader); structurePack.Board.gameBoard[0][0] = ...
-
您正在打印出数组的虚拟内存地址而不是实际的数组项: 您可以逐个打印出实际的数组项,如下所示: // This construct is called a for-each loop for(int item: integers) { System.out.println(item); } @akuhn正确地指出Java有一个内置的帮助器: System.out.println(Arrays.toString(integers)); 请注意,您需要添加: import java.util.Array ...
-
第一部分(构建数组的位置)看起来不错,但第二部分有几个严重的错误: for i in myArray; - 这会执行循环一次,$ i设置为“myArray”。 在这种情况下,您希望$ i迭代myArray的索引,因此您需要使用 for i in "${!myArray[@]}" 要么 for ((i=0; i<${#a[@]}; i++)) (虽然我通常更喜欢第一个,因为它适用于非连续和关联数组)。 另外,你不需要; 除非do在同一行上(在shell中, ;大部分相当于换行符,因此在行尾有一个分号是多余 ...