Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am writing a program that will allow the user to move the crosshairs with the mouse I am having trouble getting the crosshairs to

I am writing a program that will allow the user to move the crosshairs with the mouse I am having trouble getting the crosshairs to move using function moveCrosshairs(e). Can you help and explain how to do this? Thank you. Here is my code:

/*This program will allow the user to use the mouse to draw crosshairs that follow the mouse*/

let hLine; let vLine; function main(){

drawCrosshairs(); mouseMoveMethod(moveCrosshairs); } /*initializes crosshairs through center of the canvas before the user moves mouse*/ function drawCrosshairs(){

//draw horizontal line

hlLine = new Line(0,getHeight()/2,getWidth(),getHeight()/2); hLine.setColor("black"); hLine.setLineWidth(2); add(hLine);

//draw vertical line vLine = new Line(getWidth()/2,0, getWidth()/2,getHeight()); vLine.setColor("black"); vLine.setLineWidth(2); add(vLine); } function moveCrosshairs(e){ hlLine.setPosition(0,e.getY()); hLine.setEndpoint(getWidth(),e.getY(); vLine.setPosition(e.getX(),0); vLine.setPostion(e.getX(),get(Height());

}

main();

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

Evaluate the use of KPIs as part of a Balanced Scorecard.

Answered: 1 week ago