Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:25:39+00:00 2026-05-26T13:25:39+00:00

An example here . var context=document.getElementById(canvas).getContext(2d); //Red Box context.beginPath(); context.fillStyle=Red; context.rect(10,10,50,50); context.fill(); //Pink circle

  • 0

An example here.

var context=document.getElementById("canvas").getContext("2d");

//Red Box
context.beginPath();
context.fillStyle="Red";
context.rect(10,10,50,50);
context.fill();

//Pink circle
context.beginPath();
context.lineWidth="3";
context.fillStyle="Pink";
context.arc(250,250,50,0,Math.PI*2,false);
context.fill();
context.stroke();

context.font="1.2em Verdana";
context.fillStyle="Black";
context.fillText(context.isPointInPath(35,35),35,35);
context.fillText(context.isPointInPath(250,250),250,250);

If you write without beginPath all objects detected.
How to identify objects on the canvas or to omit beginPath?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:25:40+00:00Added an answer on May 26, 2026 at 1:25 pm

    If you want to use that function you need to rebuild the path every time you want to do the test (just don’t call fill or stroke).

    What I do normally instead is using my own point-in-polygon test function or my own spatial data structure if there are a lot of objects and speed is important.

    Note that a canvas is just a bitmap and it doesn’t store the commands you use to draw on it. That is why it cannot do the check after drawing a shape and you can test only the current path.

    Once you call beginPath the previous path geometry is discarded and what you have are only the affected pixels if you called fill or stroke.

    May be for your case it may make sense to check the color of the canvas pixel…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, here is a string representing an expression: var str = 'total =
I am trying to load a bitmap into the canvas following the example here.
Here is my html: <canvas id=test width=400 height=200></canvas> here is my javascript: var canvas_one
The fictional example here. Suppose I designed a class named IODevice. This class already
I found a great C++/ODBC example here ... The project I downloaded builds great
This problem is not readily reproducible in a simple example here but was wondering
OK, probably best to give an example here of what I mean. Imagine a
What does this do? I find the example here, but other than what it
I would like to translate or 301-redirect urls such as: www.domain.com/example.html to www.domain.com/example Here
My example is here The logos look fine when told to align right or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.