PDA

View Full Version : filled polygon


olilarkin
07-25-2010, 03:01 AM
i modified iplug to give me access to the LICE filled polygon method, but I'm not sure how to make it work properly, and it ends up just drawing a triangle. I'm trying to draw a kind of gaussian shape:


#define NUMSTEPS 64

class ESVis: public IControl
{
public:
ESVis(IPlugBase *pPlug, IRECT* pR)
: IControl(pPlug, pR)
{
CalcTable();


}

bool Draw(IGraphics* pGraphics)
{

pGraphics->FillIConvexPolygon(&COLOR_RED, mXPoints, mYPoints, NUMSTEPS, 1.);

for(int i=0;i<NUMSTEPS-1;i++)
{
pGraphics->DrawLine(&COLOR_BLACK, (float) mXPoints[i], (float) mYPoints[i], (float) mXPoints[i+1], (float) mYPoints[i+1],0, true);
}

return true;

}

void CalcTable()
{
for(int i=0;i<NUMSTEPS;i++)
{
double gauss = exp(-4.8283*(1.-cos(6.2831853*((double)i-31.5)/(NUMSTEPS-1.))));
double bell = 0.5 + 5. * cos(6.2831853*(((double) i-31.5)/(NUMSTEPS-1.))) / 10.;
double yval = gauss;//(bell * envmix) + (gauss * (1-envmix));

mXPoints[i] = (i*4);
mYPoints[i] = 100. - (yval * 100.);
printf("x %i, y %i\n",mXPoints[i] ,mYPoints[i]);
}

}

bool IsDirty() { return true;}

private:
IColor mBgColor;
int mXPoints[NUMSTEPS];
int mYPoints[NUMSTEPS];
};


anyone used it before?

junioreq
07-25-2010, 03:13 AM
The Endless series I see ;)

~Rob.

RRokkenAudio
07-30-2010, 01:41 AM
How you coming on this?

olilarkin
07-30-2010, 02:46 AM
i got it working by drawing a small 4 cornered polygon for each segment


bool Draw(IGraphics* pGraphics)
{
for(int i=0;i<NUMSTEPS-2;i++)
{
int xPoints[4] = {mXPoints[i],mXPoints[i+1],mXPoints[i+1],mXPoints[i]};
int yPoints[4] = {mYPoints[i],mYPoints[i+1],mRECT.B,mRECT.B};

pGraphics->FillIConvexPolygon(&COLOR_RED, xPoints, yPoints, 4, 1.);

pGraphics->DrawLine(&COLOR_BLACK, (float) mXPoints[i], (float) mYPoints[i], (float) mXPoints[i+1], (float) mYPoints[i+1],0, true);
}

return true;

}