예제 #1
0
static unsigned int	color_algorithm(t_env *env, t_complexe *z, int i)
{
	if (env->color == 0)
		return (hsv_to_rgb(i / (double)env->iter_max * 360, 0.6, 1));
	else if (env->color == 1)
		return (linear_interpolation(env, i));
	else
		return (hsv_to_rgb(i / (double)env->iter_max * 360,
					fmod(z->img, 1), 1));
}
예제 #2
0
파일: mandelbrot.c 프로젝트: madeka/fractol
static unsigned int	color_algorithm(t_env *env, double n, t_complexe *z, int i)
{
	double	color;

	n = sqrt(n);
	color = i - (log(log(n)) / log(1.9));
	color = fmod(color, 360);
	if (env->color == 0)
		return (hsv_to_rgb(color, 0.6, 1));
	else if (env->color == 1)
		return (hsv_to_rgb(i / (double)env->iter_max * 360, 0.6, 1));
	else
		return (hsv_to_rgb(color, fmod(z->img, 1), 1));
}
예제 #3
0
파일: ccolor.C 프로젝트: anilkunwar/OOF2
CHSVColor::CHSVColor(double h, double s, double v) {
  Triple rgb = hsv_to_rgb(h, s, v);
  red_ = rgb.x;
  green_ = rgb.y;
  blue_ = rgb.z;
  hsv = Triple(h, s, v);
}
예제 #4
0
파일: skimage.c 프로젝트: Scrik/sk1-wx
PyObject *
fill_hsv_z(PyObject * self, PyObject * args)
{
    ImagingObject * image;
    int x, y, width, height;
    int idx;
    double hsv[3];
    unsigned char *dest;


    if (!PyArg_ParseTuple(args, "Oi(ddd)", &image, &idx,
			  &hsv[0], &hsv[1], &hsv[2]))
	return NULL;

    if (idx < 0 || idx > 2)
    {
	PyErr_SetString(PyExc_ValueError, "idx must be in the range [0,2]");
	return NULL;
    }

    width = image->image->xsize - 1;
    height = image->image->ysize - 1;
    for (y = 0; y <= height; y++)
    {
	dest = (unsigned char*)(image->image->image32[y]);
	for (x = 0; x <= width; x++, dest += 4)
	{
	    hsv[idx] = (double)(height - y) / height;
	    hsv_to_rgb(hsv[0], hsv[1], hsv[2], dest);
	}
    }

    Py_INCREF(Py_None);
    return Py_None;
}
예제 #5
0
void worm::render_flip(BITMAP* where, int frame, int _x, int _y)
{
  int r,g,c,R,G,B,i;
  float h1,s1,v1,h,s,v;
  for (i=0;i<skin->img[frame]->w;i++)
  {
    for (r=0;r<skin->img[frame]->h;r++)
    {
      g=getpixel(skin->img[frame],i,r);
      c=getpixel(mask->img[frame],i,r);
      if(g!=makecol(255,0,255))
      {
        if(c!=makecol(255,0,255))
        {
          c=color;
          rgb_to_hsv(getr(c), getg(c), getb(c), &h1, &s1, &v1);
          
          R = getr(g);
          G = getg(g);
          B = getb(g);
          
          rgb_to_hsv(R, G, B, &h, &s, &v);
          h = h1;
          s = s1;
          v -= (1-v1)/1.4;
          if (v<0)v=0;
          
          hsv_to_rgb(h,s,v, &R, &G, &B);
          g = makecol(R,G,B);
          putpixel(where,_x+skin->img[frame]->w-1-i,_y+r,g);
        }else putpixel(where,_x+skin->img[frame]->w-1-i,_y+r,g);
      };
    };
  };
};
예제 #6
0
파일: main.c 프로젝트: x37v/rs485_leds
int main(void) {
   //init our pwm and uart inputs
   init_pwm_and_uart();

   draw_rgb(0,0,16);

   while (1) {
      uint8_t hsv[3];
      uint8_t rgb[3];
      uint8_t buf[4];

      //grab 4 bytes from the uart.. its actually 8 bytes but they are ascii,
      //converted in pairs to uint8_t
      ascii_uart_to_uint_buffer(buf, 4);

      //if the first value matches our address or the broadcast address, work with it
      if (buf[0] == my_addr || buf[0] == broadcast_address) {
         hsv[0] = buf[1];
         hsv[1] = buf[2];
         hsv[2] = buf[3];

         //convert to rgb and draw
         hsv_to_rgb(rgb, hsv);
         draw_rgb(rgb[0], rgb[1], rgb[2]);
      }
   }
}
예제 #7
0
파일: image.c 프로젝트: renmengye/darknet
void saturate_image(image im, float sat)
{
    rgb_to_hsv(im);
    scale_image_channel(im, 1, sat);
    hsv_to_rgb(im);
    constrain_image(im);
}
예제 #8
0
static void
random_trig (Display *dpy, Window window, struct state *st,
             XColor *color, Bool *got_color)
{
  st->d_angle = 0;
  st->factor1 = (random() % 8) + 1;
  do {
    st->factor2 = (random() % 8) + 1;
  } while (st->factor1 == st->factor2);

  st->dir = (random() & 1) ? 1 : -1;
  st->d_angle_offset = random() % 360;
  st->offset = ((random() % ((360 / 4) - 1)) + 1) / 4;
  st->density = 1 << ((random() % 4) + 4);	/* Higher density, higher angles */

  if (mono_p)
    XSetForeground (dpy, st->draw_gc, st->default_fg_pixel);
  else
    {
      hsv_to_rgb (random () % 360, frand (1.0), frand (0.5) + 0.5,
		  &color->red, &color->green, &color->blue);
      if ((*got_color = XAllocColor (dpy, st->cmap, color)))
	XSetForeground (dpy, st->draw_gc, color->pixel);
      else
	XSetForeground (dpy, st->draw_gc, st->default_fg_pixel);
    }

  XClearWindow (dpy, window);
}
예제 #9
0
static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac)
{
	float hsv[3], rgb[3], f;
	const float mfac = 1.f-*fac;
	
	rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
	
	/* adjust hue, scaling returned default 0.5 up to 1 */
	f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
	hsv[0] += f-0.5f;
	
	/* adjust saturation, scaling returned default 0.5 up to 1 */
	f = curvemapping_evaluateF(node->storage, 1, hsv[0]);
	hsv[1] *= (f * 2.f);
	
	/* adjust value, scaling returned default 0.5 up to 1 */
	f = curvemapping_evaluateF(node->storage, 2, hsv[0]);
	hsv[2] *= (f * 2.f);
	
	hsv[0] = hsv[0] - floor(hsv[0]);  /* mod 1.0 */
	CLAMP(hsv[1], 0.f, 1.f);
	
	/* convert back to rgb */
	hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
	
	out[0]= mfac*in[0] + *fac*rgb[0];
	out[1]= mfac*in[1] + *fac*rgb[1];
	out[2]= mfac*in[2] + *fac*rgb[2];
	out[3]= in[3];
}
예제 #10
0
파일: starfield.c 프로젝트: msikma/ceegee
/**
 * Returns the palette used for the starfield.
 *
 * The colors are generated by picking SHADES number of hues
 * and adding LUM_N number of variants of that hue to the palette.
 */
RGB *get_starfield_palette() {
    int a, sha, lum, r, g, b, offset;
    RGB *pal;

    pal = malloc(sizeof(PALETTE));

    // Set all skipped colors to black.
    for (a = 0; a < SHADES_OFFSET; ++a) {
        pal[a].r = pal[a].g = pal[a].b = 0;
    }

    // Add several color swatches and their darker variants.
    for (sha = 0; sha < SHADES; ++sha) {
        offset = (sha * LUM_N) + SHADES_OFFSET;
        for (lum = 0; lum < LUM_N; ++lum) {
            hsv_to_rgb((COUNTER_MAX / SHADES) * sha, 1, LUMS[lum], &r, &g, &b);
            pal[offset + lum].r = r / 4;
            pal[offset + lum].g = g / 4;
            pal[offset + lum].b = b / 4;
        }
    }

    // Fill the rest of the palette with white.
    for (a = SHADES_OFFSET + (SHADES * LUM_N); a < PAL_SIZE; ++a) {
        pal[a].r = 63;
        pal[a].g = 63;
        pal[a].b = 63;
    }

    return pal;
}
예제 #11
0
static void colorwheel_plot_point ( guchar * data,
                                    HSV hsv,
                                    gfloat radius,
                                    gfloat angle,
                                    gint rowstride,
                                    gint x,
                                    gint y ) {
    int offset;
    RGB rgb;
    if (angle > 2*M_PI) {
        angle -= 2*M_PI;
    } else if (angle < 0) {
        angle += 2*M_PI;
    }
    /* Yep, folks -- hue is 0...6, not 0...2pi! */
    hsv.H = (angle / (2*M_PI)) * 6.0;
    hsv.S = radius;

    hsv.V = 1;
    
    rgb = hsv_to_rgb (hsv);
    offset = rowstride * y + 4 * x;
    data[offset] =   MAX(0, MIN(255, rgb.R * 255));
    data[offset+1] = MAX(0, MIN(255, rgb.G * 255));
    data[offset+2] = MAX(0, MIN(255, rgb.B * 255));
    data[offset+3]=255;
}
예제 #12
0
static void get_color (gint i, gfloat * r, gfloat * g, gfloat * b)
{
    static GdkRGBA c;
    static bool_t valid = FALSE;
    gfloat h, s, v, n;

    if (! valid)
    {
        /* we want a color that matches the current theme
         * selected color of a GtkEntry should be reasonable */
        GtkStyleContext * style = gtk_style_context_new ();
        GtkWidgetPath * path = gtk_widget_path_new ();
        gtk_widget_path_append_type (path, GTK_TYPE_ENTRY);
        gtk_style_context_set_path (style, path);
        gtk_widget_path_free (path);
        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, & c);
        g_object_unref (style);
        valid = TRUE;
    }

    rgb_to_hsv (c.red, c.green, c.blue, & h, & s, & v);

    if (s < 0.1) /* monochrome theme? use blue instead */
    {
        h = 5;
        s = 0.75;
    }

    n = i / (gfloat) (bands - 1);
    s = 1 - 0.9 * n;
    v = 0.75 + 0.25 * n;

    hsv_to_rgb (h, s, v, r, g, b);
}
static void node_composit_exec_combhsva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
	/* stack order out: 1 rgba channels */
	/* stack order in: 4 value channels */

	/* input no image? then only color operation in HSV */
	if ((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) {
		hsv_to_rgb(in[0]->vec[0], in[1]->vec[0], in[2]->vec[0],
		&out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]);
		out[0]->vec[3] = in[3]->vec[0];
	}
	else {
		/* make output size of first available input image */
		CompBuf *cbuf;
		CompBuf *stackbuf;

		/* allocate a CompBuf the size of the first available input */
		if (in[0]->data) cbuf = in[0]->data;
		else if (in[1]->data) cbuf = in[1]->data;
		else if (in[2]->data) cbuf = in[2]->data;
		else cbuf = in[3]->data;

		stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */

		composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec,
		in[2]->data, in[2]->vec, in[3]->data, in[3]->vec,
		do_comb_hsva, CB_VAL, CB_VAL, CB_VAL, CB_VAL);

		out[0]->data= stackbuf;
	}
}
예제 #14
0
void calc_mandel(double mandel_scale, double mandel_cx, double mandel_cy, rgb_t *mandel_tex, int mandel_tex_w,
		int mandel_max_iter, int mandel_width, int mandel_height_start, int mandel_height_end, int mandel_height)
{
	int i, j, iter, min, max;
	double x, y, zx, zy, zx2, zy2;
	for (i = mandel_height_start; i < mandel_height_end; i++) {
		y = (i - mandel_height/2) * mandel_scale + mandel_cy;
		for (j = 0; j  < mandel_width; j++, mandel_tex++) {
			x = (j - mandel_width/2) * mandel_scale + mandel_cx;
			iter = 0;
 
			if ((x + 1)*(x + 1) + y * y < 1/16) iter = mandel_max_iter;
 
			zx = zy = zx2 = zy2 = 0;
			for (; iter < mandel_max_iter && zx2 + zy2 < 4; iter++) {
				zy = 2 * zx * zy + y;
				zx = zx2 - zy2 + x;
				zx2 = zx * zx;
				zy2 = zy * zy;
			}
			hsv_to_rgb(iter, 0, mandel_max_iter, mandel_tex);
		}
		mandel_tex += (mandel_tex_w - mandel_width);
	}
}
예제 #15
0
static uint8_t tick(void) {
    static uint16_t a = 0;

    uint8_t x, y;

    uint8_t sin1 = sini(a+512);
    uint8_t sin2 = sini(a*2);
    uint16_t sin3 = sini(a*3)<<8;

    for(y = 0; y < LED_HEIGHT; y++)
    {
        uint16_t y_part = h = 128*sini(sin2+y*20)  + sin3;

        for(x = 0; x < LED_WIDTH; x++)
        {
            h = 128*sini(sin1+x*30)+ y_part;
            hsv_to_rgb();
            setLedXY(x, y, nr>>2,ng>>2,nb>>2);
        }
    }
    a++;
    if(a==1024)
    {
        a=0;
    }
    return 0;
}
예제 #16
0
파일: ggob.cpp 프로젝트: argarak/tw-light
void RainbowRift::squiggle()
{
	STACKTRACE;
	int i;
	int m = n*6+2;
	for (i = 0; i < m - 6; i += 1) {
		p[i] = p[i+6];
	}
	p[m-6] = p[m-8] * 2 - p[m-10];
	p[m-5] = p[m-7] * 2 - p[m-9];
	p[m-4] = 75 + random(150.0);
	p[m-3] = 75 + random(150.0);
	p[m-2] = 75 + random(150.0);
	p[m-1] = 75 + random(150.0);
	for (i = 0; i < n-1; i += 1) {
		c[i] = c[i+1];
	}
	int r, g, b;
	r = int(game->game_time * 0.5) % 360;
	hsv_to_rgb( r, 1.0, 1.0, &r, &g, &b );
	c[n-1].r = r;
	c[n-1].g = g;
	c[n-1].b = b;
	return;
}
예제 #17
0
static void do_huecorrect(bNode *node, float *out, float *in)
{
	float hsv[3], f;
	
	rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
	
	/* adjust hue, scaling returned default 0.5 up to 1 */
	f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
	hsv[0] += f-0.5f;
	
	/* adjust saturation, scaling returned default 0.5 up to 1 */
	f = curvemapping_evaluateF(node->storage, 1, hsv[0]);
	hsv[1] *= (f * 2.f);
	
	/* adjust value, scaling returned default 0.5 up to 1 */
	f = curvemapping_evaluateF(node->storage, 2, hsv[0]);
	hsv[2] *= (f * 2.f);
	
	hsv[0] = hsv[0] - floor(hsv[0]); /* mod 1.0 */
	CLAMP(hsv[1], 0.f, 1.f);
	
	/* convert back to rgb */
	hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2);
	
	out[3]= in[3];
}
예제 #18
0
파일: plasma.c 프로젝트: ETroll/toaruos
void * draw_thread(void * garbage) {
	(void)garbage;

	double time = 0;

	/* Generate a palette */
	uint32_t palette[256];
	for (int x = 0; x < 256; ++x) {
		palette[x] = hsv_to_rgb(x,1.0,1.0);
	}

	while (!should_exit) {

		time += 1.0;

		int w = win_width;
		int h = win_height;

		spin_lock(&draw_lock);
		for (int x = 0; x < win_width; ++x) {
			for (int y = 0; y < win_height; ++y) {
				double value = sin(dist(x + time, y, 128.0, 128.0) / 8.0)
					+ sin(dist(x, y, 64.0, 64.0) / 8.0)
					+ sin(dist(x, y + time / 7, 192.0, 64) / 7.0)
					+ sin(dist(x, y, 192.0, 100.0) / 8.0);
				GFX(ctx, x + off_x, y + off_y) = palette[(int)((value + 4) * 32)];
			}
		}
		redraw_borders();
		flip(ctx);
		yutani_flip(yctx, wina);
		spin_unlock(&draw_lock);
		syscall_yield();
	}
}
예제 #19
0
static void
gtk_plot_surface_lighting (GdkColor *a, GdkColor *b, 
                           gdouble normal, gdouble ambient)
{
  gdouble red, green, blue;
  gdouble h, s, v;

  if(normal == 1.0){
   *b = *a;
   return;
  }

  normal = MIN(fabs(normal), 1.0);

  red = a->red;
  green = a->green;
  blue = a->blue;

  rgb_to_hsv(red, green, blue, &h, &s, &v);

  s *= normal;
  v *= normal;

  s += ambient;
  v += ambient;

  hsv_to_rgb(h, MIN(s, 1.0), MIN(v, 1.0), &red, &green, &blue);

  b->red = red;
  b->green = green;
  b->blue = blue;
}
static void set_report_color (struct chart *chart, int report)
{
    struct color color;

    hsv_to_rgb (6. / chart->num_reports * report, .7, .7, &color);
    cairo_set_source_rgb (chart->cr, color.red, color.green, color.blue);
}
예제 #21
0
	SmokeParticle::SmokeParticle(Effect* _effect, ParticleMover* _mover,
		const Vec3 _pos, const Vec3 _velocity, const color_t hue_adjust,
		const color_t saturation_adjust, const coord_t _sqrt_scale,
		const coord_t _max_size, const coord_t size_scalar,
		const alpha_t alpha_scale) :
		Particle(_effect, _mover, _pos, _velocity,
			size_scalar * (0.5f + randcoord()))
	{
		sqrt_scale = _sqrt_scale;
		max_size = _max_size;
		const color_t color_scale= square(randcolor(0.6));
		color_t hue, saturation, value;
		hue = randcolor(1.0);
		//  saturation = 1.0 - (color_scale + 0.15) / (0.15 + color_scale + square(randcolor(0.15)));
		saturation = color_scale;
		value = square(randcolor(0.15)) + color_scale + 0.15;
		//  color[0] = square(randcolor(0.15)) + color_scale + 0.15;
		//  color[1] = square(randcolor(0.15)) + color_scale + 0.15;
		//  color[2] = square(randcolor(0.15)) + color_scale + 0.15;
		hue += hue_adjust;
		if (hue > 1.0)
			hue -= 1.0;
		saturation = std::min(1.0f, saturation * saturation_adjust);
		hsv_to_rgb(hue, saturation, value, color[0], color[1], color[2]);
		alpha = std::min(1.0f, (0.05f + randcoord(0.1f)) * alpha_scale);
		flare_max = 1.0;
		flare_exp = 1.0;
		flare_frequency = 1.0;
		state = 0;
	}
예제 #22
0
	CandleParticle::CandleParticle(Effect* _effect, ParticleMover* _mover,
		const Vec3 _pos, const Vec3 _velocity, const color_t hue_adjust,
		const color_t saturation_adjust, const float _scale, const Uint16 _LOD) :
		Particle(_effect, _mover, _pos, _velocity)
	{
		LOD = _LOD;
		color_t hue, saturation, value;
		hue = 0.03 + randcolor(0.08);
		saturation = 0.78;
		value = 0.9;
		hue += hue_adjust;
		if (hue > 1.0)
			hue -= 1.0;
		saturation *= saturation_adjust;
		if (saturation > 1.0)
			saturation = 1.0;
		hsv_to_rgb(hue, saturation, value, color[0], color[1], color[2]);
		size = 6.0 * (2.0 + randcoord()) / (LOD + 2);
		alpha = 0.4 * 5 / size / (LOD + 2);
		if (alpha > 1.0)
			alpha = 1.0;
		size *= _scale;
		flare_max = 1.0;
		flare_exp = 0.0;
		flare_frequency = 2.0;
		state = ((rand() % 3) == 0);
	}
예제 #23
0
파일: image.c 프로젝트: renmengye/darknet
void exposure_image(image im, float sat)
{
    rgb_to_hsv(im);
    scale_image_channel(im, 2, sat);
    hsv_to_rgb(im);
    constrain_image(im);
}
예제 #24
0
void MixHueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
  float inputColor1[4];
  float inputColor2[4];
  float inputValue[4];

  this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
  this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
  this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);

  float value = inputValue[0];
  if (this->useValueAlphaMultiply()) {
    value *= inputColor2[3];
  }
  float valuem = 1.0f - value;

  float colH, colS, colV;
  rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
  if (colS != 0.0f) {
    float rH, rS, rV;
    float tmpr, tmpg, tmpb;
    rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
    hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb);
    output[0] = valuem * (inputColor1[0]) + value * tmpr;
    output[1] = valuem * (inputColor1[1]) + value * tmpg;
    output[2] = valuem * (inputColor1[2]) + value * tmpb;
  }
  else {
    copy_v3_v3(output, inputColor1);
  }
  output[3] = inputColor1[3];

  clampIfNeeded(output);
}
예제 #25
0
//void fcurve_rainbow (unsigned int cur, unsigned int tot, float *out)
void getcolor_fcurve_rainbow(int cur, int tot, float *out)
{
	float hue, val, sat, fac;
	int grouping;
	
	/* we try to divide the color into groupings of n colors,
	 * where n is:
	 *	3 - for 'odd' numbers of curves - there should be a majority of triplets of curves
	 *	4 - for 'even' numbers of curves - there should be a majority of quartets of curves
	 * so the base color is simply one of the three primary colors
	 */
	grouping = (4 - (tot % 2));
	hue = HSV_BANDWIDTH * (float)(cur % grouping);
	
	/* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be 
	 * 'darker' (i.e. smaller value), so that they don't look that similar to previous ones.
	 * However, only a range of 0.3 to 1.0 is really usable to avoid clashing
	 * with some other stuff 
	 */
	fac = ((float)cur / (float)tot) * 0.7f;
	
	/* the base color can get offset a bit so that the colors aren't so identical */
	hue += fac * HSV_BANDWIDTH; 
	if (hue > 1.0f) hue = fmod(hue, 1.0f);
	
	/* saturation adjustments for more visible range */
	if ((hue > 0.5f) && (hue < 0.8f)) sat = 0.5f;
	else sat = 0.6f;
	
	/* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */
	val = 1.0f;
	
	/* finally, conver this to RGB colors */
	hsv_to_rgb(hue, sat, val, out, out + 1, out + 2);
}
예제 #26
0
void MixValueOperation::executePixelSampled(float output[4],
                                            float x,
                                            float y,
                                            PixelSampler sampler)
{
  float inputColor1[4];
  float inputColor2[4];
  float inputValue[4];

  this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
  this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
  this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);

  float value = inputValue[0];
  if (this->useValueAlphaMultiply()) {
    value *= inputColor2[3];
  }
  float valuem = 1.0f - value;

  float rH, rS, rV;
  float colH, colS, colV;
  rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
  rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
  hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &output[0], &output[1], &output[2]);
  output[3] = inputColor1[3];

  clampIfNeeded(output);
}
예제 #27
0
파일: skimage.c 프로젝트: Scrik/sk1-wx
PyObject *
fill_hsv_xy(PyObject * self, PyObject * args)
{
    ImagingObject * image;
    int x, y, width, height;
    int xidx, yidx;
    double color[3];
    unsigned char *dest;

    if (!PyArg_ParseTuple(args, "Oii(ddd)", &image, &xidx, &yidx,
			  &color[0], &color[1], &color[2]))
	return NULL;

    if (xidx < 0 || xidx > 2 || yidx < 0 || yidx > 2 || xidx == yidx)
	return PyErr_Format(PyExc_ValueError,
			    "xidx and yidx must be different and in the range "
			    "[0..2] (x:%d, y:%d)",
			    xidx, yidx);

    width = image->image->xsize - 1;
    height = image->image->ysize - 1;
    for (y = 0; y <= height; y++)
    {
	dest = (unsigned char*)(image->image->image32[y]);
	for (x = 0; x <= width; x++, dest += 4)
	{
	    color[xidx] = (double)x / width;
	    color[yidx] = (double)(height - y) / height;
	    hsv_to_rgb(color[0], color[1], color[2], dest);
	}
    }

    Py_INCREF(Py_None);
    return Py_None;
}
예제 #28
0
	CloudParticle::CloudParticle(Effect* _effect, ParticleMover* _mover,
		const Vec3 _pos, const Vec3 _velocity, const color_t hue_adjust,
		const color_t saturation_adjust, const coord_t _min_height,
		const coord_t _max_height, const coord_t _size, const alpha_t _alpha) :
		Particle(_effect, _mover, _pos, _velocity)
	{
		color_t hue, saturation, value;
		hue = 0.67;
		saturation = 0.05;
		value = 1.0;
		hue += hue_adjust;
		if (hue > 1.0)
			hue -= 1.0;
		saturation *= saturation_adjust;
		if (saturation > 1.0)
			saturation = 1.0;
		hsv_to_rgb(hue, saturation, value, color[0], color[1], color[2]);
		size = _size;
		alpha = _alpha;
		flare_max = 2.0;
		flare_exp = 0.7;
		flare_frequency = 30.0;
		min_height = _min_height;
		max_height = _max_height;
		normal = Vec3(0.0, 1.0, 0.0);
	}
예제 #29
0
static void set_color_ring(void)
{
    int i;

    /*i = 0          ...        NCOLOR
     *  Blue -> Green -> Red -> White
     */
    for(i = 0; i < NCOLOR; i++)
    {
	rgb_t rgb;
	double h = 240 - 360 * sqrt((1.0/NCOLOR) * i);
	double s, v;

	if(h >= 0)
	    s = 0.9;
	else
	{
	    s = 0.9 + h / 120.0 * 0.9;
	    h = 0.0;
	}
/*	v = sqrt(i * (1.0/NCOLOR) * 0.6 + 0.4); */
	v = 1.0;
	hsv_to_rgb(h, s, v, &rgb);
	color_ring[i] = AllocRGBColor(disp, rgb.r, rgb.g, rgb.b);
    }
}
예제 #30
0
static void launch (int xlim, int ylim, int g)
{
	struct projectile *p = get_projectile ();
	int x, dx, xxx;
	double red, green, blue;
	if (! p) return;

	do {
		x = (myrand() % xlim);
		dx = 30000 - (myrand() % 60000);
		xxx = x + (dx * 200);
	} while (xxx <= 0 || xxx >= xlim);

	p->x = x;
	p->y = ylim;
	p->dx = dx;
	p->size = 20000;
	p->decay = 0;
	p->dy = (myrand() % 10000) - 20000;
	p->fuse = ((((myrand() % 500) + 100) * abs (p->dy / g)) / 1000);
	p->primary = true;

	hsv_to_rgb ((double)(myrand() % 360)/360.0, 1.0, 255.0,	&red, &green, &blue);
	//printf("New Projectile at (%d, %d), d(%d, %d), colour(%d,%d,%d)", x, ylim, dx, p->dy, (int)red, (int)green, (int)blue);
	p->colour = D3DCOLOR_XRGB((int)red,(int)green,(int)blue);
	return;
}