2
コードでドットの代わりに連続した行を作成する方法を理解できません。処理中のスケッチプログラムをエッチする(新しいプログラマー)
float posX; //current mouseX position
float posY; // current mouseY position
float ballSpeed = 50f; //controls speed that the stylus moves
final float OFF_SET = 250f; // allows ball to stay still if mouse is in center of window
void setup()
{
size(500, 500);
posX= width/2; // next four lines of code make the stylus start in middle
posY=width/2;
background(255); //clears background once
}
void draw()
{
drawLine(); //calls the drawLine function
moveStylus(); //calls the moveStylus function
}
void drawLine()
{
line(posX, posY, posX, posY); //draws a line starting previous to relative mouse position and ending at to current to relative mouse position
}
void moveStylus()
{
float moveX;
float moveY;
moveX = (mouseX-OFF_SET)/ballSpeed;
moveY = (mouseY-OFF_SET)/ballSpeed;
posX+= moveX;
posY+= moveY;
posX= max(width+1-width, posX); // line will never leave right side of screen
posX = min(width-1, posX); //line will never leave left side of screen
posY= max(height+1-height, posY); //line will never leave bottom of screen
posY = min(width-1, posY); // line will never leave top of screen
}
行の呼び出し(posX、posY、posX、posY)が気になるです。 「(posX、posY)で始まり(posX、posY)で終わる行を描く」という意味ですか?最後の2つの引数は最初の2つとは異なるはずです。 –