Example #1
0
void KQtTester::testImageEffects()
{
    QString report = QString("execute %1 times:\n").arg(g_nTimes);

    report += QString("none:\t%1\tms\n").arg(none());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("gray:\t%1\tms\n").arg(gray());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("watermark:\t%1\tms\n").arg(watermark());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("bilevel:\t%1\tms\n").arg(bilevel());

    m_pPainter->resetMatrix();
    m_pPainter->translate(0, g_img.height() + 10);
    report += QString("lightBlue:\t%1\tms\n").arg(lightBlue());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("darkBlue:\t%1\tms\n").arg(darkBlue());

    m_pPainter->resetMatrix();
    m_pPainter->translate(0, (g_img.height() + 10) * 2);
    report += QString("colorKey:\t%1\tms\n").arg(colorKey());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("brightness:\t%1\tms\n").arg(brightness());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("contrast:\t%1\tms\n").arg(contrast());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("brown:\t%1\tms\n").arg(brown());

	drawReport(report);
}
Example #2
0
void GUIForumPostItem::draw()
{
	if ( !IsVisible )
		return;

	IVideoDriver* pVideo = Environment->getVideoDriver();
	SColor black(255, 0, 0, 0), darkBlue(255, 0, 0, 128);

	pVideo->draw2DRectangle( AbsoluteRect, black, black, darkBlue, darkBlue, &AbsoluteClippingRect );

	IGUIElement::draw();
}
//----------------------------------------------------------------------------
Node* RoughPlaneSolidBox::CreateBox ()
{
    mBox = new0 Node();

    float xExtent = (float)mModule.XLocExt;
    float yExtent = (float)mModule.YLocExt;
    float zExtent = (float)mModule.ZLocExt;

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);

    StandardMesh sm(vformat);
    VertexColor3Effect* effect = new0 VertexColor3Effect();
    VertexBufferAccessor vba;
    Transform transform;
    TriMesh* face;
    int i;

    // +z face
    Float3 red(1.0f, 0.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, 0.0f, zExtent));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, xExtent, yExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = red;
        vba.Color<Float3>(0, 1) = red;
        vba.Color<Float3>(0, 2) = red;
        vba.Color<Float3>(0, 3) = red;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -z face
    Float3 darkRed(0.5f, 0.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, 0.0f, -zExtent));
    transform.SetRotate(HMatrix(AVector::UNIT_Y, AVector::UNIT_X,
        -AVector::UNIT_Z, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, yExtent, xExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkRed;
        vba.Color<Float3>(0, 1) = darkRed;
        vba.Color<Float3>(0, 2) = darkRed;
        vba.Color<Float3>(0, 3) = darkRed;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // +y face
    Float3 green(0.0f, 1.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, yExtent, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Z, AVector::UNIT_X,
        AVector::UNIT_Y, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, zExtent, xExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = green;
        vba.Color<Float3>(0, 1) = green;
        vba.Color<Float3>(0, 2) = green;
        vba.Color<Float3>(0, 3) = green;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -y face
    Float3 darkGreen(0.0f, 1.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, -yExtent, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_X, AVector::UNIT_Z,
        -AVector::UNIT_Y, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, xExtent, zExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkGreen;
        vba.Color<Float3>(0, 1) = darkGreen;
        vba.Color<Float3>(0, 2) = darkGreen;
        vba.Color<Float3>(0, 3) = darkGreen;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // +x face
    Float3 blue(0.0f, 0.0f, 1.0f);
    transform.SetTranslate(APoint(xExtent, 0.0f, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Y, AVector::UNIT_Z,
        AVector::UNIT_X, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, yExtent, zExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = blue;
        vba.Color<Float3>(0, 1) = blue;
        vba.Color<Float3>(0, 2) = blue;
        vba.Color<Float3>(0, 3) = blue;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -x face
    Float3 darkBlue(0.0f, 0.0f, 1.0f);
    transform.SetTranslate(APoint(-xExtent, 0.0f, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Z, AVector::UNIT_Y,
        -AVector::UNIT_X, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, zExtent, yExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkBlue;
        vba.Color<Float3>(0, 1) = darkBlue;
        vba.Color<Float3>(0, 2) = darkBlue;
        vba.Color<Float3>(0, 3) = darkBlue;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    MoveBox();
    return mBox;
}
void SoundplaneZoneView::renderZones()
{
	if (!mpModel) return;
    const ScopedLock lock(*(mpModel->getZoneLock()));
    const std::vector<ZonePtr>& zoneList = mpModel->getZones();

    int viewW = getBackingLayerWidth();
    int viewH = getBackingLayerHeight();
	int viewScale = getRenderingScale();
	// float viewAspect = (float)viewW / (float)viewH;
    
	int gridWidth = 30; // Soundplane A TODO get from tracker
	int gridHeight = 5;
    int lineWidth = viewW / 200;
    int thinLineWidth = viewW / 400;
    // int margin = lineWidth*2;
    
    // put origin in lower left. 
    MLGL::orthoView2(viewW, viewH);
    MLRange xRange(0, gridWidth, 1, viewW);
	MLRange yRange(0, gridHeight, 1, viewH);

	Vec4 lineColor;
	Vec4 darkBlue(0.3f, 0.3f, 0.5f, 1.f);
	Vec4 gray(0.6f, 0.6f, 0.6f, 1.f);
	Vec4 lightGray(0.9f, 0.9f, 0.9f, 1.f);
	Vec4 blue2(0.1f, 0.1f, 0.5f, 1.f);
    float smallDotSize = xRange(1.f);
    
   // float strokeWidth = viewW / 100;    
    
    std::vector<ZonePtr>::const_iterator it;

    for(it = zoneList.begin(); it != zoneList.end(); ++it)
    {
        const Zone& zone = **it;
        
        int t = zone.getType();
        MLRect zr = zone.getBounds();
        const char * name = zone.getName().c_str();
		int offset = zone.getOffset();
        
        // affine transforms TODO for better syntax: MLRect zrd = zr.xform(gridToView);
        
        MLRect zoneRectInView(xRange.convert(zr.x()), yRange.convert(zr.y()), xRange.convert(zr.width()), yRange.convert(zr.height()));
        zoneRectInView.shrink(lineWidth);
		
		// color idx = type + port offset.
        Vec4 zoneStroke(MLGL::getIndicatorColor(t + offset));
        Vec4 zoneFill(zoneStroke);
        zoneFill[3] = 0.1f;
        Vec4 activeFill(zoneStroke);
        activeFill[3] = 0.25f;
        Vec4 dotFill(zoneStroke);
        dotFill[3] = 0.5f;
        
        // draw box common to all kinds of zones
        glColor4fv(&zoneFill[0]);
        MLGL::fillRect(zoneRectInView);
        glColor4fv(&zoneStroke[0]);
        glLineWidth(lineWidth);
        MLGL::strokeRect(zoneRectInView, 2.0f*viewScale);
        glLineWidth(1);
        // draw name
        // all these rect calculations read upside-down here because view origin is at bottom
        MLGL::drawTextAt(zoneRectInView.left() + lineWidth, zoneRectInView.top() + lineWidth, 0.f, 0.1f, viewScale, name);
        
        // draw any zone-specific things
        float x, y;
        int toggle;
        switch(t)
        {
            case kNoteRow:
                for(int i = 0; i < kSoundplaneMaxTouches; ++i)
                {
                    const ZoneTouch& uTouch = zone.getTouch(i);
                    const ZoneTouch& touch = zone.touchToKeyPos(uTouch);
                    if(touch.isActive())
                    {
                        glColor4fv(&dotFill[0]);
                        float dx = xRange(touch.pos.x());
                        float dy = yRange(touch.pos.y());
                        float dz = touch.pos.z();
                        MLGL::drawDot(Vec2(dx, dy), dz*smallDotSize);
                    }
                }
                break;
                
            case kControllerX:
                x = xRange(zone.getXKeyPos());
                glColor4fv(&zoneStroke[0]);
                glLineWidth(thinLineWidth);
                MLGL::strokeRect(MLRect(x, zoneRectInView.top(), 0., zoneRectInView.height()), viewScale);
                glColor4fv(&activeFill[0]);
                MLGL::fillRect(MLRect(zoneRectInView.left(), zoneRectInView.top(), x - zoneRectInView.left(), zoneRectInView.height()));
                break;
                
            case kControllerY:
                y = yRange(zone.getYKeyPos());
                glColor4fv(&zoneStroke[0]);
                glLineWidth(thinLineWidth);                
                MLGL::strokeRect(MLRect(zoneRectInView.left(), y, zoneRectInView.width(), 0.), viewScale);
                glColor4fv(&activeFill[0]);
                MLGL::fillRect(MLRect(zoneRectInView.left(), zoneRectInView.top(), zoneRectInView.width(), y - zoneRectInView.top()));
                break;
                
            case kControllerXY:
                x = xRange(zone.getXKeyPos());
                y = yRange(zone.getYKeyPos());
                glColor4fv(&zoneStroke[0]);
                glLineWidth(thinLineWidth);
                // cross-hairs centered on dot
                MLGL::strokeRect(MLRect(x, zoneRectInView.top(), 0., zoneRectInView.height()), viewScale);
                MLGL::strokeRect(MLRect(zoneRectInView.left(), y, zoneRectInView.width(), 0.), viewScale);
                glColor4fv(&dotFill[0]);
                MLGL::drawDot(Vec2(x, y), smallDotSize*0.25f);
                break;
                                
            case kControllerZ:
                y = yRange(zone.mYRange(zone.getValue(0))); // look at z value over y range
                glColor4fv(&zoneStroke[0]);
                glLineWidth(thinLineWidth);
                MLGL::strokeRect(MLRect(zoneRectInView.left(), y, zoneRectInView.width(), 0.), viewScale);
                glColor4fv(&activeFill[0]);
                MLGL::fillRect(MLRect(zoneRectInView.left(), zoneRectInView.top(), zoneRectInView.width(), y - zoneRectInView.top()));
                break;

            case kToggle:
                toggle = zone.getToggleValue();
                glColor4fv(&zoneStroke[0]);
                glLineWidth(thinLineWidth);
                if(toggle)
                {
                    MLRect toggleFill = zoneRectInView;
                    Vec2 zoneCenter = zoneRectInView.getCenter();
                    glColor4fv(&activeFill[0]);
                    MLGL::fillRect(zoneRectInView);
                    glColor4fv(&dotFill[0]);
                    MLGL::drawDot(zoneCenter, smallDotSize*0.25f);
                }
                break;
         }
    }
}
void SoundplaneZoneView::renderGrid()
{
    int viewW = getBackingLayerWidth();
    int viewH = getBackingLayerHeight();
    
    MLGL::orthoView2(viewW, viewH);

	int gridWidth = 30; // Soundplane A TODO get from tracker
	int gridHeight = 5;
   // int margin = viewW / 50;
	MLRange xRange(0, gridWidth, 1, viewW);
	MLRange yRange(0, gridHeight, 1, viewH);
    
	// draw thin lines at key grid
	Vec4 lineColor;
	Vec4 darkBlue(0.3f, 0.3f, 0.5f, 1.f);
	Vec4 gray(0.6f, 0.6f, 0.6f, 1.f);
	lineColor = gray;

	// horiz lines
	glColor4fv(&lineColor[0]);
	for(int j=0; j<=gridHeight; ++j)
	{
		glBegin(GL_LINE_STRIP);
		for(int i=0; i<=gridWidth; ++i)
		{
			float x = xRange.convert(i);
			float y = yRange.convert(j);
			glVertex2f(x, y);
		}
		glEnd();
	}
	// vert lines
	for(int i=0; i<=gridWidth; ++i)
	{
		glBegin(GL_LINE_STRIP);
		for(int j=0; j<=gridHeight; ++j)
		{
			float x = xRange.convert(i);
			float y = yRange.convert(j);
			glVertex2f(x, y);
		}
		glEnd();
	}
	
	// draw dots
    float r = viewH / 80.;
	for(int i=0; i<=gridWidth; ++i)
	{
		float x = xRange.convert(i + 0.5);
		float y = yRange.convert(2.5);
		int k = i%12;
		if(k == 0)
		{
			float d = viewH / 50;
            Vec4 dotColor(0.6f, 0.6f, 0.6f, 1.f);
            glColor4fv(&dotColor[0]);
            MLGL::drawDot(Vec2(x, y - d), r);
			MLGL::drawDot(Vec2(x, y + d), r);
		}
		if((k == 3)||(k == 5)||(k == 7)||(k == 9))
		{
            Vec4 dotColor(0.6f, 0.6f, 0.6f, 1.f);
            glColor4fv(&dotColor[0]);
            MLGL::drawDot(Vec2(x, y), r);
		}
	}
}
//--------------------------------------------------------------
void ofApp::setup(){
    numSmallCircles = 41; //11 purple, 7 blue, 5 top right, 11 sleave, 7 but, 14 bottom
    grabbed = false;
    
    
    ofColor purple (161, 99, 128);
    ofColor pink (214, 73, 89);  // 1 pink
    ofColor lightPink (147,131,17);  //2 light pink
    ofColor yellow (212,179,14);  //3 yellow
    ofColor black (44,53,71);  //4 middle black
    ofColor blue (47,96,137);//5 blue
    ofColor green (28,124,92);//6 green
    ofColor orange (228,95,79);//7 orange bottom circles
    ofColor moreYellow (204, 155, 82);
    ofColor orangeLighter (232,105,92);
    ofColor darkBlue (38,81,126);
    
    //purple circle positions 0-11
    circlePositions.push_back(ofPoint(436, 342)); //0
    circlePositions.push_back(ofPoint(446, 358)); //1
    circlePositions.push_back(ofPoint(438, 385)); //2
    circlePositions.push_back(ofPoint(414,352)); //3
    circlePositions.push_back(ofPoint(429, 369)); //4
    circlePositions.push_back(ofPoint(423, 385)); //5
    circlePositions.push_back(ofPoint(425, 395)); //6
    circlePositions.push_back(ofPoint(402,337)); //7
    circlePositions.push_back(ofPoint(403, 376)); //8
    circlePositions.push_back(ofPoint(389, 392)); //9
    circlePositions.push_back(ofPoint(381, 348)); //10
     circlePositions.push_back(ofPoint(382, 365)); //11

    
    for(int i=0; i<11; i++){
       CirclesWoman tempCircle;
        smallCircles.push_back(tempCircle);
    }
    int width = ofRandom(20,30);
    int height = ofRandom(10,20);
    
    smallCircles[1].setup(width, height, pink, lightPink, black, circlePositions[1]);
    smallCircles[2].setup(width, height, purple, yellow, black, circlePositions[2]);
    smallCircles[3].setup(width, height, yellow, pink, black, circlePositions[3]);
    smallCircles[4].setup(width, height, pink, lightPink, black, circlePositions[4]);
    smallCircles[5].setup(width, height, purple, yellow, black, circlePositions[5]);
    smallCircles[6].setup(width, height, yellow, lightPink, black, circlePositions[6]);
    smallCircles[7].setup(width, height, pink, yellow, yellow, circlePositions[7]);
    smallCircles[8].setup(width, height, pink, yellow, black, circlePositions[8]);
    smallCircles[9].setup(width, height, blue, green, green, circlePositions[9]);
    smallCircles[10].setup(width, height, pink, purple, black, circlePositions[10]);
    smallCircles[11].setup(width, height, purple, yellow, black, circlePositions[11]);
    
    //blue circles
    for(int i=11; i<19; i++){
        CirclesWoman tempBlueCircle;
        tempBlueCircle.randomSetup("blue");
         smallCircles.push_back(tempBlueCircle);
        
    }
    //        setup(int _width, int _height, ofColor color1, ofColor color2, ofColor color3 , ofPoint _position)
    
    for(int i=19; i<26; i++){
        CirclesWoman tempButtCircle;
        tempButtCircle.randomSetup("butt");
        smallCircles.push_back(tempButtCircle);
        
    }
    
    for(int i=26; i<41; i++){
        CirclesWoman tempBottomCircle;
        smallCircles.push_back(tempBottomCircle);
    }
    
    smallCircles[26].setup(13.33, 9.33, orange, moreYellow, moreYellow, ofPoint(447,727));
    smallCircles[27].setup(17.33, 18.833, orange, moreYellow, moreYellow, ofPoint(447,738.5));
    smallCircles[28].setup(17.33, 15.75, orange, moreYellow, green, ofPoint(450,753));
    smallCircles[29].setup(16, 11.875, orange, moreYellow, moreYellow, ofPoint(442,769));
    smallCircles[30].setup(17.33, 14.542, orange, moreYellow, green, ofPoint(429,722));
    smallCircles[31].setup(18.267, 14.751, orange, moreYellow, moreYellow, ofPoint(430,733));
    smallCircles[32].setup(24.99, 18.17, orange, orangeLighter, black, ofPoint(430,748));
    smallCircles[33].setup(19.313, 15.34, darkBlue, darkBlue, black, ofPoint(418,762.566));
    smallCircles[34].setup(18.3, 13.602, orange, moreYellow, moreYellow, ofPoint(415.33,720));
    smallCircles[35].setup(23.54, 16.605, orange, orangeLighter, black, ofPoint(408,736));
    smallCircles[36].setup(22, 14, darkBlue, darkBlue, black, ofPoint(389,722));
    smallCircles[37].setup(21, 14, orange, yellow, yellow, ofPoint(385,740));
    smallCircles[38].setup(21, 14, orange, orangeLighter, black, ofPoint(395,750));
    smallCircles[39].setup(21, 18, orange, moreYellow, moreYellow, ofPoint(382,763));
    smallCircles[40].setup(21, 17, orange, moreYellow, moreYellow, ofPoint(404,765));

    
//<-------------- squiggly lines dress ---------------->
    numLines = 30;
    int startingX = 332;
    int endingX = 500;
    int interval = (endingX-startingX)/numLines;
    for(int i=0; i<numLines; i++){
        SquigglyLine tempSquiggle;
        tempSquiggle.setup(startingX + interval*i);
        lines.push_back(tempSquiggle);
    }
    
//<-------------- images ---------------->
    arm.loadImage("arm.png");
    greenCircle.loadImage("green_circle.png");
    orangeBackground.loadImage("orange_background.jpg");
    heads.loadImage("heads.png");
    spiralBackground.loadImage("under_spirals.png");
    background.loadImage("background.jpg");
    man.loadImage("man.png");
    
//<-------------- little squares dress ---------------->
    numLittleSquares = 120;
    for(int i=0; i<numLittleSquares; i++){
        LittleSquares tempSquare;
        tempSquare.setup();
        dressSquares.push_back(tempSquare);
    }
//<-------------- big circles dress ---------------->
    numBigCirclesDress = 10;
//    for(int i=0; i<numBigCirclesDress; i++){
//        bigCirclesDress tempBigCircle;
//        tempBigCircle.setup();
//        bigCircles.push_back(tempBigCircle);
//        
//        
//    }
//
    for(int i=0; i<numBigCirclesDress; i++){
        bigCirclesDress tempBigCircle;
        bigCircles.push_back(tempBigCircle);
    }

    bigCircles[0].setupFixed(ofPoint(411,488),22,16);
    bigCircles[1].setupFixed(ofPoint(412,637),20,16);
    bigCircles[2].setupFixed(ofPoint(457,330),22,14);
    bigCircles[3].setupFixed(ofPoint(417,543),21,15);
    bigCircles[4].setupFixed(ofPoint(342,500),18,11);
    bigCircles[5].setupFixed(ofPoint(377,519),18,13);
    bigCircles[6].setupFixed(ofPoint(449,548),22,16);
    bigCircles[7].setupFixed(ofPoint(388,590),21,15);
    bigCircles[8].setupFixed(ofPoint(392,649),15,11);
    bigCircles[9].setupFixed(ofPoint(465,726),19,15);
    
    //<-------------- spirals ---------------->
    numSpirals = 12;
    
    for(int i=0; i<numSpirals; i++){
        spiral tempSpiral;
        spirals.push_back(tempSpiral);
        //spirals[i].setupRandom();
    }
    
    spirals[0].setup(ofPoint(495,373), 35,35, 4);
    spirals[1].setup(ofPoint(537,355), 52,52, 4);
    spirals[2].setup(ofPoint(560, 506), 40, 38, 4);
    spirals[3].setup(ofPoint(499, 473), 60, 55, 5);
    spirals[4].setup(ofPoint(520, 438), 35, 32, 4);
    spirals[5].setup(ofPoint(553, 414), 29, 29, 3);
    spirals[6].setup(ofPoint(483, 598), 50, 45, 4);
    spirals[7].setup(ofPoint(540, 619), 40, 35, 4);
     spirals[8].setup(ofPoint(595, 554), 34, 32, 3);
     spirals[9].setup(ofPoint(479, 414), 45, 40, 4);
     spirals[10].setup(ofPoint(534, 537), 54, 44, 6);
     spirals[11].setup(ofPoint(490, 530), 36, 31, 4);
//    int posX = 495;
//    float radius = 35;
//    for(var i=0; i<numSpirals; i++){
//        if(posX < 650){
//            posX += numSpirals[i-1].radius/2
//        }
//        spirals[i].setup(ofPoint());
//    }
    
    
}