void GdImageRenderer::initColors(const WaveformColors& colors)
{
    border_color_     = createColor(colors.border_color);
    background_color_ = createColor(colors.background_color);
    waveform_color_   = createColor(colors.waveform_color);
    axis_label_color_ = createColor(colors.axis_label_color);
}
void happy(LedGroup* group) {
  byte r = Red(currentColor);
  byte g = Green(currentColor);
  byte b = Blue(currentColor);

  Color highColor1 = createColor(r/ 2,  g/2, b/2);
  Color highColor2 = createColor(250, 250, 250);

  for(int i=0;i<group->selectionLen; i++) {
  switch(group->pixelState[i]) {
    case 0:
      group->targetColors[i] = highColor1;
      group->pixelState[i]++;
      break;

    case 1:
      updateState(group, i, i);
      break;

    case 2:
      if(i == group->selectionLen - 1 && group->selectionLen < 10) {
        group->animatingPixel[group->selectionLen] = nextUnselected(group);
        group->pixelState[group->selectionLen] = 0;
        group->selectionLen++;
      }

      group->targetColors[i] = highColor2;
      group->pixelState[i]++;

      break;

    case 3:
      updateState(group, i, i);
      break;

    case 4:
      group->targetColors[i] = currentColor;
      group->pixelState[i]++;
      break;

    case 5:
      updateState(group, i, i);
      break;

    default:
      group->pixelState[i] = 0;
      group->animatingPixel[i] = nextUnselected(group);

      if(firstUnselected(group) >= group->length - 1) {
        group->animation = &flicker;
        group->selection = &flickerStrategy;
        group->counter = 0;
        group->waitFrames = 0;
      }
    }
  }
}
Beispiel #3
0
/*
 * function to set the current displayInfo's colors in the color palette
 *	and define the rcType (element type) being modified by any
 *	color palette selections
 */
void setCurrentDisplayColorsInColorPalette(
  int rcType,
  int index)	/* for types with color vectors, also specify element */
{
  Arg args[2];
  int i, n = 0;

/* create the color palette if it doesn't yet exist */
  if (colorMW == NULL) createColor();

  if (currentDisplayInfo == NULL)  {
  /* reset to default colormap */
    currentColormap = defaultColormap;
    for (i = 0; i < DL_MAX_COLORS; i++) {
      XtSetArg(args[0],XmNbackground,(Pixel)currentColormap[i]);
      XtSetValues(globalColorPalettePB[i],args,1);
    }
  } else {
    currentColormap = currentDisplayInfo->colormap;
    for (i = 0; i < MIN(currentDisplayInfo->dlColormapCounter,
		DL_MAX_COLORS); i++) {
       XtSetArg(args[0],XmNbackground,currentColormap[i]); n++;
       XtSetValues(globalColorPalettePB[i],args,1);
    }
  }

  elementTypeWhoseColorIsBeingEditted = rcType;
  elementTypeWhoseColorIsBeingEdittedIndex = index;
}
Beispiel #4
0
Game* createGame(char* title, int width, int height, float windowScale)
{
	printf("Allocating %fMB of memory...\n", (float)sizeof(Game)/1024/1024);
	Game* game = (Game*)calloc(1, sizeof(Game));
	printf("Success!\n");
	game->internalResolution = createPointi(width, height);
	game->windowScale = windowScale;
	
	State state;
	state.level = 1;
	state.stage = 1;
	state.lives = 5;
	state.score = 0;
	game->state = state;
	
	game->window = SDL_CreateWindow(
		title,
		SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED,
		(int)((float)width * windowScale), (int)((float)height * windowScale),
		SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN); 
		//SDL_WINDOW_FULLSCREEN_DESKTOP);
	
	game->renderer = 
		SDL_CreateRenderer(game->window, -1, 
			SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
	SDL_RenderSetLogicalSize(game->renderer, width, height);
		
	SDL_SetRenderDrawColor(game->renderer, 255, 255, 255, 255);
	
	game->clearColor = createColor(0, 0, 0, 255);
	game->drawAlpha = 1.0f;
		
	return game;
}
Beispiel #5
0
Entity* createEntity(Game* game, int type, Pointf position)
{
	for(int i = 0; i < MAX_ENTITIES_PER_GAME; ++i)
		if(!game->entities[i].alive)
		{
			Entity* entity = &game->entities[i];
			
			Entity blank = { 0 };
			*entity = blank;
			
			entity->alive = true;
			entity->type = type;
			entity->position = position;
			entity->size = createPointi(16, 16);
			entity->origin = createPointi(8, 8);
			entity->color = createColor(255, 255, 0, 255);
			entity->drawRectangle = true;
			entity->collidable = true;
			
			return entity;
		}
		
	printf("Error: Ran out of room for entities");
		
	return null;
}
Beispiel #6
0
JNIEXPORT void JNICALL Java_jp_dego_sample_ipcv_MainActivity_getHairArea(JNIEnv *env, jobject obj, jobject bmp,
        jint eyes_cp, jint eyes_w)
{
    AndroidBitmapInfo info;
    void* pixels;

    // Bitmapの情報を取得
    if (AndroidBitmap_getInfo(env, bmp, &info) < 0)
        return;
    // Bitmapのフォーマットをチェック
    if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888)
        return;
    // Bitmapをロック
    if (AndroidBitmap_lockPixels(env, bmp, &pixels) < 0)
        return;

    jint *p = pixels;
    int w = info.width;
    int h = info.height;

    // サンプルカラーの取得
    LAB *sc;
    sc = getSampleColor(p, w, h, (int)eyes_cp, (int)eyes_w);

    // 髪色強度マップの作成
    float *map;
    map = getHairIntensity(p, w, h, sc);

    int i, j;

    // Get Maximum and Minimum Value
    float max, min;
    max = *map;
    min = *map;
    for (i = 1; i < info.width * info.height; i++) {
        if (max < *(map + i))
            max = *(map + i);
        if (min > *(map + i))
            min = *(map + i);
    }
    // 256段階でグレースケール化
    unsigned char gray;
    int s;
    jint col;
    for (j = 0; j < info.height; j++) {
        for (i = 0; i < info.width; i++) {
            s = (int)((*(map + j * info.width + i) - (float)min) / ((float)max - min) * 255.0f);
            if (s > 255)
                gray = 255;
            else if (s < 1)
                gray = 0;
            else
                gray = (unsigned char)s;
            col = createColor(0xFF, gray, gray, gray);
            p[j * info.width + i] = col;
        }
    }

    free(map);
}
Beispiel #7
0
void MythUIHelper::SetPalette(QWidget *widget)
{
    QPalette pal = widget->palette();

    const QString names[] = { "Foreground", "Button", "Light", "Midlight",
                              "Dark", "Mid", "Text", "BrightText", "ButtonText",
                              "Base", "Background", "Shadow", "Highlight",
                              "HighlightedText"
                            };

    QString type = "Active";

    for (int i = 0; i < 13; i++)
    {
        QString color = d->m_qtThemeSettings->GetSetting(type + names[i]);

        if (!color.isEmpty())
            pal.setColor(QPalette::Active, (QPalette::ColorRole) i,
                         createColor(color));
    }

    type = "Disabled";

    for (int i = 0; i < 13; i++)
    {
        QString color = d->m_qtThemeSettings->GetSetting(type + names[i]);

        if (!color.isEmpty())
            pal.setColor(QPalette::Disabled, (QPalette::ColorRole) i,
                         createColor(color));
    }

    type = "Inactive";

    for (int i = 0; i < 13; i++)
    {
        QString color = d->m_qtThemeSettings->GetSetting(type + names[i]);

        if (!color.isEmpty())
            pal.setColor(QPalette::Inactive, (QPalette::ColorRole) i,
                         createColor(color));
    }

    widget->setPalette(pal);
}
void swapCurrentColor() {
  byte r = Red(currentColor);
  byte g = Green(currentColor);
  byte b = Blue(currentColor);
  
  currentColor = createColor(b, r,g);
  Serial.print("color:");
  Serial.println(currentColor);
}
void showLed(LedGroup* group, int i) {
  int index = random(1, 3);

  byte r = min(Red(currentColor) + index, Red(currentColor));
  byte g = min(Green(currentColor) + index, Green(currentColor));
  byte b = min(Blue(currentColor) + index, Blue(currentColor));

  group->waitFrames = 100;
  group->targetColors[i] = createColor(r,g,b);
}
void setProportionalTargetColor(LedGroup* group, int i, float colorIntensity) {
  float fr = Red(currentColor);
  float fg = Green(currentColor);
  float fb = Blue(currentColor);
  
  byte r = (fr / 100.) * colorIntensity;
  byte g = (fg / 100.) * colorIntensity;
  byte b = (fb / 100.) * colorIntensity;

  group->targetColors[i] = createColor(r, g, b);
}
void flickerSelectColor(LedGroup* group, int i, int min_, int max_) {
  float proportion = random(min_, max_);
  float fr = Red(currentColor);
  float fg = Green(currentColor);
  float fb = Blue(currentColor);

  byte r = fr / proportion;
  byte g = fg / proportion;
  byte b = fb / proportion;

  Color c = group->getColor(i);
  float cr = Red(c);
  float cg = Green(c);
  float cb = Blue(c);

  group->increment[i][0] = max(abs(cr - fr) / 10, 1);
  group->increment[i][1] = max(abs(cg - fg) / 10, 1);
  group->increment[i][2] = max(abs(cb - fb) / 10, 1);

  group->targetColors[i] = createColor(r,g,b);
}
Beispiel #12
0
void Menu::setHighLightColor(const int r, const int g, const int b)
{
    this->hlColor = createColor(r, g, b);
}
Beispiel #13
0
void Menu::setTextColor(const int r, const int g, const int b)
{
    this->fgColor = createColor(r, g, b);
}
Beispiel #14
0
Scene createScene(char* filename){
    Scene scene = {};
    scene.max_depth = 10;
    scene.num_samples = 100;

    scene.image = createImage(500, 500);

    Vector position = {278, 273, -800};
    Vector look_at = {278, 273, 0};
    Vector up = {0, 1, 0};
    scene.camera = createCamera(position, look_at, up, 39, (float)(scene.image.width/scene.image.height));

    scene.num_materials = 4;
    scene.materials = malloc(scene.num_materials * sizeof(Material));

    scene.materials[0] = createMaterial(createColor(.95, .25, .25), .6, .4, false);
    scene.materials[1] = createMaterial(createColor(.25, .95, .25), .6, .4, false);
    scene.materials[2] = createMaterial(createColor(.95, .95, .85), .6, .4, false);
    scene.materials[3] = createMaterial(createColor(.9, .9, .9), .6, .4, true);

    scene.num_triangles = 32;
    scene.triangles = malloc(scene.num_triangles * sizeof(Triangle));

    // Right Wall
    scene.triangles[0] = createTriangle(&scene.materials[1], createVector(0.0, 0.0, 559.2), createVector(0.0, 0.0, 0.0), createVector(0.0, 548.8, 0.0));
    scene.triangles[1] = createTriangle(&scene.materials[1], createVector(0.0, 0.0, 559.2), createVector(0.0, 548.8, 0.0), createVector(0.0, 548.8, 559.2));

    // Floor
    scene.triangles[2] = createTriangle(&scene.materials[2], createVector(556.0, 0.0, 0.0), createVector(0.0, 0.0, 0.0), createVector(0.0, 0.0, 559.2));
    scene.triangles[3] = createTriangle(&scene.materials[2], createVector(556.0, 0.0, 0.0), createVector(0.0, 0.0, 559.2), createVector(556.0, 0.0, 559.2));

    // Left Wall
    scene.triangles[4] = createTriangle(&scene.materials[0], createVector(556.0, 0.0, 0.0), createVector(556.0, 0.0, 559.2), createVector(556.0, 548.8, 559.2));
    scene.triangles[5] = createTriangle(&scene.materials[0], createVector(556.0, 0.0, 0.0), createVector(556.0, 548.8, 559.2), createVector(556.0, 548.8, 0.0));

    // Ceiling
    scene.triangles[6] = createTriangle(&scene.materials[2], createVector(556.0, 548.8, 0.0), createVector(0.0, 548.8, 559.2), createVector(0.0, 548.8, 0.0));
    scene.triangles[7] = createTriangle(&scene.materials[2], createVector(556.0, 548.8, 0.0), createVector(556.0, 548.8, 559.2), createVector(0.0, 548.8, 559.2));

    // Backwall
    scene.triangles[8] = createTriangle(&scene.materials[2], createVector(556.0, 0.0, 559.2), createVector(0.0, 0.0, 559.2), createVector(0.0, 548.8, 559.2));
    scene.triangles[9] = createTriangle(&scene.materials[2], createVector(556.0, 0.0, 559.2), createVector(0.0, 548.8, 559.2), createVector(556.0, 548.8, 559.2));

    // Short Block
    scene.triangles[10] = createTriangle(&scene.materials[2], createVector(130.0, 165.0, 65.0), createVector(82.0, 165.0, 225.0), createVector(240.0, 165.0, 272.0));
    scene.triangles[11] = createTriangle(&scene.materials[2], createVector(130.0, 165.0, 65.0), createVector(240.0, 165.0, 272.0), createVector(290.0, 165.0, 114.0));
    scene.triangles[12] = createTriangle(&scene.materials[2], createVector(290.0, 0.0, 114.0), createVector(290.0, 165.0, 114.0), createVector(240.0, 165.0, 272.0));
    scene.triangles[13] = createTriangle(&scene.materials[2], createVector(290.0, 0.0, 114.0), createVector(240.0, 165.0, 272.0), createVector(240.0, 0.0, 272.0));
    scene.triangles[14] = createTriangle(&scene.materials[2], createVector(130.0, 0.0, 65.0), createVector(130.0, 165.0, 65.0), createVector(290.0, 165.0, 114.0));
    scene.triangles[15] = createTriangle(&scene.materials[2], createVector(130.0, 0.0, 65.0), createVector(290.0, 165.0, 114.0), createVector(290.0, 0.0, 114.0));
    scene.triangles[16] = createTriangle(&scene.materials[2], createVector(82.0, 0.0, 225.0), createVector(82.0, 165.0, 225.0), createVector(130.0, 165.0, 65.0));
    scene.triangles[17] = createTriangle(&scene.materials[2], createVector(82.0, 0.0, 225.0), createVector(130.0, 165.0, 65.0), createVector(130.0, 0.0, 65.0));
    scene.triangles[18] = createTriangle(&scene.materials[2], createVector(240.0, 0.0, 272.0), createVector(240.0, 165.0, 272.0), createVector(82.0, 165.0, 225.0));
    scene.triangles[19] = createTriangle(&scene.materials[2], createVector(240.0, 0.0, 272.0), createVector(82.0, 165.0, 225.0), createVector(82.0, 0.0, 225.0));

    // Tall Block
    scene.triangles[20] = createTriangle(&scene.materials[2], createVector(423.0, 330.0, 247.0), createVector(265.0, 330.0, 296.0), createVector(314.0, 330.0, 456.0));
    scene.triangles[21] = createTriangle(&scene.materials[2], createVector(423.0, 330.0, 247.0), createVector(314.0, 330.0, 456.0), createVector(472.0, 330.0, 406.0));
    scene.triangles[22] = createTriangle(&scene.materials[2], createVector(423.0, 0.0, 247.0), createVector(423.0, 330.0, 247.0), createVector(472.0, 330.0, 406.0));
    scene.triangles[23] = createTriangle(&scene.materials[2], createVector(423.0, 0.0, 247.0), createVector(472.0, 330.0, 406.0), createVector(472.0, 0.0, 406.0));
    scene.triangles[24] = createTriangle(&scene.materials[2], createVector(472.0, 0.0, 406.0), createVector(472.0, 330.0, 406.0), createVector(314.0, 330.0, 456.0));
    scene.triangles[25] = createTriangle(&scene.materials[2], createVector(472.0, 0.0, 406.0), createVector(314.0, 330.0, 456.0), createVector(314.0, 0.0, 456.0));
    scene.triangles[26] = createTriangle(&scene.materials[2], createVector(314.0, 0.0, 456.0), createVector(314.0, 330.0, 456.0), createVector(265.0, 330.0, 296.0));
    scene.triangles[27] = createTriangle(&scene.materials[2], createVector(314.0, 0.0, 456.0), createVector(265.0, 330.0, 296.0), createVector(265.0, 0.0, 296.0));
    scene.triangles[28] = createTriangle(&scene.materials[2], createVector(265.0, 0.0, 296.0), createVector(265.0, 330.0, 296.0), createVector(423.0, 330.0, 247.0));
    scene.triangles[29] = createTriangle(&scene.materials[2], createVector(265.0, 0.0, 296.0), createVector(423.0, 330.0, 247.0), createVector(423.0, 0.0, 247.0));

    // Area Light
    scene.triangles[30] = createTriangle(&scene.materials[3], createVector(343.0, 548.7, 227.0), createVector(343.0, 548.7, 332.0), createVector(213.0, 548.7, 332.0));
    scene.triangles[31] = createTriangle(&scene.materials[3], createVector(343.0, 548.7, 227.0), createVector(213.0, 548.7, 332.0), createVector(213.0, 548.7, 227.0));

    scene.num_lights = 2;
    scene.lights = malloc(scene.num_lights * sizeof(Triangle));
    scene.lights[0] = createTriangle(&scene.materials[3], createVector(343.0, 548.7, 227.0), createVector(343.0, 548.7, 332.0), createVector(213.0, 548.7, 332.0));
    scene.lights[1] = createTriangle(&scene.materials[3], createVector(343.0, 548.7, 227.0), createVector(213.0, 548.7, 332.0), createVector(213.0, 548.7, 227.0));

    return scene;
}
void setDark(LedGroup* group, int i) {
  group->targetColors[i] = createColor(0, 0, 0);
}
#include "groupAnimation.h"

Color currentColor = createColor(100, 50, 50);
Color availableColors[7] = {856835, 857092, 660480, 398337, 985600, 656128, 657920};

void randomColor() {
  int index = random(0, 7);
  Serial.print("color:");
  Serial.println(availableColors[index]);
  currentColor = availableColors[index];
}

void swapCurrentColor() {
  byte r = Red(currentColor);
  byte g = Green(currentColor);
  byte b = Blue(currentColor);
  
  currentColor = createColor(b, r,g);
  Serial.print("color:");
  Serial.println(currentColor);
}

void setCurrentColor(Color color) {
  currentColor = color;
}

Color getCurrentColor() {
  return currentColor;
}

void updateState(LedGroup* group, int i, int state) {