Exemplo n.º 1
0
void hue_to_rgb(double hue, unsigned char * color)
{
	ColorRGB c = HSL2RGB(hue,1.0,0.5);
	color[0] = c.R;
	color[1] = c.G;
	color[2] = c.B;
}
Exemplo n.º 2
0
void ColorizeOperator::process(int tick)
{
    if (texture == 0)
        texture = new Texture();

    Texture* srcTexture = getInput(0)->texture;
    texture->lock();
    srcTexture->lock();

    float hue = getByteProperty(0) / 256.0f;
    float saturation = getByteProperty(1) / 256.0f ;
    float light = (getByteProperty(2) - 128) / 128.0f;

    for (int y = 0; y < 256; y++)
    {
        for (int x = 0; x < 256; x++)
        {
            float h, s, l;
            D3DCOLOR srcColor = srcTexture->getPixel(x, y);
            RGB2HSL(D3DCOLOR_R(srcColor),
                    D3DCOLOR_G(srcColor),
                    D3DCOLOR_B(srcColor),
                    h,
                    s,
                    l);
            int r, g, b;
            HSL2RGB(hue, saturation, l + light, r, g, b);
            texture->putPixel(x, y, D3DCOLOR_XRGB(r, g, b));
        }
    }

    texture->unlock();
    srcTexture->unlock();
    texture->setDirty();
}
void PolarGridRenderer::render() {
    if(m_grid) {
        glPushMatrix();
        glTranslatef(0.f, 0.f, m_depth);
        if(m_position) {
            glTranslatef(m_position->x, m_position->y, 0.f);
            glRotatef(rad2deg(m_position->theta), 0.f, 0.f, 1.f);
        }
        double sweep = 2*M_PI/(m_phiEdges->size() - 1);
        for(unsigned int i = 0; i < m_grid->size(); i ++) {
            for(unsigned int j = 0; j < (*m_grid)[i].size(); j++) {
                glPushMatrix();
                m_color.lightness() = m_maxValue == 0.? 1. : 1. - 0.5*(*m_grid)[i][j]/m_maxValue;
                Color color(HSL2RGB(m_color));
                double inner = (*m_rhoEdges)[j];
                double outer = (*m_rhoEdges)[j+1];
                double start = -(*m_phiEdges)[i] + M_PI_2;
                glColor4f(color.red(), color.green(), color.blue(), color.alpha());
                gluQuadricDrawStyle(m_GLUSectors[i * (*m_grid)[i].size() + j], GLU_FILL);
                gluPartialDisk(m_GLUSectors[i * (*m_grid)[i].size() + j], inner, outer, m_subdivision[0], m_subdivision[1], rad2deg(start), rad2deg(-sweep));
                glColor4f(0.f, 0.f, 0.f, 1.f);
                gluQuadricDrawStyle(m_GLUGrids[i * (*m_grid)[i].size() + j], GLU_SILHOUETTE);
                gluPartialDisk(m_GLUGrids[i * (*m_grid)[i].size() + j], inner, outer, m_subdivision[0], m_subdivision[1], rad2deg(start), rad2deg(-sweep));
                glPopMatrix();
            }
        }
        glColor4f(0.f,0.f,0.f,1.f);
        glBegin(GL_LINES);
        glVertex3f(0.f, 0.f, 0.f);
        glVertex3f((*m_rhoEdges)[m_rhoEdges->size() - 1] + 0.1f, 0.f, 0.f);
        glEnd();
        glPopMatrix();
    }
}
Exemplo n.º 4
0
static void CG_DrawFPS( float x, float y, float w, float h, int font, float textScale ) {
	char		*s;
	static unsigned short previousTimes[FPS_FRAMES];
	static unsigned short index;
	static int	previous, lastupdate;
	int		t, i, fps, total;
	unsigned short frameTime;
#ifdef _XBOX
	const int		xOffset = -40;
#else
	//const int		xOffset = 0;
#endif
	vec4_t	fpscolor;

	// don't use serverTime, because that will be drifting to
	// correct for internet lag changes, timescales, timedemos, etc
	t = trap_Milliseconds();
	frameTime = t - previous;
	previous = t;
	if (t - lastupdate > 50)	//don't sample faster than this
	{
		lastupdate = t;
		previousTimes[index % FPS_FRAMES] = frameTime;
		index++;
	}
	// average multiple frames together to smooth changes out a bit
	total = 0;
	for ( i = 0 ; i < FPS_FRAMES ; i++ ) {
		total += previousTimes[i];
	}
	if ( !total ) {
		total = 1;
	}
	fps = 1000 * FPS_FRAMES / total;

    s = va( "%i fps", fps );
    if (cg_drawFPS.integer == 2) {
        Q_strcat (s, 64, va ("\n%.3f mspf", (float)total / (float)FPS_FRAMES));
    }
	if (fps < 10) {
		VectorSet(fpscolor, 1, 0, 0);
	} else if (fps > 50) {
		VectorSet(fpscolor, 0, 1, 0);
	} else {
		int hue = (fps - 10) * 3; //(0 to 120)
		HSL2RGB((float)hue/360, 1, 0.5f, &fpscolor[0], &fpscolor[1], &fpscolor[2]);
	}
	fpscolor[3] = 1;

	//w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;

	trap_R_Font_DrawString(x, y, s, fpscolor, font | STYLE_DROPSHADOW, -1, textScale);
	//CG_DrawBigString( 635 - w + xOffset, y + 2, s, 1.0F);
}
Exemplo n.º 5
0
Color RGBAdjustHSL(Color col, double h, double s, double l) {
	ColorHSL hsl;
	Color rgb = col;
	hsl = RGB2HSL(rgb);
	hsl.h = hsl.h + h / 360.0;
	while (hsl.h > 1) hsl.h -= 1;
	while (hsl.h < 0) hsl.h += 1;
	hsl.s = hsl.s + s;
	if (hsl.s > 1) hsl.s = 1;
	if (hsl.s < 0) hsl.s = 0;
	hsl.l = hsl.l * l;
	if (hsl.l > 1) hsl.l = 1;
	if (hsl.l < 0) hsl.l = 0;
	rgb = HSL2RGB(hsl);
	rgb.alpha = col.alpha;
	return rgb;
}
Exemplo n.º 6
0
global func HSLa(int h, int s, int l, int a) { return  HSL2RGB(RGB(h, s, l)) ^ ~(a & 255) << 24; }
Exemplo n.º 7
0
// documented in /docs/sdk/script/fn
global func HSL(int h, int s, int l)  { return HSL2RGB(RGB(h, s, l)); }
Exemplo n.º 8
0
protected func Initialize()
{
	_inherited();
	SetClrModulation(HSL2RGB(RGB(RandomX(0,255),RandomX(100,200),150)));
}