SlideShare a Scribd company logo
1 of 2
Download to read offline
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();
I am writing a program that will allow the user to move the crosshairs.pdf

More Related Content

Similar to I am writing a program that will allow the user to move the crosshairs.pdf

Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
contact41
 
#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf
#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf
#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf
computersmartdwarka
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbars
myrajendra
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
Conint29
 

Similar to I am writing a program that will allow the user to move the crosshairs.pdf (20)

HTML5 Canvas - Basics.pptx
HTML5 Canvas - Basics.pptxHTML5 Canvas - Basics.pptx
HTML5 Canvas - Basics.pptx
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 Canvas
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
 
#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf
#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf
#include bitsstdc++.h#include unistd.h#include GLglew.h.pdf
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbars
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Language
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Language
 
Plunge into HTML5 Canvas – Let’s begin
Plunge into HTML5 Canvas – Let’s beginPlunge into HTML5 Canvas – Let’s begin
Plunge into HTML5 Canvas – Let’s begin
 
How to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in ScilabHow to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in Scilab
 
Lhy tutorial gui(1)
Lhy tutorial gui(1)Lhy tutorial gui(1)
Lhy tutorial gui(1)
 
Advanced html5 diving into the canvas tag
Advanced html5 diving into the canvas tagAdvanced html5 diving into the canvas tag
Advanced html5 diving into the canvas tag
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
Maps
MapsMaps
Maps
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
ITT 2014 - Chris Eidhof - Practical Concurrent Programming
ITT 2014 - Chris Eidhof - Practical Concurrent ProgrammingITT 2014 - Chris Eidhof - Practical Concurrent Programming
ITT 2014 - Chris Eidhof - Practical Concurrent Programming
 
Canvas
CanvasCanvas
Canvas
 
P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218
 
SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...
SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...
SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...
 

More from shreeaadithyaacellso

In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdfIn C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
shreeaadithyaacellso
 
I got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdfI got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdf
shreeaadithyaacellso
 
I need hlep I have posted this proble 4 times have gotten no help can.pdf
I need hlep I have posted this proble 4 times have gotten no help can.pdfI need hlep I have posted this proble 4 times have gotten no help can.pdf
I need hlep I have posted this proble 4 times have gotten no help can.pdf
shreeaadithyaacellso
 

More from shreeaadithyaacellso (20)

In c++ Polymorphism is one of the hallmarks of OOP languages- What are (1).pdf
In c++ Polymorphism is one of the hallmarks of OOP languages- What are (1).pdfIn c++ Polymorphism is one of the hallmarks of OOP languages- What are (1).pdf
In c++ Polymorphism is one of the hallmarks of OOP languages- What are (1).pdf
 
In Chapter 4 of LS- there is a case of Zappos and it describes how Zap.pdf
In Chapter 4 of LS- there is a case of Zappos and it describes how Zap.pdfIn Chapter 4 of LS- there is a case of Zappos and it describes how Zap.pdf
In Chapter 4 of LS- there is a case of Zappos and it describes how Zap.pdf
 
In C++ Plz LAB- Playlist (output linked list) Given main()- complete.pdf
In C++ Plz  LAB- Playlist (output linked list) Given main()- complete.pdfIn C++ Plz  LAB- Playlist (output linked list) Given main()- complete.pdf
In C++ Plz LAB- Playlist (output linked list) Given main()- complete.pdf
 
In C Programming- not C++ Write a function which takes two formal pa.pdf
In C Programming- not C++   Write a function which takes two formal pa.pdfIn C Programming- not C++   Write a function which takes two formal pa.pdf
In C Programming- not C++ Write a function which takes two formal pa.pdf
 
In chapter 17 you learned about the big picture of circulation through.pdf
In chapter 17 you learned about the big picture of circulation through.pdfIn chapter 17 you learned about the big picture of circulation through.pdf
In chapter 17 you learned about the big picture of circulation through.pdf
 
In cell M11- enter a formula that will calculate the total amount due.pdf
In cell M11- enter a formula that will calculate the total amount due.pdfIn cell M11- enter a formula that will calculate the total amount due.pdf
In cell M11- enter a formula that will calculate the total amount due.pdf
 
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdfIn C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
 
In C++ Complete the program with the bold requirements #include #i.pdf
In C++  Complete the program with the bold requirements   #include  #i.pdfIn C++  Complete the program with the bold requirements   #include  #i.pdf
In C++ Complete the program with the bold requirements #include #i.pdf
 
I am studying for a test tomorrow in my 494 Population Biology class-.pdf
I am studying for a test tomorrow in my 494 Population Biology class-.pdfI am studying for a test tomorrow in my 494 Population Biology class-.pdf
I am studying for a test tomorrow in my 494 Population Biology class-.pdf
 
I got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdfI got the codes written down below- Basically- I am trying to implemen.pdf
I got the codes written down below- Basically- I am trying to implemen.pdf
 
I am trying to write a program that will converts a 32bit float number.pdf
I am trying to write a program that will converts a 32bit float number.pdfI am trying to write a program that will converts a 32bit float number.pdf
I am trying to write a program that will converts a 32bit float number.pdf
 
I am stuck on this question- please show the solution step by step- Re.pdf
I am stuck on this question- please show the solution step by step- Re.pdfI am stuck on this question- please show the solution step by step- Re.pdf
I am stuck on this question- please show the solution step by step- Re.pdf
 
I et X and Y he two indenendent R(3n-1-3) random variables- Calculate.pdf
I et X and Y he two indenendent R(3n-1-3) random variables- Calculate.pdfI et X and Y he two indenendent R(3n-1-3) random variables- Calculate.pdf
I et X and Y he two indenendent R(3n-1-3) random variables- Calculate.pdf
 
I am working on a coding project- and it asked me to combine five sets.pdf
I am working on a coding project- and it asked me to combine five sets.pdfI am working on a coding project- and it asked me to combine five sets.pdf
I am working on a coding project- and it asked me to combine five sets.pdf
 
I am needing to do a Point Factor Job Evaluation for a IT Company whos.pdf
I am needing to do a Point Factor Job Evaluation for a IT Company whos.pdfI am needing to do a Point Factor Job Evaluation for a IT Company whos.pdf
I am needing to do a Point Factor Job Evaluation for a IT Company whos.pdf
 
i cant figure out this excel equation For the Year Ended December 31-.pdf
i cant figure out this excel equation For the Year Ended December 31-.pdfi cant figure out this excel equation For the Year Ended December 31-.pdf
i cant figure out this excel equation For the Year Ended December 31-.pdf
 
I need simple java code for the below scenario- UML Diagrams(Class-Use.pdf
I need simple java code for the below scenario- UML Diagrams(Class-Use.pdfI need simple java code for the below scenario- UML Diagrams(Class-Use.pdf
I need simple java code for the below scenario- UML Diagrams(Class-Use.pdf
 
I need hlep I have posted this proble 4 times have gotten no help can.pdf
I need hlep I have posted this proble 4 times have gotten no help can.pdfI need hlep I have posted this proble 4 times have gotten no help can.pdf
I need hlep I have posted this proble 4 times have gotten no help can.pdf
 
I need question 1 answer in java language- question 1)Create an applic.pdf
I need question 1 answer in java language- question 1)Create an applic.pdfI need question 1 answer in java language- question 1)Create an applic.pdf
I need question 1 answer in java language- question 1)Create an applic.pdf
 
I need help with this question- Thank you! Problem -#1- (5pts) - Nutri.pdf
I need help with this question- Thank you! Problem -#1- (5pts) - Nutri.pdfI need help with this question- Thank you! Problem -#1- (5pts) - Nutri.pdf
I need help with this question- Thank you! Problem -#1- (5pts) - Nutri.pdf
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 

Recently uploaded (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

I am writing a program that will allow the user to move the crosshairs.pdf

  • 1. 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();