Example #1
0
		//----------
		void Toggle::draw(DrawArguments & args) {
			if (!this->value) {
				//nothing allocated
				return;
			}

			auto & font = ofxAssets::font(ofxCvGui::getDefaultTypeface(), 12);

			ofPushStyle();
			
			//fill
			ofSetColor(this->value->get() ^ this->isMouseDown() ?  80 : 50);
			ofFill();
			const auto radius = 4.0f;
			ofDrawRectRounded(args.localBounds, radius, radius, radius, radius);
			
			//outline
			if (this->isMouseOver()) {
				ofNoFill();
				ofSetColor(!this->value->get() ?  80 : 50);
				ofDrawRectRounded(args.localBounds, radius, radius, radius, radius);
			}

			ofSetColor(255);
			auto caption = this->caption;
			if (this->hotKey != 0) {
				caption = caption + " [" + Utils::makeString(this->hotKey) + "]";
			}
			Utils::drawText(caption, args.localBounds, false);
			
			ofPopStyle();
		}
Example #2
0
void BarreDeVie::majBarreVie() 
{
	tailleX = ofGetWindowWidth();
	tailleY = ofGetWindowHeight();
	bdvie.draw(tailleX - 310, 10, 300, 95);
	ofSetColor(200, 0, 0);
	ofDrawRectRounded(tailleX - 265, 15, taillebarre1, 25,100);
	ofSetColor(255);
	ofSetColor(255,255,0);
	ofDrawRectRounded(tailleX - 265, 45, taillebarre2, 25, 100);
	ofSetColor(255);
	ofSetColor(0,200,0);
	ofDrawRectRounded(tailleX - 265, 75, taillebarre3, 25, 100);
	ofSetColor(255);
}
Example #3
0
void Character::drawCursor (float size)
{
    ofSetColor(250, 75 + 175 * size, 75);
    ofDrawRectRounded(xAnim + charWidth * 0.5f + charWidth * size * 0.44f,
                      yAnim + charHeight,
                      charWidth * (1.0f - size * 0.88f),
                      -charHeight * size,
                      charWidth * (1.0f - size));
}
void PMFileSelector::draw(){
    ofPushStyle();
    ofSetColor(ofColor::red);
    ofDrawRectRounded(rectangle, 5);
    
    ofSetColor(ofColor::green);
    int x = rectangle.getX() + 20;
    int y = rectangle.getY()+rectangle.getHeight() - ((rectangle.getHeight()-(font->stringHeight(text)))/1.5);   //font->stringHeight(text);
    font->drawString(text, x, y);
    ofPopStyle();
}
Example #5
0
/*!
 * @brief   Draw stove
 */
void Stove::draw()
{
   // Draw stove border
   ofSetColor(255,255,255);
   ofNoFill();
   ofDrawRectRounded(_orig, _width, _height, 10);

   // Draw burners
   for (int i=0; i<_burners.size(); i++)
      _burners[i].draw();
}
void SolidColorPanel::draw() {
  if (bDrawBackground) {
    ofFill();
    ofSetColor(bgColor);

    if (bRounded) {
      ofDrawRectRounded(0, 0, getWidth(), getHeight(), roundAngle);
    } else {
      ofDrawRectangle(0, 0, getWidth(), getHeight());
    }
  }

  if (bDrawBorder) {
    ofNoFill();
    ofSetLineWidth(2);
    ofSetColor(strokeColor);
    if (bRounded) {
      ofDrawRectRounded(0, 0, getWidth(), getHeight(), roundAngle);
    } else {
      ofDrawRectangle(0, 0, getWidth(), getHeight());
    }
  }
}
Example #7
0
void sketch1::draw(){
    ofSetColor(0,0,0);
    ofDrawBitmapString("Rate " + ofToString(ofGetFrameRate()) + "fps", 10, 15);
    ofDrawBitmapString("circleX " + ofToString(circleX) + " circleY " + ofToString(circleY), 10, 30);
    ofDrawBitmapString("X bound " + ofToString(maxX - radius) + " Y bound " + ofToString(maxY - radius), 10, 45);
    ofDrawBitmapString(" radius " + ofToString(radius), 10, 60);
    ofDrawRectRounded(MINX,
                      MINY,
                      WIDTH,
                      HEIGHT,
                      RECT_RADIUS);
    ofSetColor(r, g, b);
    ofDrawCircle(circleX, circleY, radius);
}
Example #8
0
void CalendarWidget::draw()
{
    ofFill();
    ofSetColor(0, 200);

    ofDrawRectangle(_window);

    std::string formatStringHourMin = "%h:%M %A";
    std::string formatStringHour = "%h:%M";
    std::string formatStringHourMinSec = "%h:%M:%S %A";

    Poco::LocalDateTime minTime(_windowInterval.getStart());
    Poco::LocalDateTime maxTime(_windowInterval.getEnd());

    Poco::LocalDateTime startQuarter = Utils::ceiling(minTime, Poco::Timespan::MINUTES * 5);

    ofPushMatrix();
    ofTranslate(_window.getPosition());

    std::vector<Poco::Timestamp> hours = Utils::getInstances(startQuarter.utc().timestamp(),
                                                             maxTime.utc().timestamp(),
                                                             Period(Period::MINUTE, 5));

    std::vector<Poco::Timestamp>::const_iterator hourIter = hours.begin();

    while (hourIter != hours.end())
    {
        Poco::DateTime time = Poco::DateTime(*hourIter);

        int y = _window.getHeight() * _windowInterval.map(time.timestamp());

        int minute = time.minute();

        float alpha = ofMap(std::abs(_windowInterval.map(time.timestamp()) - 0.5), 0, .2, .25, 1, true);

        if (0 == minute)
        {
            ofSetColor(255, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }
        else if (0 == minute % 15)
        {
            ofSetColor(255, 255, 0, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }
        else
        {
            ofSetColor(127, 80 * alpha);
            ofDrawLine(0, y, _window.getWidth(), y);
        }

        std::string label = Utils::format(Poco::LocalDateTime(time), formatStringHourMinSec);

        int width = _font.stringWidth(label);
        int height = _font.stringHeight(label);

        if (y - height - 4 > 0)
        {
            _font.drawString(label, _window.getWidth() - width - 4, y - 4);
        }

        ++hourIter;
    }

    int y = _window.getHeight() * _windowInterval.map(_now);

    ofSetColor(255);
    ofDrawLine(0, y, _window.getWidth(), y);

    std::string label = Utils::format(Poco::LocalDateTime(_now), formatStringHourMinSec);

    int width = _font.stringWidth(label);

    _font.drawString(label, _window.getWidth() - width - 4, y - 4);

    std::sort(_currentEvents.begin(), _currentEvents.end());


    ICalendar::EventInstances::const_iterator iter = _currentEvents.begin();

    int x = 0;

    while (iter != _currentEvents.end())
    {
        const ICalendarEvent& event = (*iter).getEvent();
        const Interval& interval = (*iter).getInterval();

        if (_windowInterval.intersects(interval))
        {
            int y0 = _window.getHeight() * _windowInterval.map(interval.getStart());
            int y1 = _window.getHeight() * _windowInterval.map(interval.getEnd());

            ofFill();
            ofSetColor(255, 50);

            if (interval.contains(_now))
            {
                ofSetColor(255, 255, 0, 50);
            }
            else
            {
                ofSetColor(255, 50);
            }


            ofDrawRectRounded(x, y0, 80, y1 - y0, 5);

            ofNoFill();
            ofSetColor(127);
            ofDrawRectRounded(x, y0, 80, y1 - y0, 5);

            ofSetColor(255);
            ofDrawRectRounded(x-1, y0-1, 80+2, y1 - y0+2, 5);


            std::string startLabel = Utils::format(Poco::LocalDateTime(interval.getStart()), formatStringHour);
            std::string endLabel = Utils::format(Poco::LocalDateTime(interval.getEnd()), formatStringHour);

            ofFill();
            ofSetColor(255);
            _font.drawString(event.getSummary(), x + 5, y0 + 10);
            _font.drawString(startLabel,         x + 5, y0 + 20);
            _font.drawString(endLabel,           x + 5, y0 + 30);
            
            x+= 84;
            
            if (x > _window.getWidth() - 160) x = 0;
            
        }
        
        ++iter;
    }
    
    ofPopMatrix();
}
Example #9
0
//========================================================================
void Character::draw (float& x, float& y, bool vertical, bool selection, bool floating)
{
    // Init character position
    if (this->x == 0.0f) this->x = xAnim = x + charWidth;
    if (this->y == 0.0f) this->y = yAnim = y + charHeight * int(vertical);
    
    
    // Update input position
    if (ofGetMousePressed(OF_MOUSE_BUTTON_LEFT) &&
        charSelected->charType != CHAR &&
        (begin == charSelected || (begin == charSelected->end()->right && !floating)))
    {
        if (begin == charSelected)
        {
            x = mouseX - charWidth  * 0.5f;
            y = mouseY - charHeight * 0.5f;
        }
        else
        {
            x = charSelected->left->x + charWidth  * 3.0f;
            y = charSelected->left->y + charHeight * int(vertical);
        }
    }
    else
    {
        if (floating)
        {
            x = roundf(this->x / charWidth)  * charWidth;
            y = roundf(this->y / charHeight) * charHeight;
        }
        else
        {
            x += charWidth;
            y += charHeight * int(vertical);
        }
    }
    
    
    // Update character position
    this->x = x;
    this->y = y;
    
    
    // Draw character
    ofPushMatrix();
    
    float factor1 = powf(1.0f - animation, 4.0f);
    float factor2 = (1.0f - factor1);
    
    float scaling = 1.0f + ofGetHeight() / charHeight * factor1 * 0.4f;
    
    // TODO: change translate
    ofTranslate(xAnim * factor2, // + ofGetWidth()  * 0.5f * factor1,
                yAnim * factor2);// + ofGetHeight() * 0.5f * factor1);
    ofTranslate(charWidth * 0.5f, charHeight * 0.5f);
    ofRotate(factor1 * 180.0f);
    ofScale(scaling, scaling);
    charFont.drawString(charString,
                        -charWidth * 0.5f,
                        charHeight * 0.5f + charFont.getDescenderHeight());
    
    ofPopMatrix();
    
    
    // Draw selection
    if (selection)
    {
        ofSetColor(COLOR_SELECTION);
        ofDrawRectangle(xAnim, yAnim, charWidth, charHeight);
    }
    
    if ((mouseX >= xAnim && mouseX < xAnim + charWidth) &&
        (mouseY >= yAnim && mouseY < yAnim + charHeight))
    {
        ofSetColor(COLOR_SELECTION * 2);
        ofDrawRectRounded(xAnim, yAnim, charWidth, charHeight, charWidth * 0.1f);
    }
    
    
    // Draw fractal
    //if (charType == FUNC || charType == MAIN)
    //    drawFractal();
    
    
    // Update character animation position
    float factor = 0.3f;
    xAnim = (1.0f - factor) * xAnim + factor * this->x;
    yAnim = (1.0f - factor) * yAnim + factor * this->y;
    
    
    // Update animation
    if (animation >= 1.0f)
        animation  = 1.0f;
    else
        animation += 0.047f;
    
    
    // Shake characters when a key is pressed
    if (RMS > 0.0707f) // CHANGE THIS WHEN NEEDED
    {
        float factor = 0.05f;
        xAnim += ofRandom(-charWidth * factor, charWidth * factor);
        yAnim -= ofRandom(0.0f, charHeight * factor);
        
        animation *= 0.92f;
    }
}