<commit_before>//
//  PaintboxScene.cpp
//  show
//
//  Created by <NAME> on 05/09/2015.
//
//

#include "PaintboxScene.h"
using namespace ofxCv;
using namespace cv;

PaintboxScene::PaintboxScene() {
    name = "Paintbox";
}

void PaintboxScene::setup() {
    // subscenes
    subsceneStart = 63;
    subsceneEnd = 66;
    brushImage.loadImage("images/paintbrush/brush1.png");
    SceneBase::setup();
}

void PaintboxScene::update() {
    SceneBase::update();
    if (isMaster() && getIsActive()) {
        totalBlobArea = 0;
        ContourTracker& tracker = *vision->getTracker();
        ofxCv::ContourFinder& contourFinder = tracker.contourFinder;
        for(int i = 0; i < contourFinder.size(); i++) {
            auto rect = toOf(contourFinder.getBoundingRect(i));
            totalBlobArea += rect.getArea();
        }
    }
    if (isWindow()) {
        imageElement.update();
    }
}

void PaintboxScene::draw() {
    if (isWindow()) {
        imageElement.draw(ofRectangle(0, 0, ofGetWidth(), ofGetHeight()));
    }
    SceneBase::draw();
}

void PaintboxScene::drawMasterProjection() {
    ofSetColor(255);
    
    if (getIsActive()) {
        
        // contour tracker
        ContourTracker& tracker = *vision->getTracker();
        ofxCv::ContourFinder& contourFinder = tracker.contourFinder;
        float scale = displays->masterProjection.sizeIn->x / tracker.thresholded.width;
        float targetW = displays->masterProjection.sizeIn->x;
        float targetH = tracker.thresholded.height * scale;
        
        // start canvas FBO
        canvas.begin();
        for(int i = 0; i < contourFinder.size(); i++) {
            auto rect = toOf(contourFinder.getBoundingRect(i));
            auto center = toOf(contourFinder.getCenter(i));
            // label identifies specific blobs
            // use the label as a key for assigning colours
            int label = contourFinder.getLabel(i);
            ofSetColor(getColour(label));
            // in eraser mode, blobs above a certain size have specific colours
            // white acts as an eraser
            // black is, black.
            if (mode == ERASER) {
                float areaPercent = rect.getArea() / totalBlobArea;
                if (areaPercent >= minAreaEraser) {
                    ofSetColor(0);
                }
                if (areaPercent >= minAreaBlack) {
                    ofSetColor(255);
                }
            }
            // rotate the brush image to vary the painted lines
            ofPushMatrix();
            ofTranslate(center*scale);
            ofRotateZ(ofRandom(360));
            float scale = ofClamp((rect.width)/brushImage.width, 0.5, 4);
            int w = brushImage.width*scale;
            int h = brushImage.height*scale;
            brushImage.draw(-w/2, -h/2, w, h);
            ofPopMatrix();
        }
        ofSetColor(255);
        canvas.end();
    }
    
    canvas.draw(0,0);
}

//////////////////////////////////////////////////////////////////////////////////
// public
//////////////////////////////////////////////////////////////////////////////////
void PaintboxScene::play(int i){
    if (isMaster()) {
        vision->isEnabled = true;
    }
    switch (i) {
        case 63:
            if (isSlave()) {
                led->show(sleeping.get());
            }
            if (isMaster()) {
                countdown->start(timerIntro);
                setMode(INACTIVE);
                osc->sendLightingCue(lxCueIntro);
            }
            break;
        case 64:
            if (isSlave()) led->show(title.get());
            if (isMaster()) {
                countdown->start(timerLines);
                setMode(LINES);
                osc->sendSoundCue(soundCueSoundScape);
            }
            break;
        case 65:
            if (isSlave()) led->show(title.get());
            if (isMaster()) {
                countdown->start(timerErase);
                setMode(ERASER);
                osc->sendSoundCue(soundCueSoundScape2);
            }
            if (isWindow()) imageElement.hide();
            break;
        case 66:
            if (isSlave()) {
                led->hide();
                led->queue(LedDisplay::Params(back.get(), 0, 8, 0));
                led->queue(LedDisplay::Params(bonusTime.get(), 0, 6, 0));
                led->queue(LedDisplay::Params(bonusGame.get(), 0, 1, 0, false, 5));
                led->queue(LedDisplay::Params(goingDark.get(), 0, 1, 0));
                led->queue(LedDisplay::Params(pleaseEnjoy.get(), 0, 1, 0));
                led->queue(LedDisplay::Params(goingDark.get(), 0, 1, 0));
                led->queue(LedDisplay::Params(pleaseEnjoy.get(), 0, 1, 0));
                led->queue(LedDisplay::Params("", 0, 2, 0));
                led->playQueue();
            }
            if (isMaster()) {
                countdown->start(21);
                setMode(FADE);
                osc->sendSoundCue(soundCueOutro);
                osc->sendLightingCue(lxCueOutro);<commit_msg>Added a new title in the second Scene of paintbox (sub scene 65)<commit_after>//
//  PaintboxScene.cpp
//  show
//
//  Created by <NAME> on 05/09/2015.
//
//

#include "PaintboxScene.h"
using namespace ofxCv;
using namespace cv;

PaintboxScene::PaintboxScene() {
    name = "Paintbox";
}

void PaintboxScene::setup() {
    // subscenes
    subsceneStart = 63;
    subsceneEnd = 66;
    brushImage.loadImage("images/paintbrush/brush1.png");
    SceneBase::setup();
}

void PaintboxScene::update() {
    SceneBase::update();
    if (isMaster() && getIsActive()) {
        totalBlobArea = 0;
        ContourTracker& tracker = *vision->getTracker();
        ofxCv::ContourFinder& contourFinder = tracker.contourFinder;
        for(int i = 0; i < contourFinder.size(); i++) {
            auto rect = toOf(contourFinder.getBoundingRect(i));
            totalBlobArea += rect.getArea();
        }
    }
    if (isWindow()) {
        imageElement.update();
    }
}

void PaintboxScene::draw() {
    if (isWindow()) {
        imageElement.draw(ofRectangle(0, 0, ofGetWidth(), ofGetHeight()));
    }
    SceneBase::draw();
}

void PaintboxScene::drawMasterProjection() {
    ofSetColor(255);
    
    if (getIsActive()) {
        
        // contour tracker
        ContourTracker& tracker = *vision->getTracker();
        ofxCv::ContourFinder& contourFinder = tracker.contourFinder;
        float scale = displays->masterProjection.sizeIn->x / tracker.thresholded.width;
        float targetW = displays->masterProjection.sizeIn->x;
        float targetH = tracker.thresholded.height * scale;
        
        // start canvas FBO
        canvas.begin();
        for(int i = 0; i < contourFinder.size(); i++) {
            auto rect = toOf(contourFinder.getBoundingRect(i));
            auto center = toOf(contourFinder.getCenter(i));
            // label identifies specific blobs
            // use the label as a key for assigning colours
            int label = contourFinder.getLabel(i);
            ofSetColor(getColour(label));
            // in eraser mode, blobs above a certain size have specific colours
            // white acts as an eraser
            // black is, black.
            if (mode == ERASER) {
                float areaPercent = rect.getArea() / totalBlobArea;
                if (areaPercent >= minAreaEraser) {
                    ofSetColor(0);
                }
                if (areaPercent >= minAreaBlack) {
                    ofSetColor(255);
                }
            }
            // rotate the brush image to vary the painted lines
            ofPushMatrix();
            ofTranslate(center*scale);
            ofRotateZ(ofRandom(360));
            float scale = ofClamp((rect.width)/brushImage.width, 0.5, 4);
            int w = brushImage.width*scale;
            int h = brushImage.height*scale;
            brushImage.draw(-w/2, -h/2, w, h);
            ofPopMatrix();
        }
        ofSetColor(255);
        canvas.end();
    }
    
    canvas.draw(0,0);
}

//////////////////////////////////////////////////////////////////////////////////
// public
//////////////////////////////////////////////////////////////////////////////////
void PaintboxScene::play(int i){
    if (isMaster()) {
        vision->isEnabled = true;
    }
    switch (i) {
        case 63:
            if (isSlave()) {
                led->show(sleeping.get());
            }
            if (isMaster()) {
                countdown->start(timerIntro);
                setMode(INACTIVE);
                osc->sendLightingCue(lxCueIntro);
            }
            break;
        case 64:
            if (isSlave()) led->show(title.get());
            if (isMaster()) {
                countdown->start(timerLines);
                setMode(LINES);
                osc->sendSoundCue(soundCueSoundScape);
            }
            break;
        case 65:
            if (isSlave()) led->show("4. Phase 2: Link/Erase");
            if (isMaster()) {
                countdown->start(timerErase);
                setMode(ERASER);
                osc->sendSoundCue(soundCueSoundScape2);
            }
            if (isWindow()) imageElement.hide();
            break;
        case 66:
            if (isSlave()) {
                led->hide();
                led->queue(LedDisplay::Params(back.get(), 0, 8, 0));
                led->queue(LedDisplay::Params(bonusTime.get(), 0, 6, 0));
                led->queue(LedDisplay::Params(bonusGame.get(), 0, 1, 0, false, 5));
                led->queue(LedDisplay::Params(goingDark.get(), 0, 1, 0));
                led->queue(LedDisplay::Params(pleaseEnjoy.get(), 0, 1, 0));
                led->queue(LedDisplay::Params(goingDark.get(), 0, 1, 0));
                led->queue(LedDisplay::Params(pleaseEnjoy.get(), 0, 1, 0));
                led->queue(LedDisplay::Params("", 0, 2, 0));
                led->playQueue();
            }
            if (isMaster()) {
                countdown->start(21);
                setMode(FADE);
                osc->sendSoundCue(soundCueOutro);
                osc->sendLightingCue(lxCueOutro);
{'fraction_non_alphanumeric': 0.16277689873417722, 'fraction_numerical': 0.015031645569620253, 'mean_word_length': 1.5977395324942203, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '950516', 'n_tokens_mistral': 3062, 'n_tokens_neox': 2840, 'n_words': 572}