예제 #1
0
bool RunPackage::actionParser(char* s) const
{
  // send plain text to the log
  if ( strcmp(s, "Text") == 0){

    char* tok = strtok(NULL, "}");
    LogMessage msg;
    msg << tok;
    msg.send();
   
    return true;
  }
   
  // create a file link 
  if (strcmp(s, "Link") == 0){
    
    char* text = strtok(NULL, ",");
    char* filename = strtok(NULL, "}");
    
    LogMessage msg1;
    msg1 << Link(Chars( text ),
		 "Package",Chars(filename), true );
    msg1.send();
    
    ofstream colorf(Chars(filename)+Chars(".color"),ios::app);
    colorf << "#0000000%000@" << flush;
    colorf.close();
  
    return true;
  }



  
  // Create an object in the workspace
  if (strncmp("Create", s, strlen("Create")) == 0 ){
    
    // get object description and parent
    char* description = strtok(NULL, "|");
    
    Chars errMsg;

    // create a group
    if (strcmp(s, "CreateGroup")==0){
      FPGroup G;
      //@njz
      //      strstream ss;
      std::strstream ss;
      //
      ss << description << endl;
      ss >> G;
      
      SMFPGroup* smo =
	new SMFPGroup( G,Text("The group created from a package") );
      
      
      ListOf<OID> dependencies;
      CheckinMessage( *smo, "", dependencies ).send();
      return true;
    } else { // if not a group than ...
예제 #2
0
colorf colorf::lerp(const colorf& c1, const colorf& c2) const
{
    return colorf(c1.r * (1 - r) + c2.r*r,
	    c1.g * (1 - g) + c2.g*g,
	    c1.b * (1 - b) + c2.b*b,
	    c1.a * (1 - a) + c2.a * a);
}
예제 #3
0
ColorBank::Color ColorBank::color(DotPath const &path) const
{
    if (path.isEmpty()) return Color();
    Colorf col = colorf(path);
    return Color(round<dbyte>(col.x * 255),
                 round<dbyte>(col.y * 255),
                 round<dbyte>(col.z * 255),
                 round<dbyte>(col.w * 255));
}
예제 #4
0
bool ShaderProgram::setUniformValue(const std::string& name, const Vector3ub& v)
{
  GLint location = static_cast<GLint>(findUniform(name));
  if (location == -1) {
    m_error = "Could not set uniform " + name + ". No such uniform.";
    return false;
  }
  Vector3f colorf(v.cast<float>() * (1.0f / 255.0f));
  glUniform3fv(location, 1, colorf.data());
  return true;
}
예제 #5
0
파일: draw_perlin.c 프로젝트: Chr0nos/draw
void					draw_perlin_aa(SDL_Surface *surface)
{
	t_v2i			px;
	unsigned int	*pixels;

	pixels = surface->pixels;
	px.x = surface->w;
	while (px.x--)
	{
		px.y = surface->h;
		while (px.y--)
		{
			pixels[px.y * surface->w + px.x] = colorf(draw_perlin_aa_px((t_v2f){
				(float)px.x,
				(float)px.y}));
		}
	}
}
예제 #6
0
파일: draw_perlin.c 프로젝트: Chr0nos/draw
void					draw_perlin(SDL_Surface *surface)
{
	t_v2i			px;
	unsigned int	*pixels;

	pixels = surface->pixels;
	px.x = surface->w;
	while (px.x--)
	{
		px.y = surface->h;
		while (px.y--)
		{
			pixels[px.y * surface->w + px.x] = colorf(
				geo_clamp(geo_perlin((t_v2f){
				(float)px.x,
				(float)px.y}), 0.0f, 1.0f));
		}
	}
}
예제 #7
0
void lggBeamMaps::fireCurrentBeams(LLPointer<LLHUDEffectSpiral> mBeam, LLColor4U rgb)
{
    if(scale == 0.0f)return;

    for(int i = 0; i < (int)dots.size(); i++)
    {
        LLColor4U myColor = rgb;
        static LLCachedControl<std::string> scolorf(gSavedSettings, "PhoenixBeamColorFile");
        std::string colorf(scolorf);
        if(colorf == "===OFF===")
            myColor = dots[i].c;

        F32 distanceAdjust = dist_vec(mBeam->getPositionGlobal(),gAgent.getPositionGlobal()) ;
        F32 pulse = (F32)(.75f+sinf(gFrameTimeSeconds*1.0f)*0.25f);
        LLVector3d offset = dots[i].p;
        offset.mdV[VY] *= -1;
        offset *= pulse * scale * distanceAdjust * 0.1;

        //llinfos << "dist is " << distanceAdjust << "scale is " << scale << llendl;
        LLVector3 beamLine = LLVector3( mBeam->getPositionGlobal() - gAgent.getPositionGlobal());
        LLVector3 beamLineFlat = beamLine;
        beamLineFlat.mV[VZ]= 0.0f;

        LLVector3 newDirFlat = LLVector3::x_axis;
        beamLine.normalize();
        beamLineFlat.normalize();
        LLQuaternion change;
        change.shortestArc(newDirFlat,beamLineFlat);
        offset.rotVec(change);
        newDirFlat.rotVec(change);
        change.shortestArc(newDirFlat,beamLine);
        offset.rotVec(change);

        LLPointer<LLHUDEffectSpiral> myBeam =  (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM);
        myBeam->setPositionGlobal(mBeam->getPositionGlobal() + offset + (LLVector3d(beamLine) * sinf(gFrameTimeSeconds*2.0f) * 0.2f));

        myBeam->setColor(myColor);
        myBeam->setTargetObject(mBeam->getTargetObject());
        myBeam->setSourceObject(mBeam->getSourceObject());
        myBeam->setNeedsSendToSim(mBeam->getNeedsSendToSim());
        myBeam->setDuration(duration* 1.2f);
    }
}
예제 #8
0
	ColorHSLx<int, Color>::operator Color()
	{
		ColorHSLf hslf((float)h, (float)s / 255.0f, (float)l / 255.0f, (float)a / 255.0f);
		Colorf colorf(hslf);
		return colorf;
	}
예제 #9
0
void TestApp::test_hsv()
{
	Console::write_line(" Header: color_hsv.h");
	Console::write_line("  Class: ColorHSVi");
	
	Console::write_line("   Function: ColorHSVi()");
	{
		ColorHSVi hsv;
		if (hsv.h !=0) fail();
		if (hsv.s !=0) fail();
		if (hsv.v !=0) fail();
		if (hsv.a !=0) fail();
	}
	
	Console::write_line("   Function: ColorHSVi(int h, int s, int v, int a)");
	{
		ColorHSVi hsv(1,2,3,4);
		if (hsv.h != 1) fail();
		if (hsv.s != 2) fail();
		if (hsv.v != 3) fail();
		if (hsv.a != 4) fail();
	}
	
	Console::write_line("   Function: ColorHSVi(const ColorHSVi &copy)");
	{
		ColorHSVi hsv(1,2,3,4);
		ColorHSVi hsv_copy(hsv);
		if (hsv_copy.h != 1) fail();
		if (hsv_copy.s != 2) fail();
		if (hsv_copy.v != 3) fail();
		if (hsv_copy.a != 4) fail();
	}
	
	Console::write_line("   Function: ColorHSVi(const Color &color)");
	{
		Color color(255, 0, 0, 64);
		ColorHSVi hsv(color);
		if (hsv.h != 0) fail();
		if (hsv.s != 255) fail();
		if (hsv.v != 255) fail();
		if (hsv.a != 64) fail();
	}
	
	
	
	{
		Color color(128, 255, 128, 64);
		ColorHSVi hsv(color);
		if (hsv.h != 120) fail();
		if (hsv.s != 127) fail();
		if (hsv.v != 255) fail();
		if (hsv.a != 64) fail();
	}
	
	{
		Colorf colorf(0.5f, 1.0f, 0.5f, 1.0f);
		ColorHSVi hsv(colorf);
		if (hsv.h != 120) fail();
		if (hsv.s != 128) fail();
		if (hsv.v != 255) fail();
		if (hsv.a != 255) fail();
	}

	{
		Color color(0, 0, 128, 64);
		ColorHSVi hsv(color);
		if (hsv.h != 240) fail();
		if (hsv.s != 255) fail();
		if (hsv.v != 128) fail();
		if (hsv.a != 64) fail();
	}
	{
		Color color(64, 90, 136, 90);
		ColorHSVi hsv(color);
		if (hsv.h != 218) fail();
		if (hsv.s != 135) fail();
		if (hsv.v != 136) fail();
		if (hsv.a != 90) fail();
	}
	{
		Color color(128, 128, 128, 90);
		ColorHSVi hsv(color);
		if (hsv.h != 0) fail();
		if (hsv.s != 0) fail();
		if (hsv.v != 128) fail();
		if (hsv.a != 90) fail();
	}

	{
		Color color(64, 90, 136, 90);
		ColorHSVi hsv(color);
		Color color2(hsv);
		int red = color2.get_red();
		int green = color2.get_green();
		int blue = color2.get_blue();
		int alpha = color2.get_alpha();
		if (red != 64) fail();
		if (green != 90) fail();
		if (blue != 136) fail();
		if (alpha != 90) fail();

	}
	

	
	Console::write_line("  Class: ColorHSVf");

	Console::write_line("   Function: ColorHSVf()");
	{
		ColorHSVf hsv;
		if (hsv.h !=0.0f) fail();
		if (hsv.s !=0.0f) fail();
		if (hsv.v !=0.0f) fail();
		if (hsv.a !=0.0f) fail();
	}

	Console::write_line("   Function: ColorHSVf(float h, float s, float v, float a)");
	{
		ColorHSVf hsv(0.1f, 0.2f, 0.3f, 0.4f);
		if (hsv.h != 0.1f) fail();
		if (hsv.s != 0.2f) fail();
		if (hsv.v != 0.3f) fail();
		if (hsv.a != 0.4f) fail();
	}

	Console::write_line("   Function: ColorHSVf(const ColorHSVf &copy)");
	{
		ColorHSVf hsv(0.1f, 0.2f, 0.3f, 0.4f);
		ColorHSVf hsv_copy(hsv);
		if (hsv_copy.h != 0.1f) fail();
		if (hsv_copy.s != 0.2f) fail();
		if (hsv_copy.v != 0.3f) fail();
		if (hsv_copy.a != 0.4f) fail();
	}
	Console::write_line("   Function: ColorHSVf(const Colorf &color)");
	{
		Colorf color(1.0f, 0.0f, 0.0f, 0.2f);
		ColorHSVf hsv(color);
		if (hsv.h != 0.0f) fail();
		if (hsv.s != 1.0f) fail();
		if (hsv.v != 1.0f) fail();
		if (hsv.a != 0.2f) fail();
	}

	{
		Colorf color(0.5f, 1.0f, 0.5f, 0.2f);
		ColorHSVf hsv(color);
		if (hsv.h != 120.0f) fail();
		if (hsv.s != 0.5f) fail();
		if (hsv.v != 1.0f) fail();
		if (hsv.a != 0.2f) fail();
	}

	{
		Color color(127, 255, 127, 255);
		ColorHSVf hsv(color);
		if (hsv.h != 120.0f) fail();
		if (hsv.s < 0.49f) fail();
		if (hsv.s > 0.51f) fail();
		if (hsv.v != 1.0f) fail();
		if (hsv.a != 1.0f) fail();
	}

	{
		Colorf color(0.0f, 0.0f, 0.5, 0.3f);
		ColorHSVf hsv(color);
		if (hsv.h != 240.0f) fail();
		if (hsv.s != 1.0f) fail();
		if (hsv.v != 0.5f) fail();
		if (hsv.a != 0.3f) fail();
	}
	
	{
		Colorf color(0.2f, 0.4f, 0.7f, 0.3f);
		ColorHSVf hsv(color);
		Colorf color2(hsv);
		if (color.r < 0.1999f) fail();
		if (color.r > 0.2001f) fail();
		if (color.g < 0.3999f) fail();
		if (color.g > 0.4001f) fail();
		if (color.b < 0.6999f) fail();
		if (color.b > 0.7001f) fail();
		if (color.a < 0.2999f) fail();
		if (color.a > 0.3001f) fail();
	}
	
	Console::write_line("  Class: ColorHSVd");


}
예제 #10
0
colorf colorf::grey_value() const
{
    float c = (r * 0.299 + g * 0.587 + b * 0.114);
    return colorf(c, c, c, a);
}
예제 #11
0
colorf colorf::operator*(const colorf& c) const
{
    return colorf(r * c.r, g * c.g, b * c.b, a * c.a);
}
예제 #12
0
void TestApp::test_hsl()
{
    Console::write_line(" Header: color_hsl.h");
    Console::write_line("  Class: ColorHSLi");

    Console::write_line("   Function: ColorHSLi()");
    {
        ColorHSLi hsl;
        if (hsl.h !=0) fail();
        if (hsl.s !=0) fail();
        if (hsl.l !=0) fail();
        if (hsl.a !=0) fail();
    }

    Console::write_line("   Function: ColorHSLi(int h, int s, int l, int a)");
    {
        ColorHSLi hsl(1,2,3,4);
        if (hsl.h != 1) fail();
        if (hsl.s != 2) fail();
        if (hsl.l != 3) fail();
        if (hsl.a != 4) fail();
    }

    Console::write_line("   Function: ColorHSLi(const ColorHSLi &copy)");
    {
        ColorHSLi hsl(1,2,3,4);
        ColorHSLi hsl_copy(hsl);
        if (hsl_copy.h != 1) fail();
        if (hsl_copy.s != 2) fail();
        if (hsl_copy.l != 3) fail();
        if (hsl_copy.a != 4) fail();
    }
    Console::write_line("   Function: ColorHSLi(const Color &color)");
    {
        Color color(255, 0, 0, 64);
        ColorHSLi hsl(color);
        if (hsl.h != 0) fail();
        if (hsl.s != 255) fail();
        if (hsl.l != 128) fail();
        if (hsl.a != 64) fail();
    }

    {
        Color color(128, 255, 128, 64);
        ColorHSLi hsl(color);
        if (hsl.h != 120) fail();
        if (hsl.s != 255) fail();
        if (hsl.l < 191) fail();
        if (hsl.l > 192) fail();
        if (hsl.a != 64) fail();
    }

    {
        Colorf colorf(0.5f, 1.0f, 0.5f, 1.0f);
        ColorHSLi hsl(colorf);
        if (hsl.h != 120) fail();
        if (hsl.s != 255) fail();
        if (hsl.l != 191) fail();
        if (hsl.a != 255) fail();
    }

    {
        Color color(0, 0, 128, 64);
        ColorHSLi hsl(color);
        if (hsl.h != 240) fail();
        if (hsl.s != 255) fail();
        if (hsl.l != 64) fail();
        if (hsl.a != 64) fail();
    }
    {
        Color color(64, 90, 136, 90);
        ColorHSLi hsl(color);
        if (hsl.h != 218) fail();
        if (hsl.s != 92) fail();
        if (hsl.l != 100) fail();
        if (hsl.a != 90) fail();
    }
    {
        Color color(128, 128, 128, 90);
        ColorHSLi hsl(color);
        if (hsl.h != 0) fail();
        if (hsl.s != 0) fail();
        if (hsl.l != 128) fail();
        if (hsl.a != 90) fail();
    }

    {
        Color color(64, 90, 136, 90);
        ColorHSLi hsl(color);
        Color color2(hsl);
        int red = color2.get_red();
        int green = color2.get_green();
        int blue = color2.get_blue();
        int alpha = color2.get_alpha();
        if (red < 63) fail();
        if (red > 65) fail();
        if (green != 90) fail();
        if (blue != 136) fail();
        if (alpha != 90) fail();

    }

    Console::write_line("  Class: ColorHSLf");

    Console::write_line("   Function: ColorHSLf()");
    {
        ColorHSLf hsl;
        if (hsl.h !=0.0f) fail();
        if (hsl.s !=0.0f) fail();
        if (hsl.l !=0.0f) fail();
        if (hsl.a !=0.0f) fail();
    }

    Console::write_line("   Function: ColorHSLf(float h, float s, float l, float a)");
    {
        ColorHSLf hsl(0.1f, 0.2f, 0.3f, 0.4f);
        if (hsl.h != 0.1f) fail();
        if (hsl.s != 0.2f) fail();
        if (hsl.l != 0.3f) fail();
        if (hsl.a != 0.4f) fail();
    }

    Console::write_line("   Function: ColorHSLf(const ColorHSLf &copy)");
    {
        ColorHSLf hsl(0.1f, 0.2f, 0.3f, 0.4f);
        ColorHSLf hsl_copy(hsl);
        if (hsl_copy.h != 0.1f) fail();
        if (hsl_copy.s != 0.2f) fail();
        if (hsl_copy.l != 0.3f) fail();
        if (hsl_copy.a != 0.4f) fail();
    }
    Console::write_line("   Function: ColorHSLf(const Colorf &color)");
    {
        Colorf color(1.0f, 0.0f, 0.0f, 0.2f);
        ColorHSLf hsl(color);
        if (hsl.h != 0.0f) fail();
        if (hsl.s != 1.0f) fail();
        if (hsl.l != 0.5f) fail();
        if (hsl.a != 0.2f) fail();
    }

    {
        Colorf color(0.5f, 1.0f, 0.5f, 0.2f);
        ColorHSLf hsl(color);
        if (hsl.h != 120.0f) fail();
        if (hsl.s != 1.0f) fail();
        if (hsl.l != 0.75f) fail();
        if (hsl.a != 0.2f) fail();
    }

    {
        Color color(127, 255, 127, 255);
        ColorHSLf hsl(color);
        if (hsl.h != 120.0f) fail();
        if (hsl.s != 1.0f) fail();
        if (hsl.l < 0.74f) fail();
        if (hsl.l > 0.76f) fail();
        if (hsl.a != 1.0f) fail();
    }

    {
        Colorf color(0.0f, 0.0f, 0.5, 0.3f);
        ColorHSLf hsl(color);
        if (hsl.h != 240.0f) fail();
        if (hsl.s != 1.0f) fail();
        if (hsl.l < 0.24f) fail();
        if (hsl.l > 0.26f) fail();
        if (hsl.a != 0.3f) fail();
    }

    {
        Colorf color(0.2f, 0.4f, 0.7f, 0.3f);
        ColorHSLf hsl(color);
        Colorf color2(hsl);
        if (color.r < 0.1999f) fail();
        if (color.r > 0.2001f) fail();
        if (color.g < 0.3999f) fail();
        if (color.g > 0.4001f) fail();
        if (color.b < 0.6999f) fail();
        if (color.b > 0.7001f) fail();
        if (color.a < 0.2999f) fail();
        if (color.a > 0.3001f) fail();
    }


}