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

  • SEARCH
  • Home
  • 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 9027043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:39:52+00:00 2026-06-16T06:39:52+00:00

I have a polygon (square) on the Stage. When a user clicks on any

  • 0

I have a polygon (square) on the Stage. When a user clicks on any edge of the polygon, a new vertex will be created at that point, increasing the number of edges by 1.

Problem: How can you detect a click on the edge/stroke of the Polygon?

After detecting the click, how do you add a new vertex/point to the Polygon at the place it was clicked? I am guessing that if the new point is added to the end of the polygon’s points array, the polygon may overlap because it draws the polygon in a anti-clockwise manner.

jsfiddle attempt: http://jsfiddle.net/frpn7/

  • 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-06-16T06:39:54+00:00Added an answer on June 16, 2026 at 6:39 am

    Switch to “click” to capture the click on the polygon:

    poly.on('click', function(e) {
    

    Unfortunately this will also throw the click event on the inside of the polygon so you will need to create 2 polygons (1 for the inside and one for the border) if you want to have just the border be clickable, otherwise you might try not filling the polygon.

    Edit with how to do that:

    You can do that by combining two shapes together and put them in one group. The first shape will have a border and the second one with no border.

            var first_poly = new Kinetic.Polygon({
                points: [73, 192, 73, 160, 340, 23, 500, 109, 499, 139, 342, 93],
                fill: '#00D2FF',
                stroke: 'black',
                strokeWidth: 5
            });
            var second_poly = new Kinetic.Polygon({
                points: [73, 192, 73, 160, 340, 23, 500, 109, 499, 139, 342, 93],
                fill: '#00D2FF',
                stroke: 'black',
                strokeWidth: 0
            });
    
            first_poly.on("click",function(){
                alert("border clicked");
            })
            // add the shape to the layer
            layer.add(first_poly);
            layer.add(second_poly);
            stage.add(layer);
    

    Second part borrowed from: Kinetic JS – Detecting Click on Border of Shape

    The third part of re-drawing the polygon will come next. Speaking abstractly, you can always clear these polygons and simply re-draw the entire polygon again. First determine the click’s new position in the polygon point array. You can approximate it by looping over each point to determine the 2 closest points and injecting it in between them.

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

Sidebar

Related Questions

I have the code that draw a point inside a polygon. Each time I
I am trying to animate random point that i have created so they move
i have an application that shows a simple square polygon represented on a GLSurfaceView.
I have a drawingManager that allows the user to draw a polygon. When the
I have a lat/long coordinate point and I'm drawing a polygon (hexagon) around it
i have a polygon and point i use query to detect latitude longitude location
I have a square polygon with a texture (opengl es 1.1), and i need
Imagine that you have some polygon on the center of the screen (let's say
I am new to Python. I have drawn polygon and circle with fixed coordinates.
I have a polygon that I want to rotate around over 360 degrees but

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.