[Athens] Finding if a line passes through a specific pixel .

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Athens] Finding if a line passes through a specific pixel .

kilon.alios
So here we are with my first challenge.  I am making Hyperion, a vector graphics editor using Athens , so far I have a nice line with several segments, I have added nice handlers to allow me to move the points (start and end of each segment) of the line around with the mouse, but now I want each time I click on a segment itself to create a new point.This way I will create more points with the mouse and bring more detail to the shape of the line / path. 

In order to do that I will have to check that the line passes through a specific pixel. Or to be more correct that the place that mouse has clicked is where my path passes through. How I do that ? Can Athens do that ? Can athens tell me which pixels my path passes through ? 

At first I thought to return the Athens surface as a Form but the form will give me back the colors of each pixel on a specific place, but that does not guarantee  that my line / path passes through those pixels.  
Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

Dennis Schetinin
Why do you think it's a job for Athens? Shouldn't it be in a geometry lib?


--

Best regards,


Dennis Schetinin



2013/11/15 kilon alios <[hidden email]>
So here we are with my first challenge.  I am making Hyperion, a vector graphics editor using Athens , so far I have a nice line with several segments, I have added nice handlers to allow me to move the points (start and end of each segment) of the line around with the mouse, but now I want each time I click on a segment itself to create a new point.This way I will create more points with the mouse and bring more detail to the shape of the line / path. 

In order to do that I will have to check that the line passes through a specific pixel. Or to be more correct that the place that mouse has clicked is where my path passes through. How I do that ? Can Athens do that ? Can athens tell me which pixels my path passes through ? 

At first I thought to return the Athens surface as a Form but the form will give me back the colors of each pixel on a specific place, but that does not guarantee  that my line / path passes through those pixels.  

Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

kilon.alios

Libraries have no job. They have no obligations. No things they should or must do. They have methods that define what they can do.

So there is nothing stopping Athens from having such a feature. Hence my question.

But I found the formula for this, looks like i will be learning linear algebra and geometry.  Good thing I love math :D

Στις 15 Νοε 2013 6:24 π.μ., ο χρήστης "Dennis Schetinin" <[hidden email]> έγραψε:
Why do you think it's a job for Athens? Shouldn't it be in a geometry lib?


--

Best regards,


Dennis Schetinin



2013/11/15 kilon alios <[hidden email]>
So here we are with my first challenge.  I am making Hyperion, a vector graphics editor using Athens , so far I have a nice line with several segments, I have added nice handlers to allow me to move the points (start and end of each segment) of the line around with the mouse, but now I want each time I click on a segment itself to create a new point.This way I will create more points with the mouse and bring more detail to the shape of the line / path. 

In order to do that I will have to check that the line passes through a specific pixel. Or to be more correct that the place that mouse has clicked is where my path passes through. How I do that ? Can Athens do that ? Can athens tell me which pixels my path passes through ? 

At first I thought to return the Athens surface as a Form but the form will give me back the colors of each pixel on a specific place, but that does not guarantee  that my line / path passes through those pixels.  

Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

hilaire
In reply to this post by kilon.alios
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

kilon.alios
yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

Stéphane Ducasse
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu




Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

kilon.alios
would I sound too lazy to ask in which class ? 


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <[hidden email]> wrote:
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu





Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

Ben Coman
kilon alios wrote:
would I sound too lazy to ask in which class ?
  

yes. (but you usually are not lazy so you have some quota :)

I can't answer directly since Stef's post is the first I know of it,
but a few interesting things turn up when I try World > Tools > Finder searching for 'bezier' for
* Classes
* Selectors
* Source

cheers -ben


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <
[hidden email]> wrote:

  
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios [hidden email] wrote:

yes I found the formula for straight lines and I was wondering what was
the one for bezier curves, so your reply could not have come a better
moment. Thanks I will study it and implement it.


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <
[hidden email]> wrote:

    
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
      
In order to do that I will have to check that the line passes through a
specific pixel. Or to be more correct that the place that mouse has
clicked is where my path passes through. How I do that ? Can Athens do
that ? Can athens tell me which pixels my path passes through ?

        
--
Dr. Geo http://drgeo.eu



      
    

  

Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

Stéphane Ducasse
In reply to this post by kilon.alios


On Nov 23, 2013, at 11:24 AM, kilon alios <[hidden email]> wrote:

would I sound too lazy to ask in which class ? 


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <[hidden email]> wrote:
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu







Screen Shot 2013-11-23 at 2.37.51 PM.pdf (140K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

kilon.alios
aaaaaahhh come on ... I am not THAT lazy :D 

of course I have searched it before asking. Unless I am blind I see loads of bezier methods, none that detects whether a point belong to a curve. But now you mention it I think I remember squeak was able to do add points to a curve via click or something similar, because thats what I wan to do. So I will take a look at it , most probably there is a method in there that does this.

I want the user to click on a curve or line and there a new control point will be placed that will allow the user to shape the line or curve to a finer detail. A standard feature for all vector editors , 3d editors, even image editors.  

I am sorry if I miss something obvious here, its not laziness , its most likely stupidity or just the fact I am very new with this. This is the first time I try to make a vector editor.Again thank you all for trying to help me, you have done already a lot. 


On Sat, Nov 23, 2013 at 3:38 PM, Stéphane Ducasse <[hidden email]> wrote:


On Nov 23, 2013, at 11:24 AM, kilon alios <[hidden email]> wrote:

would I sound too lazy to ask in which class ? 


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <[hidden email]> wrote:
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu








Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

Igor Stasenko
There is some bits which can help you in this regard.
The part of it is path tesseleration, which turns any path with complex curves
into polygon (which has only straight lines),
from there on, i think you can easily calculate the distance between any point and that polygon.
Look at AthensCurveFlattener class, and its uses.
the entry point is (flattenPath: aPath transform: aTransformation).

But be aware that this is not fully integrated yet and subject to change in future.



On 23 November 2013 15:20, kilon alios <[hidden email]> wrote:
aaaaaahhh come on ... I am not THAT lazy :D 

of course I have searched it before asking. Unless I am blind I see loads of bezier methods, none that detects whether a point belong to a curve. But now you mention it I think I remember squeak was able to do add points to a curve via click or something similar, because thats what I wan to do. So I will take a look at it , most probably there is a method in there that does this.

I want the user to click on a curve or line and there a new control point will be placed that will allow the user to shape the line or curve to a finer detail. A standard feature for all vector editors , 3d editors, even image editors.  

I am sorry if I miss something obvious here, its not laziness , its most likely stupidity or just the fact I am very new with this. This is the first time I try to make a vector editor.Again thank you all for trying to help me, you have done already a lot. 


On Sat, Nov 23, 2013 at 3:38 PM, Stéphane Ducasse <[hidden email]> wrote:



On Nov 23, 2013, at 11:24 AM, kilon alios <[hidden email]> wrote:

would I sound too lazy to ask in which class ? 


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <[hidden email]> wrote:
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu











--
Best regards,
Igor Stasenko.
Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

Stéphane Ducasse
In reply to this post by kilon.alios
have a look at roassal because mathieu started to implement something and he realized it was already in the image.

On Nov 23, 2013, at 3:20 PM, kilon alios <[hidden email]> wrote:

aaaaaahhh come on ... I am not THAT lazy :D 

of course I have searched it before asking. Unless I am blind I see loads of bezier methods, none that detects whether a point belong to a curve. But now you mention it I think I remember squeak was able to do add points to a curve via click or something similar, because thats what I wan to do. So I will take a look at it , most probably there is a method in there that does this.

I want the user to click on a curve or line and there a new control point will be placed that will allow the user to shape the line or curve to a finer detail. A standard feature for all vector editors , 3d editors, even image editors.  

I am sorry if I miss something obvious here, its not laziness , its most likely stupidity or just the fact I am very new with this. This is the first time I try to make a vector editor.Again thank you all for trying to help me, you have done already a lot. 


On Sat, Nov 23, 2013 at 3:38 PM, Stéphane Ducasse <[hidden email]> wrote:


On Nov 23, 2013, at 11:24 AM, kilon alios <[hidden email]> wrote:

would I sound too lazy to ask in which class ? 


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <[hidden email]> wrote:
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu









Reply | Threaded
Open this post in threaded view
|

Re: [Athens] Finding if a line passes through a specific pixel .

kilon.alios
yes I am looking at Roassal and definetly it gives a good insight into Athens.

Igor you are correct from what I see from the algorithms for finding if a point passes through a curve the work in kinda similar ground. I have to confess I have not looked into it yet, cause I am trying to solve some other problems but I will definitely need this. 

Right now I try to figure out how to implement my GUI , I want to support Spec so the gui elements ( lets say a button) is rendered by Athens but also called by Spec. Also I want to make something that will easy to port once Athens becomes the main render engine of Pharo and replaces Morphic rendering. 

But I am happy to say Hyperion is moving forward, a basic vector graphics editor is coming to Pharo ;)





On Sun, Nov 24, 2013 at 11:19 AM, Stéphane Ducasse <[hidden email]> wrote:
have a look at roassal because mathieu started to implement something and he realized it was already in the image.

On Nov 23, 2013, at 3:20 PM, kilon alios <[hidden email]> wrote:

aaaaaahhh come on ... I am not THAT lazy :D 

of course I have searched it before asking. Unless I am blind I see loads of bezier methods, none that detects whether a point belong to a curve. But now you mention it I think I remember squeak was able to do add points to a curve via click or something similar, because thats what I wan to do. So I will take a look at it , most probably there is a method in there that does this.

I want the user to click on a curve or line and there a new control point will be placed that will allow the user to shape the line or curve to a finer detail. A standard feature for all vector editors , 3d editors, even image editors.  

I am sorry if I miss something obvious here, its not laziness , its most likely stupidity or just the fact I am very new with this. This is the first time I try to make a vector editor.Again thank you all for trying to help me, you have done already a lot. 


On Sat, Nov 23, 2013 at 3:38 PM, Stéphane Ducasse <[hidden email]> wrote:


On Nov 23, 2013, at 11:24 AM, kilon alios <[hidden email]> wrote:

would I sound too lazy to ask in which class ? 


On Sat, Nov 23, 2013 at 11:35 AM, Stéphane Ducasse <[hidden email]> wrote:
there are bezier algo in the system

Stef

On Nov 20, 2013, at 9:55 PM, kilon alios <[hidden email]> wrote:

yes I found the formula for straight lines and I was wondering what was the one for bezier curves, so your reply could not have come a better moment. Thanks I will study it and implement it. 


On Wed, Nov 20, 2013 at 9:21 PM, Hilaire Fernandes <[hidden email]> wrote:
Hello,

You may want to calculate the distance between the mouse position and
your path (I guess a bezier curve). Then given this distance and a
tolerance to zero you decide if the mouse position is more or less on
your path. Calculating the distance you will also get for free the place
where to add a point on your path.

http://blog.gludion.com/2009/08/distance-to-quadratic-bezier-curve.html

Hilaire


Le 14/11/2013 21:07, kilon alios a écrit :
> In order to do that I will have to check that the line passes through a
> specific pixel. Or to be more correct that the place that mouse has
> clicked is where my path passes through. How I do that ? Can Athens do
> that ? Can athens tell me which pixels my path passes through ?
>


--
Dr. Geo http://drgeo.eu