I have a Path object. When I hover the mouse over this Path I want a little "glowing" object thing to move on the lines of the Path. Like a pulse effekt or something.
No mather what, I need an "Control" (Ellipse, UserControl, what-ever) to follow a Path, is that possible and how?
Thanks in advance,
Qbus
--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net
You can use a mask to do that..You can have "glowing rectangle" pass under the whole path and it can be masked by that path. It will give the appearance that the glow is following the path. There are some examples of this on the web.
I have a Path, lets say it has 4 "points", you know like a rectagle. When I hover my mouse over it I what something to happen. This is easy, I set the MouseEnter event on my Path and that is fired when I take my mouse over it. So far so good.
When my mouse enter this Path, or "hover" over it if you want, I want a little Ellipse to move along the Path. Lets say my Path has corners A,B,C,D. I then want my Ellipse to go from A to B, then B to C etc. etc.
I think I can do this if I can find a way to retrieve all the "points" of a Path. I looked at the Path obejct yesterday, but I couldn't find any method or property to help me here...
--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net
lets talk about a sinus. The formular is y= sin(x). With that you can calculate each point in the 2d. Mouse move can input one of the parameters. You can also use eg a slider to control the movement. I have implemented that for a carousell
www.adc08.de
I think this is a very interesting problem, which
has been proposed before. Seems it's not natively supported right now. I've tried to do it by animating an object programmatically with a timer, but couldn't.
My problem lies in that I can't determine the function value of my path for a given x value (assuming my path can be described as a function). You can also think of it as detecting the intersection points of your path and a vertical line on a given x (left)
position.
This is my shot at it:
with code behind,
private DispatcherTimer _timer = new DispatcherTimer();
private List pathCoordinates;
private int _index;
public Page()
{
InitializeComponent();
_index = 0;
pathCoordinates = GetPathAsPointList(MyPath);
_timer.Interval = TimeSpan.FromMilliseconds(200);
_timer.Tick += new EventHandler(_timer_Tick);
}
void _timer_Tick(object sender, EventArgs e)
{
SomeCtrl.SetValue(Canvas.TopProperty, (double)pathCoordinates[_index].Y);
SomeCtrl.SetValue(Canvas.LeftProperty, (double)pathCoordinates[_index].X);
_index++;
}
private void btnGo_Click(object sender, RoutedEventArgs e)
{
_timer.Start();
}
private List GetPathAsPointList(Path p)
{
List discretePath = new List();
double left = p.Data.Bounds.Left;
double top = p.Data.Bounds.Top;
double pwidth = p.Data.Bounds.Width;
double pheight = p.Data.Bounds.Height;
p.StrokeThickness = 2;
for(int i = 0;ifor(int j = 0;jnew Point(left + i, top + j);
IEnumerable hits =
VisualTreeHelper.FindElementsInHostCoordinates(p1, LayoutRoot);
if(hits.Count()>0)
{
discretePath.Add(p1);
}
}
}
return discretePath;
}
but the discretePath.Add(p1) never gets invoked :(
pathanimate
(please mark as answer if this post answered your question)
WPF has a DoubleAnimationUsingPath class that is missing in Silverlight. Of all the things left out of Silverlight, especially in terms of competing with Flash, this one seems an odd omission.
The Silverlight APIs do expose the high level means of creating curves/paths using control points, but not for generating all of the points that would fall on these curves. The math for Bezier curves and such is readily available, but I have to wonder if
there are not some potential differences in interpretation? This would be an interesting exercise to attempt.
Qbus
Member
611 Points
271 Posts
Making an "Control" follow a Path?
Oct 27, 2008 10:39 PM | LINK
Hi
I have a Path object. When I hover the mouse over this Path I want a little "glowing" object thing to move on the lines of the Path. Like a pulse effekt or something.
No mather what, I need an "Control" (Ellipse, UserControl, what-ever) to follow a Path, is that possible and how?
Thanks in advance,
Qbus
Please mark the post as answered if this answers your question
http://www.laumania.net
preishuber
Contributor
3572 Points
658 Posts
Re: Making an "Control" follow a Path?
Oct 28, 2008 01:06 AM | LINK
you have to move the object by code. Best use some mouse event for that
http://www.ppedv.de
bartczernicki
Contributor
5212 Points
953 Posts
Re: Making an "Control" follow a Path?
Oct 28, 2008 02:55 AM | LINK
You can use a mask to do that..You can have "glowing rectangle" pass under the whole path and it can be masked by that path. It will give the appearance that the glow is following the path. There are some examples of this on the web.
Bart Czernicki
http://www.silverlighthack.com | My new Silverlight and Business Intelligence Book
Qbus
Member
611 Points
271 Posts
Re: Making an "Control" follow a Path?
Oct 28, 2008 10:48 AM | LINK
Ok, but to do that I need to get all the points of the current line i want my object to follow, how do i do that?
Please mark the post as answered if this answers your question
http://www.laumania.net
preishuber
Contributor
3572 Points
658 Posts
Re: Making an "Control" follow a Path?
Oct 28, 2008 01:53 PM | LINK
you can attacht the mousemove event
then you need the "formular" which describes the object
then you have to decide which is your control parameter (x or y position)
btw: i have done that not bevore in that matter
http://www.ppedv.de
Qbus
Member
611 Points
271 Posts
Re: Re: Making an "Control" follow a Path?
Oct 28, 2008 02:13 PM | LINK
I think we misunderstand each other :)
I have a Path, lets say it has 4 "points", you know like a rectagle. When I hover my mouse over it I what something to happen. This is easy, I set the MouseEnter event on my Path and that is fired when I take my mouse over it. So far so good.
When my mouse enter this Path, or "hover" over it if you want, I want a little Ellipse to move along the Path. Lets say my Path has corners A,B,C,D. I then want my Ellipse to go from A to B, then B to C etc. etc.
I think I can do this if I can find a way to retrieve all the "points" of a Path. I looked at the Path obejct yesterday, but I couldn't find any method or property to help me here...
Please mark the post as answered if this answers your question
http://www.laumania.net
preishuber
Contributor
3572 Points
658 Posts
Re: Re: Making an "Control" follow a Path?
Oct 28, 2008 03:04 PM | LINK
not really
lets talk about a sinus. The formular is y= sin(x). With that you can calculate each point in the 2d. Mouse move can input one of the parameters. You can also use eg a slider to control the movement. I have implemented that for a carousell www.adc08.de
The only open point is, how to get the formular.
http://www.ppedv.de
gabouy
Member
219 Points
45 Posts
Re: Re: Making an "Control" follow a Path?
Oct 28, 2008 04:14 PM | LINK
I think this is a very interesting problem, which has been proposed before. Seems it's not natively supported right now. I've tried to do it by animating an object programmatically with a timer, but couldn't.
My problem lies in that I can't determine the function value of my path for a given x value (assuming my path can be described as a function). You can also think of it as detecting the intersection points of your path and a vertical line on a given x (left) position.
This is my shot at it:
with code behind,
but the discretePath.Add(p1) never gets invoked :(
path animate
Gabriel
damonpayne
Member
324 Points
82 Posts
Re: Re: Making an "Control" follow a Path?
Oct 28, 2008 04:33 PM | LINK
This has been brought up before...
WPF has a DoubleAnimationUsingPath class that is missing in Silverlight. Of all the things left out of Silverlight, especially in terms of competing with Flash, this one seems an odd omission.
The Silverlight APIs do expose the high level means of creating curves/paths using control points, but not for generating all of the points that would fall on these curves. The math for Bezier curves and such is readily available, but I have to wonder if there are not some potential differences in interpretation? This would be an interesting exercise to attempt.
http://www.damonpayne.com/
Qbus
Member
611 Points
271 Posts
Re: Re: Making an "Control" follow a Path?
Oct 28, 2008 09:34 PM | LINK
Have you tried running the:
Please mark the post as answered if this answers your question
http://www.laumania.net