如何调用mousemoved的paintcanvas函数INSIDE [英] How do I call the paintcanvas function INSIDE of mousemoved

查看:43
本文介绍了如何调用mousemoved的paintcanvas函数INSIDE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置新属性值后,请务必调用mouseMoved()的paintCanvas函数INSIDE,以便在新位置的画布上绘制图像!移动鼠标以检查它是否有效。

(报告问题)



??

1

2

3

4

5

$

7

8

9

10

11

12 br / >
13

14

15

16

$

18

19

20

var paintBrush = {

x:150,

y :250,

img:getImage(avatars / piceratops-ultimate)

};

var mouseMoved = function(){

paintBrush.x = mouseX;

paintBrush.y = mouseY;

};

var paintCanvas = function() {

imageMode(CENTER);

image(paintBrush.img,paintBrush.x,paintBrush.y);

};

paintCanvas();



我尝试过:



i现在尝试了很多东西,但我现在还不知道

解决方案

var paintBrush = {

x:0,

y:0,

img:getImage(avatars / piceratops-ultimate)

};

var mouseMoved = function(){

paintBrush.x = mouseX;

paintBrush.y = mouseY ;

paintCanvas();

};

var paintCanvas = function(){

imageMode(CENTER) ;

image(paintBrush.img,paintBrush.x,paintBrush.y);

};


After you set the new property values, make sure to call the paintCanvas function INSIDE of mouseMoved() so that the image is painted on the canvas at the new location! Move your mouse to check it works.
(Report a problem)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var paintBrush = {
x: 150,
y: 250,
img: getImage("avatars/piceratops-ultimate")
};
var mouseMoved = function () {
paintBrush.x = mouseX;
paintBrush.y = mouseY;
};
var paintCanvas = function() {
imageMode(CENTER);
image(paintBrush.img, paintBrush.x, paintBrush.y);
};
paintCanvas();

What I have tried:

i have try lots of stuff for now but i still don t now

解决方案

var paintBrush = {
x: 0,
y: 0,
img: getImage("avatars/piceratops-ultimate")
};
var mouseMoved = function () {
paintBrush.x = mouseX;
paintBrush.y = mouseY;
paintCanvas();
};
var paintCanvas = function() {
imageMode(CENTER);
image(paintBrush.img, paintBrush.x, paintBrush.y);
};


这篇关于如何调用mousemoved的paintcanvas函数INSIDE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆