Пример #1
0
void vgainit(void)
{
  video_mode=VIDEO_MODE_VGA_16;
  windowed_palette[0] = vga16_pal1_rgbq;
  windowed_palette[1] = vga16_pal1i_rgbq;
  windowed_palette[2] = vga16_pal2_rgbq;
  windowed_palette[3] = vga16_pal2i_rgbq;
  destroy_palettes();
  init_palettes();
}
Пример #2
0
int flam3_get_palette(int n, flam3_palette c, double hue_rotation) {
   int cmap_len = 256;
   int idx, i, j;

   if (NULL == the_palettes) {
   
      char *d = getenv("flam3_palettes");
      init_palettes(d ? d : (PACKAGE_DATA_DIR "/flam3-palettes.xml"));
   }
   
   if (flam3_palette_random == n)
      n = the_palettes[random()%npalettes].number;

   for (idx = 0; idx < npalettes; idx++) {
      
      if (n == the_palettes[idx].number) {
      	/* Loop over elements of cmap */
	      for (i = 0; i < cmap_len; i++) {
            int ii = (i * 256) / cmap_len;
            double rgb[3], hsv[3];
            
            /* Colors are in 0-1 space */
            for (j = 0; j < 3; j++)
               rgb[j] = the_palettes[idx].colors[ii][j] / 255.0;
	       
	         rgb2hsv(rgb, hsv);
	         hsv[0] += hue_rotation * 6.0;
	         hsv2rgb(hsv, rgb);
	         
	         c[i].index = i;
	       
	         for (j = 0; j < 3; j++)
		         c[i].color[j] = rgb[j];
		         
		      c[i].color[3] = 1.0;
         }
	   
	      return n;
      }
   }
   
   fprintf(stderr, "warning: palette number %d not found, using white.\n", n);

   for (i = 0; i < cmap_len; i++) {
   	c[i].index = i;
      for (j = 0; j < 4; j++)
         c[i].color[j] = 1.0;
   }

   return flam3_palette_random;
}