我可以获取当前的画布上下文的旋转角度吗?(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.

相关问答

更多

读取txt文件内容并存储在数组中(Reading txt file contents and storing in array)

您也可以使用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...

从txt文件中读取每个其他行并保存到数组中(Reading every other line from a txt file and saving into an array)

以下可能是一个快速而肮脏的解决方案,但将完成工作: for (soldBoxIndex = 0; soldBoxIndex < numSaleSlips; soldBoxIndex++) { if (soldBoxIndex % 2 != 0 { String soldBoxString; soldBoxString = input.readLine(); //reads in value and assigns/re-assigns ...

读取.txt文件并将值存储到Java中的double数组中(Reading in a .txt file and storing the values into a double array in Java)

使用 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 tha...

Java:如何将.txt中的值存储到数组中[关闭](Java: How to store values from .txt into array [closed])

假设您的成绩在文本文件中为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 ar...

读入并使用txt文件java(reading in and using a txt file java)

它太简单了; 在读取数据时处理数据; 阅读每个滑雪板并与最佳前值进行比较; 然后选择最佳值作为最佳值; 见下面的代码 import java.io.*; import java.util.*; public class loops { public static void main (String [] args) throws FileNotFoundException{ File myFile = new File("Snowboard_Scores.txt"); Scan...

在Java中读取(分配)txt.file值(Reading (assigning) txt.file values in Java)

请更改loadGame方法,如下所示: public static void loadGame() throws Exception { //deserialization FileReader fileReader = new FileReader(filename); BufferedReader bufferedReader = new BufferedReader(fileReader); structurePack.Board.gameBoard[0][...

从txt文件中读取ints并存储到数组中(Reading ints from a txt file and storing to an array)

您正在打印出数组的虚拟内存地址而不是实际的数组项: 您可以逐个打印出实际的数组项,如下所示: // 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....

Bash读取txt文件并存储在数组中(Bash reading txt file and storing in array)

第一部分(构建数组的位置)看起来不错,但第二部分有几个严重的错误: for i in myArray; - 这会执行循环一次,$ i设置为“myArray”。 在这种情况下,您希望$ i迭代myArray的索引,因此您需要使用 for i in "${!myArray[@]}" 要么 for ((i=0; i<${#a[@]}; i++)) (虽然我通常更喜欢第一个,因为它适用于非连续和关联数组)。 另外,你不需要; 除非do在同一行上(在shell中, ;大部分相当于换行符,因此在行尾有一个...

相关文章

更多

HTML5项目笔记3:使用Canvas设计离线系统的Logo

HTML5的CavansAPI可以动态来展示图形、图表、图像以及动画,我们的这个离线系统中,主要用来设 ...

HTML5画布(Canvas)【HTML5教程 - 第七篇】

Canvas是HTML5中的画布API,用来帮助大家在浏览器上快速的绘制图形图像。HTML5 canv ...

[译文] 恶意软件行为综述 - A View on Current Malware Behaviors

A View on Current Malware Behaviors Ulrich Bayer ...

HTML5 Canvas 图像动画的实现

内容摘要:Canvas 中 clearRect 清除函数;setInterval与clearInter ...

《Java 2 图形设计卷I:AWT》(Graphic Java 1.2 Mastering the JFC Volume I:AWT )扫描版[PDF]

中文名: Java 2 图形设计卷I:AWT 原名: Graphic Java 1.2 Mast ...

HTML5 Canvas 画图标签、画线、圆、渐变色

内容摘要:Canvas标签定义,并获得坐标;画矩形,定义颜色,透明度;画直线,定义连接,节点;画圆,定 ...

HTML5-canvas画布坐标体系_HTML5网页游戏坦克大战04

坐标体系-介绍:canvas 画布坐标系。坐标原点位于左上角,以像素为单位。像素是计算机屏幕上最小的显 ...

HTML5项目笔记9:HTML5 Canvas 的图表报表开发

我们前面所涉及的离线数据库、离线文件的操作,会话机制的控制,以及客户端跨域数据同步、与服务端的交互,都 ...

最新问答

更多

python的访问器方法有哪些

使用方法: class A(object): def foo(self,x): #类实例方法 print "executing foo(%s,%s)"%(self,x) @classmethod def class_foo(cls,x): #类方法 print "executing class_foo(%s,%s)"%(cls,x) @staticmethod def static_foo(x): #静态方法 print "executing static_foo(%s)"%x调用方法: a =

使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)

我认为你必须将两个TableGetway传递给UserTable构造。 你必须改变Module.php看看: public function getServiceConfig() { return array( 'factories' => array( 'User\Model\UserTable' => function($sm) { $userTableGateway = $sm->get('UserTable

透明度错误IE11(Transparency bug IE11)

这是一个渲染错误,由使用透明度触发,使用bootstrap用于在聚焦控件周围放置蓝色光环的box-shadow属性。 可以通过添加以下类覆盖来解决它。 .form-control:hover { -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,255,1); box-shadow: 0px 0px 4px 0px rgba(0,0,255,1)

linux的基本操作命令。。。

ls 显示目录 mkdir 建立目录 cd 进入目录

响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)

将z-index设置为.main-nav这将解决您的重叠问题 .main-nav { position:relative; z-index:9; } set z-index to .main-nav This will fix your overlaping issue .main-nav { position:relative; z-index:9; }

在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)

这是因为模式规范"a"打开一个文件以便追加,文件指针在末尾。 如果您尝试从此处读取,则由于文件指针位于EOF,因此没有数据。 您应该打开"r+"进行阅读和写作。 如果在写入之前读取整个文件,则在写入更多数据时,文件指针将正确定位以追加。 如果这还不够,请探索ftell()和fseek()函数。 That is because the mode spec "a" opens a file for appending, with the file pointer at the end. If you

NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)

支持空中接口的数据速率是一回事。 在消除协议开销,等待eeprom写入以及所有需要时间的其他内容之后,您看到的数据速率是完全不同的故事。 长话短说,从标签读取或进行对等传输时的实际数据速率峰值约为2.5千字节/秒。 取决于具体的标签或对等技术,它可能比这慢很多。 The supported data-rates of the air-interface are one thing. The data-rate that you see after removing protocol overhe

元素上的盒子阴影行为(box-shadow behaviour on elements)

它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂

Laravel检查是否存在记录(Laravel Checking If a Record Exists)

这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found

设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)

$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640