Search Results

Search found 127 results on 6 pages for 'ellipse'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • Mise en oeuvre de composants web via le framework Ellipse, par l'équipe Ellipse

    L'objectif de ce nouveau tutoriel est de vous montrer comment créer des composants web réutilisables via le framework Ellipse. Deux types de composants web peuvent être envisagés : un composant web définit dans une simple classe Java, ou bien un composant web à base d'un modèle XML (TemplatedComponent) afin d'y stocker la mise en page pour le rendu HTML. Bien entendu, nous allons utiliser le plugin Ellipse afin de nous simplifier la construction de ces éléments. Ce tutoriel est accessible à partir de l'adresse suivante : http://ellipse.developpez.com/tutori...s-web-ellipse/ Si vous avez des commentaires ou des questions, n'hésitez pas à compléter cette discussion.

    Read the article

  • Scaled ellipse over button, button not clickable

    - by user336720
    Hi, I'm scaling an ellipse in an animation with the following code: ScaleTransform myScTransform = new ScaleTransform(); TransformGroup myTransGroup = new TransformGroup(); myTransGroup.Children.Add(myScTransform); newPHRadio.RenderTransform = myTransGroup; newPHRadio.RenderTransformOrigin = new Point(0.5, 0.5); Storyboard story = new Storyboard(); DoubleAnimation xAnimation = new DoubleAnimation(1, ph.Bereik, new Duration(TimeSpan.FromSeconds(2))); DoubleAnimation yAnimation = new DoubleAnimation(1, ph.Bereik, new Duration(TimeSpan.FromSeconds(2))); DoubleAnimation doorzichtig = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(2))); Storyboard.SetTarget(xAnimation, newPHRadio); Storyboard.SetTarget(yAnimation, newPHRadio); Storyboard.SetTarget(doorzichtig, newPHRadio); DependencyProperty[] propertyChainX = new DependencyProperty[] { Ellipse.RenderTransformProperty, TransformGroup.ChildrenProperty, ScaleTransform.ScaleXProperty }; DependencyProperty[] propertyChainY = new DependencyProperty[] { Ellipse.RenderTransformProperty, TransformGroup.ChildrenProperty, ScaleTransform.ScaleYProperty }; string thePath = "(0).(1)[0].(2)"; Storyboard.SetTargetProperty(xAnimation, new PropertyPath(thePath, propertyChainX)); Storyboard.SetTargetProperty(yAnimation, new PropertyPath(thePath, propertyChainY)); Storyboard.SetTargetProperty(doorzichtig, new PropertyPath(Ellipse.OpacityProperty)); story.Children.Add(xAnimation); story.Children.Add(yAnimation); story.Children.Add(doorzichtig); story.Duration = new Duration(TimeSpan.FromSeconds(60 / ph.Frequentie)); story.RepeatBehavior = RepeatBehavior.Forever; story.Begin(); The ellipse is constructed with the following code: Ellipse newPHRadio = new Ellipse(); newPHRadio.Width = 1; newPHRadio.Height = 1; newPHRadio.SetValue(Canvas.LeftProperty, ph.xPositie + 7); newPHRadio.SetValue(Canvas.TopProperty, ph.yPositie + 7); newPHRadio.SetValue(Canvas.ZIndexProperty, 3); newPHRadio.Stroke = new SolidColorBrush(Colors.Black); newPHRadio.StrokeThickness = 0.03; Now the ellipse is scaled over an button which has a z-index of 1. With a static ellipse and no fill, the button is clickable. Now there is no fill as well but the button is not clickable. Can someone tell me how to fix this?

    Read the article

  • WPF Binding to change fill color of ellipse

    - by user294382
    Probably a simple question but: How do I programmatically change the color of an ellipse that is defined in XAML based on a variable? Everything I've read on binding is based on collections and lists -can't I set it simply (and literally) based on the value of a string variable? string color = "red" color = "#FF0000"

    Read the article

  • fit a ellipse in Python given a set of points xi=(xi,yi)

    - by Gianni
    I am computing a series of index from a 2D points (x,y). One index is the ratio between minor and major axis. To fit the ellipse i am using the following post when i run these function the final results looks strange because the center and the axis length are not in scale with the 2D points center = [ 560415.53298363+0.j 6368878.84576771+0.j] angle of rotation = (-0.0528033467597-5.55111512313e-17j) axes = [0.00000000-557.21553487j 6817.76933256 +0.j] thanks in advance for help import numpy as np from numpy.linalg import eig, inv def fitEllipse(x,y): x = x[:,np.newaxis] y = y[:,np.newaxis] D = np.hstack((x*x, x*y, y*y, x, y, np.ones_like(x))) S = np.dot(D.T,D) C = np.zeros([6,6]) C[0,2] = C[2,0] = 2; C[1,1] = -1 E, V = eig(np.dot(inv(S), C)) n = np.argmax(np.abs(E)) a = V[:,n] return a def ellipse_center(a): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] num = b*b-a*c x0=(c*d-b*f)/num y0=(a*f-b*d)/num return np.array([x0,y0]) def ellipse_angle_of_rotation( a ): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] return 0.5*np.arctan(2*b/(a-c)) def ellipse_axis_length( a ): b,c,d,f,g,a = a[1]/2, a[2], a[3]/2, a[4]/2, a[5], a[0] up = 2*(a*f*f+c*d*d+g*b*b-2*b*d*f-a*c*g) down1=(b*b-a*c)*( (c-a)*np.sqrt(1+4*b*b/((a-c)*(a-c)))-(c+a)) down2=(b*b-a*c)*( (a-c)*np.sqrt(1+4*b*b/((a-c)*(a-c)))-(c+a)) res1=np.sqrt(up/down1) res2=np.sqrt(up/down2) return np.array([res1, res2]) if __name__ == '__main__': points = [(560036.4495758876, 6362071.890493258), (560036.4495758876, 6362070.890493258), (560036.9495758876, 6362070.890493258), (560036.9495758876, 6362070.390493258), (560037.4495758876, 6362070.390493258), (560037.4495758876, 6362064.890493258), (560036.4495758876, 6362064.890493258), (560036.4495758876, 6362063.390493258), (560035.4495758876, 6362063.390493258), (560035.4495758876, 6362062.390493258), (560034.9495758876, 6362062.390493258), (560034.9495758876, 6362061.390493258), (560032.9495758876, 6362061.390493258), (560032.9495758876, 6362061.890493258), (560030.4495758876, 6362061.890493258), (560030.4495758876, 6362061.390493258), (560029.9495758876, 6362061.390493258), (560029.9495758876, 6362060.390493258), (560029.4495758876, 6362060.390493258), (560029.4495758876, 6362059.890493258), (560028.9495758876, 6362059.890493258), (560028.9495758876, 6362059.390493258), (560028.4495758876, 6362059.390493258), (560028.4495758876, 6362058.890493258), (560027.4495758876, 6362058.890493258), (560027.4495758876, 6362058.390493258), (560026.9495758876, 6362058.390493258), (560026.9495758876, 6362057.890493258), (560025.4495758876, 6362057.890493258), (560025.4495758876, 6362057.390493258), (560023.4495758876, 6362057.390493258), (560023.4495758876, 6362060.390493258), (560023.9495758876, 6362060.390493258), (560023.9495758876, 6362061.890493258), (560024.4495758876, 6362061.890493258), (560024.4495758876, 6362063.390493258), (560024.9495758876, 6362063.390493258), (560024.9495758876, 6362064.390493258), (560025.4495758876, 6362064.390493258), (560025.4495758876, 6362065.390493258), (560025.9495758876, 6362065.390493258), (560025.9495758876, 6362065.890493258), (560026.4495758876, 6362065.890493258), (560026.4495758876, 6362066.890493258), (560026.9495758876, 6362066.890493258), (560026.9495758876, 6362068.390493258), (560027.4495758876, 6362068.390493258), (560027.4495758876, 6362068.890493258), (560027.9495758876, 6362068.890493258), (560027.9495758876, 6362069.390493258), (560028.4495758876, 6362069.390493258), (560028.4495758876, 6362069.890493258), (560033.4495758876, 6362069.890493258), (560033.4495758876, 6362070.390493258), (560033.9495758876, 6362070.390493258), (560033.9495758876, 6362070.890493258), (560034.4495758876, 6362070.890493258), (560034.4495758876, 6362071.390493258), (560034.9495758876, 6362071.390493258), (560034.9495758876, 6362071.890493258), (560036.4495758876, 6362071.890493258)] a_points = np.array(points) x = a_points[:, 0] y = a_points[:, 1] from pylab import * plot(x,y) show() a = fitEllipse(x,y) center = ellipse_center(a) phi = ellipse_angle_of_rotation(a) axes = ellipse_axis_length(a) print "center = ", center print "angle of rotation = ", phi print "axes = ", axes from pylab import * plot(x,y) plot(center[0:1],center[1:], color = 'red') show() each vertex is a xi,y,i point plot of 2D point and center of fit ellipse

    Read the article

  • How do I draw an ellipse with arbitrary orientation pixel by pixel?

    - by amc
    Hi, I have to draw an ellipse of arbitrary size and orientation pixel by pixel. It seems pretty easy to draw an ellipse whose major and minor axes align with the x and y axes, but rotating the ellipse by an arbitrary angle seems trickier. Initially I though it might work to draw the unrotated ellipse and apply a rotation matrix to each point, but it seems as though that could cause errors do to rounding, and I need rather high precision. Is my suspicion about this method correct? How could I accomplish this task more precisely? I'm programming in C++ (although that shouldn't really matter since this is a more algorithm-oriented question).

    Read the article

  • Axis-Aligned Bounding Boxes vs Bounding Ellipse

    - by Griffin
    Why is it that most, if not all collision detection algorithms today require each body to have an AABB for the use in the broad phase only? It seems to me like simply placing a circle at the body's centroid, and extending the radius to where the circle encompasses the entire body would be optimal. This would not need to be updated after the body rotates and broad overlap-calculation would be faster to. Correct? Bonus: Would a bounding ellipse be practical for broad phase calculations also, since it would better represent long, skinny shapes? Or would it require extensive calculations, defeating the purpose of broad-phase?

    Read the article

  • Why function Ellipse(...) are needed twice here to draw an ellipse?

    - by John Son
    MFC: I read this code which is to draw an ellipse (not solid interior), but I cannot understand why function "pDC-Ellipse(...)" is needed twice here? CDC *pDC=GetDC(); CPen pen; CBrush brush; getpen(pen,pDC,col,bol); if(do_what>=DRAW_LINE&&do_what<=DRAW_RRECT){ p->p[0]=start; p->p[1]=end; if(sol==1){ getbrush(brush,pDC,col); } if(do_what==DRAW_LINE){ pDC->MoveTo(start); pDC->LineTo(end); } else if(do_what==DRAW_ELLIPSE||do_what==DRAW_CIRCLE){ pDC->SetROP2(R2_NOT); assist=start; if(do_what==DRAW_CIRCLE){ assist.y=end.y-end.x+start.x; } pDC->Ellipse(start.x,assist.y,end.x,end.y); pDC->SetROP2(R2_COPYPEN); if(sol==0){ pDC->SelectStockObject(NULL_BRUSH); } if(do_what==DRAW_CIRCLE){ assist.y=point.y-point.x+start.x; } pDC->Ellipse(start.x,assist.y,point.x,point.y); end=point; } } If I remove the first one, the ellipse will be black solid inside. If I remove the second one, the ellipse will never be drawn but disappears when left mouse button is up. the dialog: when moving mouse: mouse moving when mouse button pops: mouse button pops Besides, what color of CBrush is if I use "CBrush brush; pDC-Ellipse(start.x,assist.y,end.x,end.y);"

    Read the article

  • How can a data ellipse be superimposed on a ggplot2 scatterplot?

    - by Radu
    Hi, I have an R function which produces 95% confidence ellipses for scatterplots. The output looks like this, having a default of 50 points for each ellipse (50 rows): [,1] [,2] [1,] 0.097733810 0.044957994 [2,] 0.084433494 0.050337990 [3,] 0.069746783 0.054891438 I would like to superimpose a number of such ellipses for each level of a factor called 'site' on a ggplot2 scatterplot, produced from this command: > plat1 <- ggplot(mapping=aes(shape=site, size=geom), shape=factor(site)); plat1 + geom_point(aes(x=PC1.1,y=PC2.1)) This is run on a dataset, called dflat which looks like this: site geom PC1.1 PC2.1 PC3.1 PC1.2 PC2.2 1 Buhlen 1259.5649 -0.0387975838 -0.022889782 0.01355317 0.008705276 0.02441577 2 Buhlen 653.6607 -0.0009398704 -0.013076251 0.02898955 -0.001345149 0.03133990 The result is fine, but when I try to add the ellipse (let's say for this one site, called "Buhlen"): > plat1 + geom_point(aes(x=PC1.1,y=PC2.1)) + geom_path(data=subset(dflat, site="Buhlen"),mapping=aes(x=ELLI(PC1.1,PC2.1)[,1],y=ELLI(PC1.1,PC2.1)[,2])) I get an error message: "Error in data.frame(x = c(0.0977338099339815, 0.0844334944904515, 0.0697467834016782, : arguments imply differing number of rows: 50, 211 I've managed to fix this in the past, but I cannot remember how. It seems that geom_path is relying on the same points rather than plotting new ones. Any help would be appreciated.

    Read the article

  • How to detect if an ellipse intersects(collides with) a circle

    - by php html
    I want to improve a collision system. Right now I detect if 2 irregular objects collide if their bounding rectangles collide. I want to obtain the for rectangle the corresponding ellipse while for the other one to use a circle. I found a method to obtain the ellipse coordinates but I have a problem when I try to detect if it intersects the circle. Do you know a algorithm to test if a circle intersects an ellipse?

    Read the article

  • finding a point on an ellipse circumference which is inside a rectangle having center point, height

    - by Shlomi Assaf
    Hi all. I have a rectangle in .NET in which I draw an ellipse. I know the width, height and center point of that rectangle. Ofcourse the cetner point of the rectangle is also the center point of the ellipse. I know how to calculate a point on a circle, however I have no clue about an ellipse. I have those parameters and an angle, i need the point on the ellipse, can someone post the formula? I saw somewhere you need to calculate 2 points in which 2 raduises will go, the sum of the radiuses will be fixed and they will change in size accordingly. I dont know how to do that, I only have the rectange height, width and center point and ofcourse the angle I wish to find the point at. thanks for any help Shlomi

    Read the article

  • Animated Ellipse

    - by user287798
    Hi, i need someone to help me. I need a xaml with animated ellipses like the ones shown here:http://www.telerik.com/products/silverlight/chart.aspx They are to act as hotspot indicators on my map. What i have below is a xaml that i was trying to do but the circles don't center and have no fed-in/fade-out effect. May somebody help me please. Thanks Sam 1 <UserControl 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 x:Class="SilverlightApplication3.MainPage" 5 Width="640" Height="480"> 6 7 8 <Canvas> 9 10 <Canvas.Triggers> 11 <EventTrigger RoutedEvent="Canvas.Loaded"> 12 <EventTrigger.Actions> 13 <BeginStoryboard> 14 <Storyboard > 15 <DoubleAnimation RepeatBehavior="Forever" 16 Storyboard.TargetName="Pt1" 17 Storyboard.TargetProperty="ScaleX" 18 From="1" 19 To="0.3" 20 Duration="0:0:5" /> 21 </Storyboard> 22 </BeginStoryboard> 23 24 <BeginStoryboard> 25 <Storyboard> 26 <DoubleAnimation RepeatBehavior="Forever" 27 Storyboard.TargetName="Pt1" 28 Storyboard.TargetProperty="ScaleY" 29 From="1" 30 To="0.3" 31 Duration="0:0:5" /> 32 </Storyboard> 33 </BeginStoryboard> 34 <!--<BeginStoryboard> 35 <Storyboard > 36 <DoubleAnimation RepeatBehavior="Forever" 37 Storyboard.TargetName="rect_Copy" 38 Storyboard.TargetProperty="Width" 39 From="30" 40 To="100" 41 Duration="0:0:5" /> 42 </Storyboard> 43 </BeginStoryboard> 44 45 <BeginStoryboard> 46 <Storyboard> 47 <DoubleAnimation RepeatBehavior="Forever" 48 Storyboard.TargetName="rect_Copy" 49 Storyboard.TargetProperty="Height" 50 From="30" 51 To="100" 52 Duration="0:0:5" /> 53 </Storyboard> 54 </BeginStoryboard>--> 55 </EventTrigger.Actions> 56 </EventTrigger> 57 </Canvas.Triggers> 58 59 60 <Ellipse x:Name="rect" Stroke="Green" Width="100" Height="100" Canvas.Left="30" 61 Canvas.Top="29"> 62 <Ellipse.RenderTransform> 63 <ScaleTransform x:Name="Pt1" ScaleX="1" ScaleY="1"/> 64 </Ellipse.RenderTransform> 65 66 </Ellipse> 67 <Ellipse x:Name="rect_Copy" 68 Stroke="Green" 69 Width="30" 70 Height="30" 71 Canvas.Left="65" 72 Canvas.Top="64"/> 73 74 </Canvas> 75 </UserControl>

    Read the article

  • How do I position an ellipse on a Silverlight Grid?

    - by daviddennisei
    I am creating a silverlight application which will allow you to click at two places on the screen and will draw an ellipse whose major axis starts and ends at the click locations. The clickable area is a Silverlight Grid control. Currently: When you first click, I am: Dropping a marker at the click point. Creating an ellipse and parenting it to the Grid. Creating and setting an AngleTransform on the ellipse. As you move the mouse, I am: Calculating the distance to the first click point. Setting the Width of the ellipse to this length. Calculating the angle of a line to the click point and the Grid's X-Axis. Setting the Ellipse's AngleTransform Angle to this angle. So far, so good. The ellipse is displayed, and its length and angle of rotation follow the mouse as it moves. However, the major axis of the ellipse is offset from the click point. How do I position the Ellipse so its major axis starts at the click point and ends at the current mouse position?

    Read the article

  • draw ellipse in MFC C++ just use OPENGL?

    - by taki
    i trying to draw ellipse in MFC C++ just use OPENGL. it ran for the resulting ellipse but it is not correct mouse coordinates. My code: in class Ellispe.cpp void VeEllispe::putPixel(int x,int y,int xc, int yc) { glBegin(GL_POINTS);// bat dau bang ve diem glVertex2i(xc+x,yc+y); glVertex2i(xc-x,yc-y); glVertex2i(xc+x,yc-y); glVertex2i(xc-x,yc+y); glEnd(); } void VeEllispe::Draw(int a, int b,int xc,int yc) { int x = 0; int y = b; float a2 = (a*a); float b2 = (b*b); float p = b2 - a2*b + 0.25*a2; while(2*b2*x <= 2*y*a2) { putPixel(x,y,xc,yc); if (p < 0) p+= 2*b2*x + 3*b2; else { p+= 2*b2*x + 3*b2 - 2*a2*y + 2*a2; y--; } x++; } x = a; y = 0; p = a2 - b2*a + 0.25*b2; while(2*a2*y <= 2*x*b2) { putPixel(x,y,xc, yc); if (p < 0) p+= 2*a2*y + 3*a2; else { p+= 2*a2*y + 3*a2 - 2*b2*x + 2*b2; x--; } y++; } } in class XYZView.cpp . . VeEllispe e; void Cbaitap1View::OnDraw(CDC* /*pDC*/) { Cbaitap1Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; wglMakeCurrent(m_hDC,m_hRC); glClear(GL_COLOR_BUFFER_BIT); glClearColor(1.0,1.0,1.0,0.0); glColor3f(0.0,0.0,1.0); glPointSize(2); if (state==4) e.Draw(X2,Y2,X1,Y1); glFlush(); SwapBuffers(::GetDC(GetSafeHwnd())); wglMakeCurrent(NULL,NULL); } And if possible, can you teach me the document to drawing triangles or parapol use OPENGL?

    Read the article

  • What's the best way to structure this Linq-to-Events Drag & Drop code?

    - by Rob Fonseca-Ensor
    I am trying to handle a drag & drop interaction, which involves mouse down, mouse move, and mouse up. Here is a simplified repro of my solution that: on mouse down, creates an ellipse and adds it to a canvas on mouse move, repositions the ellipse to follow the mouse on mouse up, changes the colour of the canvas so that it's obvious which one you're dragging. var mouseDown = Observable.FromEvent<MouseButtonEventArgs>(canvas, "MouseLeftButtonDown"); var mouseUp = Observable.FromEvent<MouseButtonEventArgs>(canvas, "MouseLeftButtonUp"); var mouseMove = Observable.FromEvent<MouseEventArgs>(canvas, "MouseMove"); Ellipse ellipse = null; var q = from start in mouseDown.Do(x => { // handle mousedown by creating a red ellipse, // adding it to the canvas at the right position ellipse = new Ellipse() { Width = 10, Height = 10, Fill = Brushes.Red }; Point position = x.EventArgs.GetPosition(canvas); Canvas.SetLeft(ellipse, position.X); Canvas.SetTop(ellipse, position.Y); canvas.Children.Add(ellipse); }) from delta in mouseMove.Until(mouseUp.Do(x => { // handle mouse up by making the ellipse green ellipse.Fill = Brushes.Green; })) select delta; q.Subscribe(x => { // handle mouse move by repositioning ellipse Point position = x.EventArgs.GetPosition(canvas); Canvas.SetLeft(ellipse, position.X); Canvas.SetTop(ellipse, position.Y); }); the XAML is simply <Canvas x:Name="canvas"/> There's a few things I don't like about this code, and I need help refactoring it :) First of all: the mousedown and mouseup callbacks are specified as side effects. If two subscriptions are made to q, they will happen twice. Second, the mouseup callback is specified before the mousemove callback. This makes it a bit hard to read. Thirdly, the reference to the ellipse seems to be in a silly place. If there's two subscriptions, that variable reference will get overwritten quite quickly. I'm sure that there should be some way we can leverage the let keyword to introduce a variable to the linq expression that will mean the correct ellipse reference is available to both the mouse move and mouse up handlers How would you write this code?

    Read the article

  • How to Find Intersections with Ellipses in PGF/TikZ

    - by infblnpf
    Hello, I am trying to display a sphere in PGF/TikZ to illustrate the idea of great circles. The code for my current result is: \begin{tikzpicture} \tikzfading[name=fade right, left color=transparent!20, right color=transparent!90] \tikzfading[name=fade out, inner color=transparent!100, outer color=transparent!10] \tikzfading[name=fade right gc, left color=transparent!0, right color=transparent!70] \draw [<->, dashed] (0,-5) -- (0,5); % y-axis \draw [->, dashed] (0, 0) -- (20:5); % x-axis \draw [->, dashed] (0, 0) -- (200:5); % x-axis \draw [->, dashed] (0, 0) -- (340:5); % z-axis \draw [->, dashed] (0, 0) -- (160:5); % z-axis \fill [color=cyan, opacity=0.15, path fading=fade out] (0,0) circle (4cm); % bounding circle \fill [color=cyan, opacity=0.25, path fading=fade right, fading angle=90] (0,0) ellipse (4cm and 1cm); % x-y-axis area % great circle 1 \draw [rotate=-40, color=red, path fading=fade right gc, fading angle=40] (0,0) ellipse (4cm and 1cm); % great circle 2 \draw[rotate=5, color=red, path fading=fade right gc, fading angle=5] (0,0) ellipse (1.5cm and 4cm); \end{tikzpicture} How do I find the two points of intersection of the two red ellipses (commented as great circle 1 and 2), find the point of intersection of a line (originating at the center (0,0)) with a ellipse, and place a little circle or rectangle there? Placing a little circle or rectangle there is not an issue. Thank you very much!

    Read the article

  • Ellipse Drawing WPF Animation

    - by widmayer
    I am developing a control that is a rectangle area and will draw an ellipse in the rectangle area when a trigger occurs. This control will be able to host other controls like, textbox's, buttons, etc. so the circle will be drawn around them when triggered. I want the circle being drawn as an animation like you were circling the inner controls with a pen. My question is whats the best way to accomplish this. I've been doing some research and I could use WPF animation or I could use GDI+ to accomplish the tasks. I am new to WPF animation so that is why I am asking the question.

    Read the article

  • How do I make an ellipse blink?

    - by MedicineMan
    I am trying to make a custom control in WPF. I want it to simulate the behavior of a LED that can blink. There are three states to the control: On, Off, and Blinking. I know how to set On and Off through the code behind, but this WPF animation stuff is just driving me nuts!!!! I cannot get anything to animate whatsoever. The plan is to have a property called state. When the user sets the value to blinking, I want the control to alternate between green and grey. I'm assuming I need a dependency property here, but have no idea. I had more xaml before but just erased it all. it doesn't seem to do anything. I'd love to do this in the most best practice way possible, but at this point, I'll take anything. I'm half way to writing a thread that changes the color manually at this point. <UserControl x:Class="WpfAnimation.LED" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300"> <Grid> <Ellipse x:Name="MyLight" Height="Auto" Width="Auto"/> </Grid> </UserControl>

    Read the article

  • How to refresh/redraw the screen (not the program window)

    - by mohrphium
    I'm having a bit of a hard time figuring out, how to remove a drawn ellipse after it has been drawn somewhere else. I need a circle to follow my mouse all the time and this is all the program should do. I get the mousepositions and draw my circle but how can I remove the last one? #include <Windows.h> #include <iostream> void drawRect(int a1, int a2){ HDC screenDC = ::GetDC(0); //Draw circle at mouse position ::Ellipse(screenDC, a1, a2+5, a1+9, a2+14); ::ReleaseDC(0, screenDC); //::InvalidateRect(0, NULL, TRUE); //<- I tried that but then everything flickers //Also, the refresh rate is not fast enough... still some circles left } int main(void) { int a1; int a2; bool exit=false; while (exit!=true) { POINT cursorPos; GetCursorPos(&cursorPos); float x = 0; x = cursorPos.x; float y = 0; y = cursorPos.y; a1=(int)cursorPos.x; a2=(int)cursorPos.y; drawRect(a1, a2); } } I am working with graphics and all that stuff for the first time. Im kinda stuck here... once again. Thanks.

    Read the article

  • android ellipsize multiline textview

    - by Arutha
    I need to ellipsize multiligne textview. My component is large enough to display at least 4 lines with the ellipse, but only 2 lines are displayed. I tried to change the minimum and maximum number of rows in the component but it changes nothing

    Read the article

  • How to parametrize WPF Style?

    - by Konstantin
    Hi! I'm looking for a simplest way to remove duplication in my WPF code. Code below is a simple traffic light with 3 lights - Red, Amber, Green. It is bound to a ViewModel that has one enum property State taking one of those 3 values. Code declaring 3 ellipses is very duplicative. Now I want to add animation so that each light fades in and out - styles will become even bigger and duplication will worsen. Is it possible to parametrize style with State and Color arguments so that I can have a single style in resources describing behavior of a light and then use it 3 times - for 'Red', 'Amber' and 'Green' lights? <UserControl.Resources> <l:TrafficLightViewModel x:Key="ViewModel" /> </UserControl.Resources> <StackPanel Orientation="Vertical" DataContext="{StaticResource ViewModel}"> <StackPanel.Resources> <Style x:Key="singleLightStyle" TargetType="{x:Type Ellipse}"> <Setter Property="StrokeThickness" Value="2" /> <Setter Property="Stroke" Value="Black" /> <Setter Property="Height" Value="{Binding Width, RelativeSource={RelativeSource Self}}" /> <Setter Property="Width" Value="60" /> <Setter Property="Fill" Value="LightGray" /> </Style> </StackPanel.Resources> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Red"> <Setter Property="Fill" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Amber"> <Setter Property="Fill" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> <Ellipse> <Ellipse.Style> <Style TargetType="{x:Type Ellipse}" BasedOn="{StaticResource singleLightStyle}"> <Style.Triggers> <DataTrigger Binding="{Binding State}" Value="Green"> <Setter Property="Fill" Value="Green" /> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> </StackPanel>

    Read the article

  • How to draw a full ellipse in a StreamGeometry in WPF?

    - by romkyns
    The only method in a StreamGeometryContext that seems related to ellipses is the ArcTo method. Unfortunately it is heavily geared to joining lines rather than drawing ellipses. In particular, the position of the arc is determined by a starting and ending point. For a full ellipse the two coincide obviously, and the exact orientation becomes undefined. So far the best way of drawing an ellipse centered on 100,100 of size 10,10 that I found is like this: using (var ctx = geometry.Open()) { ctx.BeginFigure(new Point(100+5, 100), isFilled: true, isClosed: true); ctx.ArcTo( new Point(100 + 5*Math.Cos(0.01), 100 + 5*Math.Sin(0.01)), // need a small angle but large enough that the ellipse is positioned accurately new Size(10/2, 10/2), // docs say it should be 10,10 but in practice it appears that this should be half the desired width/height... 0, true, SweepDirection.Counterclockwise, true, true); } Which is pretty ugly, and also leaves a small "flat" area (although not visible at normal zoom levels). How else might I draw a full ellipse using StreamGeometryContext?

    Read the article

  • Crop circular or elliptical image from original UIImage

    - by vikas ojha
    I am working on openCV for detecting the face .I want face to get cropped once its detected.Till now I got the face and have marked the rect/ellipse around it on iPhone. Please help me out in cropping the face in circular/elliptical pattern (UIImage *) opencvFaceDetect:(UIImage *)originalImage { cvSetErrMode(CV_ErrModeParent); IplImage *image = [self CreateIplImageFromUIImage:originalImage]; // Scaling down /* Creates IPL image (header and data) ----------------cvCreateImage CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); */ IplImage *small_image = cvCreateImage(cvSize(image->width/2,image->height/2), IPL_DEPTH_8U, 3); /*SMOOTHES DOWN THYE GUASSIAN SURFACE--------:cvPyrDown*/ cvPyrDown(image, small_image, CV_GAUSSIAN_5x5); int scale = 2; // Load XML NSString *path = [[NSBundle mainBundle] pathForResource:@"haarcascade_frontalface_default" ofType:@"xml"]; CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*)cvLoad([path cStringUsingEncoding:NSASCIIStringEncoding], NULL, NULL, NULL); // Check whether the cascade has loaded successfully. Else report and error and quit if( !cascade ) { NSLog(@"ERROR: Could not load classifier cascade\n"); //return; } //Allocate the Memory storage CvMemStorage* storage = cvCreateMemStorage(0); // Clear the memory storage which was used before cvClearMemStorage( storage ); CGColorSpaceRef colorSpace; CGContextRef contextRef; CGRect face_rect; // Find whether the cascade is loaded, to find the faces. If yes, then: if( cascade ) { CvSeq* faces = cvHaarDetectObjects(small_image, cascade, storage, 1.1f, 3, 0, cvSize(20, 20)); cvReleaseImage(&small_image); // Create canvas to show the results CGImageRef imageRef = originalImage.CGImage; colorSpace = CGColorSpaceCreateDeviceRGB(); contextRef = CGBitmapContextCreate(NULL, originalImage.size.width, originalImage.size.height, 8, originalImage.size.width * 4, colorSpace, kCGImageAlphaPremultipliedLast|kCGBitmapByteOrderDefault); //VIKAS CGContextDrawImage(contextRef, CGRectMake(0, 0, originalImage.size.width, originalImage.size.height), imageRef); CGContextSetLineWidth(contextRef, 4); CGContextSetRGBStrokeColor(contextRef, 1.0, 1.0, 1.0, 0.5); // Draw results on the iamge:Draw all components of face in the form of small rectangles // Loop the number of faces found. for(int i = 0; i < faces->total; i++) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // Calc the rect of faces // Create a new rectangle for drawing the face CvRect cvrect = *(CvRect*)cvGetSeqElem(faces, i); // CGRect face_rect = CGContextConvertRectToDeviceSpace(contextRef, // CGRectMake(cvrect.x * scale, cvrect.y * scale, cvrect.width * scale, cvrect.height * scale)); face_rect = CGContextConvertRectToDeviceSpace(contextRef, CGRectMake(cvrect.x*scale, cvrect.y , cvrect.width*scale , cvrect.height*scale*1.25 )); facedetectapp=(FaceDetectAppDelegate *)[[UIApplication sharedApplication]delegate]; facedetectapp.grabcropcoordrect=face_rect; NSLog(@" FACE off %f %f %f %f",facedetectapp.grabcropcoordrect.origin.x,facedetectapp.grabcropcoordrect.origin.y,facedetectapp.grabcropcoordrect.size.width,facedetectapp.grabcropcoordrect.size.height); CGContextStrokeRect(contextRef, face_rect); //CGContextFillEllipseInRect(contextRef,face_rect); CGContextStrokeEllipseInRect(contextRef,face_rect); [pool release]; } } CGImageRef imageRef = CGImageCreateWithImageInRect([originalImage CGImage],face_rect); UIImage *returnImage = [UIImage imageWithCGImage:imageRef]; CGImageRelease(imageRef); CGContextRelease(contextRef); CGColorSpaceRelease(colorSpace); cvReleaseMemStorage(&storage); cvReleaseHaarClassifierCascade(&cascade); return returnImage; } } Thanks Vikas

    Read the article

1 2 3 4 5 6  | Next Page >