std::array<SDL_Color, 8> CCreatureAnimation::genSpecialPalette()
{
	std::array<SDL_Color, 8> ret;

	ret[0] = genShadow(0);
	ret[1] = genShadow(64);
	ret[2] = genShadow(128);
	ret[3] = genShadow(128);
	ret[4] = genShadow(128);
	ret[5] = genBorderColor(getBorderStrength(elapsedTime), border);
	ret[6] = addColors(genShadow(128), genBorderColor(getBorderStrength(elapsedTime), border));
	ret[7] = addColors(genShadow(64),  genBorderColor(getBorderStrength(elapsedTime), border));

	return ret;
}
Example #2
0
/**
   Sets the current color
 */
void ColorCombo::setColor( const QColor &col )
{
  internalcolor = col;
  hascolor = true;

  addColors();
}
Example #3
0
//--------------------------------------------------------------
void testApp::update(){
	
	if(puntos.size()>nPuntosBase) {
		triangulation.reset();
		
		// mover puntos
		for(int i=nPuntosBase;i<puntos.size();i++) {
			puntos[i] += vels[i];
			ofPoint pt = puntos[i]-zentro;
			if(pt.length()>radio) {
				float angPos = atan2(pt.y, pt.x);
				puntos[i] = ofPoint(radio*0.95*cos(angPos), radio*0.95*sin(angPos));
				puntos[i]+=zentro;
				// angulo entre veloc y nueva posic
				float angRel = pt.angle(vels[i]); // degrees (-180,180)
				vels[i].rotate(2*angRel, ofVec3f(0,0,1));// = ofPoint(-vels[i].y, -vels[i].x);				
				
//				vels[i] = ofPoint(-vels[i].y, -vels[i].x);				
			}
		}
		
		// update Triang
		triangulation.addPoints(puntos);
		triangulation.triangulate();
		addColors();		
	
	}

}
Example #4
0
ColorList& ColorList::operator= (const ColorList& list)
{
	clear();
	if (!m_retainDoc)
		m_doc = list.m_doc;
	addColors(list);
	return *this;
}
Example #5
0
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){

	if(button==2) {
		puntos.push_back(ofPoint(x,y));
		int npts = triangulation.addPoint(ofPoint(x,y));
		triangulation.triangulate();
		addColors();
	}
}
Example #6
0
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableSmoothing();
    ofBackground(0);
    
	bFill = true;
	
	setupColores();
	myMesh.clear();
	
	puntos.clear();
	vels.clear();
	
	// poner puntos en circulo
	nPuntosBase=0;
	zentro = ofVec2f(ofGetWidth()/2.0, ofGetHeight()/2.0);
	radio = ofGetHeight()/2.0*0.8;
	for(int i=0; i<60; i++) {
		float ang=(float)TWO_PI/60.0*i;
		puntos.push_back(ofPoint(zentro.x+radio*cos(ang), zentro.y+radio*sin(ang)));
		vels.push_back(ofPoint(0,0));
		
		nPuntosBase++;
	}
	// poner cuadricula de puntos
	int nLado = 11;
	float lado = 2*radio;
	for(int j=0; j<nLado; j++) {
		for(int i=0; i<nLado; i++) {
			ofPoint pTmp = ofPoint(-lado/2+i*lado/nLado,-lado/2+j*lado/nLado);
			if(pTmp.length()<radio) {
				pTmp+=zentro;
				puntos.push_back(pTmp);
				vels.push_back(ofPoint(0,0));
				nPuntosBase++;
			}
		}
	}
	
	
//	int nPtsMoviles = 1;
//	for(int i=0; i<nPtsMoviles; i++) {
	addPart();
//	}
	
//	radio1 = ofGetHeight()/2.0*0.25;
//	for(int i=0; i<60; i++) {
//		float ang=(float)TWO_PI/60.0*i;
//		puntos.push_back(ofPoint(zentro.x+radio1*cos(ang), zentro.y+radio1*sin(ang)));
//		vels.push_back(ofPoint(ofRandom(-2,2), ofRandom(-2,2)) );
//	}
	
	triangulation.addPoints(puntos);
	triangulation.triangulate();
	addColors();
}
Example #7
0
Color hitScene(struct Scene* scene, struct HitRecord* record, Ray ray, int depth){
    Color result = {0, 0, 0};
    for(int k = 0; k < scene->num_triangles; k++){
        hitTriangle(&scene->triangles[k], record, ray);
    }

    if(record->has_hit){
        result = addColors(result, shadeWithMaterial(scene, record, ray, depth));
    }

    return result;
}
Example #8
0
void ColorCombo::setColorName( const QString &color )
{

  QColor c(color);

  if ( c.isValid() && !color.isEmpty() ) {
    setColor( c );
  }
  else {
    hascolor = false;
    addColors();
  }

}
Example #9
0
ColorCombo::ColorCombo( QWidget *parent, const char *name )
  : QComboBox( parent, name )
{
  customColor.setRgb( 255, 255, 255 );
  internalcolor.setRgb( 255, 255, 255 );

  hascolor = false;

  createStandardPalette();

  addColors();

  connect( this, SIGNAL( activated(int) ), SLOT( slotActivated(int) ) );
  connect( this, SIGNAL( highlighted(int) ), SLOT( slotHighlighted(int) ) );
}
Example #10
0
ColorCombo::ColorCombo( ColorScheme colorScheme, QWidget *parent, const char *name )
	: QComboBox( parent, name )
{
	m_colorScheme = colorScheme;
	
	customColor.setRgb( 255, 255, 255 );
	internalColor.setRgb( 255, 255, 255 );

	createPalettes();

	addColors();

	connect( this, SIGNAL( activated(int) ), SLOT( slotActivated(int) ) );
	connect( this, SIGNAL( highlighted(int) ), SLOT( slotHighlighted(int) ) );
}
Example #11
0
Color shadeWithMaterial(struct Scene* scene, struct HitRecord* record, Ray ray, int depth) {
    Color result = {0,0,0};
    Material material = *record->triangle->material;
    struct HitRecord temp_record = createHitRecord();
    Vector position = record->point;
    Vector new_direction;

    if(depth == scene->max_depth) {
        return result;
    }

    if(material.is_light) {
        return material.color;
    }

    Vector normal = record->triangle->normal;
    float costheta = dotVector(normal, ray.direction);

    if(costheta > 0) {
        normal = negateVector(normal);
    }

    float path = (double)rand()/(double)RAND_MAX;

    // diffuse BRDF
    if(path < .33) {
        new_direction = getDiffuseDirection(normal);
    }
    // BRDF (which is also diffuse)
    else if(path < .66) {
        new_direction = getDiffuseDirection(normal);
    }
    // point to light
    else {
        new_direction = getLightDirection(scene, position);
    }

    Ray new_ray = {position, new_direction};
    resetHitRecord(&temp_record);
    float cosphi = dotVector(normal, new_direction);

    if(cosphi > 0) {
        result = addColors(result, multiplyColorByNumber(hitScene(scene, &temp_record, new_ray, depth + 1), cosphi));
    }

    return multiplyColors(result, material.color);
}
Example #12
0
void renderScene(Scene* scene){
	Color final_color;
	HitRecord record = createHitRecord();
    Sample sample = createSample(scene->num_samples);

    Color black = {0, 0, 0};

    int xres = scene->image.width;
    int yres = scene->image.height;

	for(int i = 0; i < xres; i++){
		for(int j = 0; j < yres; j++){

            getSamples(&sample);
            applyFilter(&sample);

            final_color = black;

            int hit_count = 0;
            for(int k = 0; k < scene->num_samples; k++){
                double x = 2 * (i - xres/2. + sample.samples[k].x)/xres;
                double y = 2 * (j - yres/2. + sample.samples[k].y)/yres;

                Ray ray = cameraCreateRay(&scene->camera, x, -y);
                resetHitRecord(&record);
                Color result = hitScene(scene, &record, ray, 0);
                if(result.red != 0 || result.green != 0 || result.blue != 0){
                    final_color = addColors(final_color, result);
                    hit_count++;
                }
            }

            if(hit_count > 0){
                final_color = multiplyColorByNumber(final_color, 1.0 / (double)hit_count);
            }

			setImageColor(&scene->image, i, j, final_color);
		}
	}
}
Example #13
0
void ColorList::copyColors(const ColorList& colorList, bool overwrite)
{
	clear();
	addColors(colorList, overwrite);
}
Example #14
0
void ColorCombo::setColor( const QColor &col )
{
	internalColor = col;
	addColors();
}
Example #15
0
//--------------------------------------------------------------
void ofxFatLine::add(const vector<ofVec3f> &thePoints, const vector<ofFloatColor> &theColors, const vector<double> &theWeights){
    addVertices(thePoints);
    addColors(theColors);
    addWeights(theWeights);
    update();
}
Example #16
0
void ColorCombo::resizeEvent( QResizeEvent *re )
{
  QComboBox::resizeEvent( re );

  addColors();
}
Example #17
0
/**
   Sets the current color
 */
void KColorCombo::setColor( const QColor &col )
{
	internalcolor = col;
	d->showEmptyList=false;
	addColors();
}
Example #18
0
/**
   Show an empty list, till the next color is set with setColor
 */
void KColorCombo::showEmptyList()
{
	d->showEmptyList=true;
	addColors();
}