//----------------------------------------------------------------------------
void NonlocalBlowup::BuildSquareDomain ()
{
    // Create a texture representing the domain.  This will be used by the
    // shader for drawing the domain and graph of temperature.
    mDomainTexture = new0 Texture2D(Texture::TF_A8R8G8B8, DIMENSION,
        DIMENSION, 1);
    mDomainTexture->GenerateMipmaps();
    unsigned char* data = (unsigned char*)mDomainTexture->GetData(0);
    memset(data, 0, NUMSAMPLES*sizeof(unsigned char));

    // Create a domain mask that is 1 at interior samples of the square and 0
    // at boundary samples of the square.
    mDomain.ClearPixels();
    for (int y = 1; y < DIMENSION-1; ++y)
    {
        for (int x = 1; x < DIMENSION-1; ++x)
        {
            mDomain(x, y) = 255;
            data[4*(x + DIMENSION*y) + 0] = 255;
            data[4*(x + DIMENSION*y) + 1] = 255;
            data[4*(x + DIMENSION*y) + 2] = 255;
            data[4*(x + DIMENSION*y) + 3] = 255;
        }
    }
}
Exemple #2
0
void MLGraph::paint (Graphics& g)
{
	MLLookAndFeel* myLookAndFeel = MLLookAndFeel::getInstance();
	int m = myLookAndFeel->getSmallMargin();
	int w = getWidth();
	int h = getHeight();
	
	Rectangle<float> br (m + 0.5, m + 0.5, w - 2*m + 0.5, h - 2*m + 0.5);
	
	float outlineThickness = 0.5;
	Path envPath;
	
	float fx, fy, viewX, viewY;
	envPath.startNewSubPath(mViewDomain(0), mViewRange(0));
	for(int i=0; i<=mResolution; ++i)
	{
		fx = mDomain((float)i/(float)mResolution);
		
		// evaluate function at fx;
		fy = 0.;
		int s = mPolyCoeffs.size();
		for(int j=0; j<s; ++j)
		{
			float k = mPolyCoeffs[j];
			fy += k*powf(fx, j);
		}		
		
		viewX = mViewDomain(fx);
		viewY = mViewRange(fy);
		envPath.lineTo(viewX, viewY);
	}
	envPath.lineTo(mViewDomain(1), mViewRange(0));

	g.setColour(findColour(MLLookAndFeel::outlineColor));
	g.strokePath(envPath, PathStrokeType (outlineThickness));	
	g.setColour(findColour(MLLookAndFeel::outlineColor).withAlpha(0.125f));
	g.fillPath(envPath);
	
}