logo
down
shadow

CaptureElement as an ellipse shape


CaptureElement as an ellipse shape

By : user2953497
Date : November 21 2020, 01:01 AM
Any of those help No, there's no direct way to do this. The Windows Runtime doesn't have anything analagous to VideoBrush and no non-rectangular clipping.
What you can do is to display the preview in a rectangular window but cover it with an opaque mask with your ellipse cut out of it. Something approximating the following (but with your app's sizing, naming, etc.)
code :
    <CaptureElement />
    <Path Fill="{ThemeResource MyOpaqueBackgroundBrush}">
        <Path.Data>
            <GeometryGroup>
                <RectangleGeometry Rect="0,0 300,300" />
                <EllipseGeometry Center="150,150" RadiusX="100" RadiusY="100" />
            </GeometryGroup>
        </Path.Data>
    </Path>


Share : facebook icon twitter icon
WPF show video in ellipse shape

WPF show video in ellipse shape


By : user1965395
Date : March 29 2020, 07:55 AM
hop of those help? I want to show a video in an ellipse shape.
code :
<MediaElement Source="YourMediaElement">
    <MediaElement.Clip>
        <EllipseGeometry Center="150,150" RadiusX="50" RadiusY="50"/>
    </MediaElement.Clip>
</MediaElement>
Algorithm for shape calculation (Ellipse)

Algorithm for shape calculation (Ellipse)


By : Дмитрий Пазников
Date : March 29 2020, 07:55 AM
To fix the issue you can do OK as i understand you know common radius of circles R0 and their number N and want to know inside ellipse parameters and positions of everything.
If we convert ellipse to circle then we get this:
code :
const int N=12; // number of satelite circles
const double R=10.0;    // radius of satelite circles
struct _circle { double x,y,r; } circle[N]; // satelite circles

int i;
double x,y,r,l,a,da;
x=0.0;  // start pos of first satelite circle
y=0.0;
r=R;
l=r+r;  // distance ang angle between satelite circle centers
a=0.0*deg;
da=divide(360.0*deg,N);
for (i=0;i<N;i++)
    {
    circle[i].x=x; x+=l*cos(a);
    circle[i].y=y; y+=l*sin(a);
    circle[i].r=r; a+=da;
    }
// inside circle params
_circle c;
r=divide(0.5*l,sin(0.5*da))-R;
c.x=circle[i].x;
c.y=circle[i].y+R+r;
c.r=r;
const int    N=20;      // number of satelite circles
const double R=10.0;    // satelite circles radius
const double E= 0.7;    // ellipse distortion ry=rx*E
struct _circle { double x,y,r; _circle() { x=0; y=0; r=0.0; } } circle[N];
struct _ellipse { double x,y,rx,ry; _ellipse() { x=0; y=0; rx=0.0; ry=0.0; } } ellipse;

int i,j,k;
double l,a,da,m,dm,x,y,q,r0;
l=double(N)*R;                          // circle cener lines polygon length
ellipse.x =0.0;                         // set ellipse parameters
ellipse.y =0.0;
r0=divide(l,M_PI*sqrt(0.5*(1.0+(E*E))))-R;// aprox radius to match ellipse length for start
l=R+R; l*=l;
m=1.0; dm=1.0; x=0.0;
for (k=0;k<5;k++)                       // aproximate ellipse size to the right size
    {
    dm=fabs(0.1*dm);                    // each k-iteration layer is 10x times more accurate
    if (x>l) dm=-dm;
    for (;;)
        {
        ellipse.rx=r0  *m;
        ellipse.ry=r0*E*m;
        for (a=0.0,i=0;i<N;i++)         // set circle parameters
            {
            q=(2.0*a)-atanxy(cos(a),sin(a)*E);
            circle[i].x=ellipse.x+(ellipse.rx*cos(a))+(R*cos(q));
            circle[i].y=ellipse.y+(ellipse.ry*sin(a))+(R*sin(q));
            circle[i].r=R;    
            da=divide(360*deg,N); a+=da;
            for (j=0;j<5;j++)           // aproximate next position to match 2R distance from current position
                {
                da=fabs(0.1*da);        // each j-iteration layer is 10x times more accurate
                q=(2.0*a)-atanxy(cos(a),sin(a)*E);
                x=ellipse.x+(ellipse.rx*cos(a))+(R*cos(q))-circle[i].x; x*=x;
                y=ellipse.y+(ellipse.ry*sin(a))+(R*sin(q))-circle[i].y; y*=y; x+=y;
                if (x>l) for (;;)       // if too far dec angle
                    {
                    a-=da;
                    q=(2.0*a)-atanxy(cos(a),sin(a)*E);
                    x=ellipse.x+(ellipse.rx*cos(a))+(R*cos(q))-circle[i].x; x*=x;
                    y=ellipse.y+(ellipse.ry*sin(a))+(R*sin(q))-circle[i].y; y*=y; x+=y;
                    if (x<=l) break;
                    }
                else if (x<l) for (;;)  // if too short inc angle
                    {
                    a+=da;
                    q=(2.0*a)-atanxy(cos(a),sin(a)*E);
                    x=ellipse.x+(ellipse.rx*cos(a))+(R*cos(q))-circle[i].x; x*=x;
                    y=ellipse.y+(ellipse.ry*sin(a))+(R*sin(q))-circle[i].y; y*=y; x+=y;
                    if (x>=l) break;
                    }
                else break;
                }
            }
        // check if last circle is joined as it should be
        x=circle[N-1].x-circle[0].x; x*=x;
        y=circle[N-1].y-circle[0].y; y*=y; x+=y;
        if (dm>0.0) { if (x>=l) break; }
        else        { if (x<=l) break; }
        m+=dm;
        }
    }
How to change shape of chord diagram from circle to ellipse shape?

How to change shape of chord diagram from circle to ellipse shape?


By : 王一夫
Date : March 29 2020, 07:55 AM
it should still fix some issue First of all, the chords are not drawn as circles, but as bezier curves with a single control point in the center of the drawing (which kind of look like circles). I propose to place two control points closer to the rim to obtain an "ellipse-like" effect.
I'm not sure how to draw such arcs from scratch, but it is possible to edit the d attribute of the paths after they are drawn.
code :
function editPath() {
    var ratio = 0.6;
    var path=d3.select(this).attr("d")
    console.log(path);
    find=path.match(/([\-\.0-9]+)\,([\-\.0-9]+)Q 0,0 ([\-\.0-9]+),([\-\.0-9]+)/);
    if (!find) return;

    path=path.replace(/Q 0,0/,"C "+find[1]*ratio+","+find[2]*ratio+" "+find[3]*ratio+","+find[4]*ratio);

    console.log(path);
    d3.select(this).attr("d", path)
}
[...]
 .attr("class", "chord")
 .attr("d", d3.svg.chord().radius(350))
 .each(editPath).each(editPath) //call twice!
How to fill an ellipse shape?

How to fill an ellipse shape?


By : love yuanyuan
Date : March 29 2020, 07:55 AM
around this issue Well, one idea could be to just traverse half the circle, and instead compute points that are symmetrically placed around i.e. the y axis. Then draw a horizontal line between them, filling in all the pixels.
Obtaining the best ellipse fit of an irregular shape

Obtaining the best ellipse fit of an irregular shape


By : Red One
Date : March 29 2020, 07:55 AM
To fix the issue you can do Ok here is a bit of code to get you started. This is by no means perfect but it was fun doing it and I hope it will help you. The most important part of the code was actually written by @Amro in this great answer: check me!. I incorporated Amro's code to plot the ellipse ( Amro!).
As I mentioned in my comment, you can use regionprops with a couple of parameters to estimate an ellipse that fit some shape. The names are self-explanatory and can be used to describe an ellipse. Here is my dummy shape which looks like a potato:
Related Posts Related Posts :
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org