小编Paw*_*wan的帖子

如何用鼠标在画布上绘制箭头

最近我开始玩canvas元素.现在我可以在带有鼠标的画布上绘制线条(尽可能多).你可以在代码中看到它:http://jsfiddle.net/saipavan579/a6L3ka8p/.

var ctx = tempcanvas.getContext('2d'),
mainctx = canvas.getContext('2d'),
w = canvas.width,
h = canvas.height,
x1,
y1,
isDown = false;

tempcanvas.onmousedown = function(e) {
var pos = getPosition(e, canvas);
x1      = pos.x;
y1      = pos.y;
isDown = true;
}
tempcanvas.onmouseup = function() {
isDown = false;
mainctx.drawImage(tempcanvas, 0, 0);
ctx.clearRect(0, 0, w, h);
}
tempcanvas.onmousemove = function(e) {

if (!isDown) return;

var pos = getPosition(e, canvas);
x2      = pos.x;
y2      = pos.y;

ctx.clearRect(0, 0, w, …
Run Code Online (Sandbox Code Playgroud)

javascript html5 canvas

4
推荐指数
1
解决办法
2041
查看次数

在Java中使用递增和递减运算符的混淆

我有一个带递增和递减运算符的表达式以及一些二元运算符.

public class precedence {
   public static void main(String ar[]){
     int a=3;
     int b=4;
     System.out.println(a++ * b-- / a-- + ++b);
     System.out.println(a+","+b);
   }   
}
Run Code Online (Sandbox Code Playgroud)

第一个++ b被5替换,b将是5.

然后,由于所有剩余的术语都是修补后的版本,评估的顺序将从右到左

a--将被替换为3,a将更改为2.

b--将被替换为5,b将变为4.

a ++将被替换为2,a将变为3.

所以最后的表达式应该是2*5/3 + 5,它等于8,但输出中显示的答案是7.可以有人告诉我哪里错了.

java operator-precedence

1
推荐指数
1
解决办法
1446
查看次数

无法理解简单CUDA函数中的错误

最近我开始学习CUDA.这是我从内核打印的简单代码.

#include"cuPrintf.cu"
#include"cuPrintf.cuh"
#include<cuda.h>
#include<stdio.h>
__global__ void cuprint()
{
     cuPrintf("He he, I am printing from here");
}
main()
{
     cuprint<<<1,1>>>cuprint();
}
Run Code Online (Sandbox Code Playgroud)

cuPrintf.cucuPrintf.cuh下载并保存在我编写此程序的目录中.我收到以下错误.

cuprint.cu(11): error: expected a "("
cuprint.cu(13): error: expected a declaration
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我为什么我会收到这些错误.

cuda

0
推荐指数
1
解决办法
179
查看次数

标签 统计

canvas ×1

cuda ×1

html5 ×1

java ×1

javascript ×1

operator-precedence ×1