void ColorManager::load(ColorScheme *cs)
{
    wchar_t keyname[50];
    swprintf(keyname,50,L"scheme %d",cs->id);
    DWORD csLen=sizeof(ColorScheme);
    RegQueryValueEx(key,keyname,NULL,NULL,(LPBYTE)cs,&csLen);

	// find out how many entries are invalid and fix these by shifting up
	int woolLoc = BLOCK_BLACK_WOOL;
	// Find black wool entry (for backwards compatibility)
	unsigned int color=blockColor(BLOCK_BLACK_WOOL);

	// go back through list until wool is found. Don't go back past say snow
	while ( woolLoc > 78 && cs->colors[woolLoc] != color )
	{
		woolLoc--;
	}

	// woolLoc is the location of black wool in the saved color scheme
	if ( woolLoc < BLOCK_BLACK_WOOL && woolLoc > 78 )
	{
		// Mind the gap! Move the 16 wools up some slots, fill in these slots
		// with missing entries
		int gap = BLOCK_BLACK_WOOL - woolLoc;
		int i;
		// set unknown block attribute, one past wool
		cs->colors[NUM_BLOCKS-1] = blockColor(NUM_BLOCKS-1);
		for ( i = 0; i > -16; i-- )
		{
			// correct black wool set to where black wool is currently, on back down
			cs->colors[woolLoc+gap+i] = cs->colors[woolLoc+i];
		}
		for ( i = 0; i <= BLOCK_BLACK_WOOL; i++ )
		{
			// set where white wool was, on up, to missing color
			cs->colors[woolLoc-15+i] = blockColor(woolLoc-15+i);
		}
		save(cs);
	}
}
Beispiel #2
0
void ColorManager::load(ColorScheme *cs)
{
    wchar_t keyname[50];
    swprintf(keyname,50,L"scheme %d",cs->id);
    DWORD csLen=sizeof(ColorScheme);
    RegQueryValueEx(key,keyname,NULL,NULL,(LPBYTE)cs,&csLen);

    // find out how many entries are invalid and fix these by shifting up
    int endLoc = BLOCK_UNKNOWN;
    // Find unknown block entry (for backwards compatibility)
    unsigned int color=blockColor(BLOCK_UNKNOWN);

    // go back through list until unknown block is found. Don't go back past say snow.
    // ignore alpha, because that could get zero'ed.
    while ( endLoc > BLOCK_SNOW && (cs->colors[endLoc] & 0xffffff00) != (color & 0xffffff00) )
    {
        endLoc--;
    }

    // endLoc is the location of the unknown block in the saved color scheme.
    // Check if a correction is needed, i.e. new blocks have been added.
    if ( endLoc < BLOCK_UNKNOWN && endLoc > BLOCK_SNOW )
    {
        // Mind the gap! Move the unknown block up some slots, fill in these slots
        // with missing entries
        int gap = BLOCK_UNKNOWN - endLoc;
        int i;
        // set unknown block attribute to whatever it was before
        cs->colors[endLoc+gap] = cs->colors[endLoc];

        // set "empty" blocks with new default data
        for ( i = 0; i < gap; i++ )
        {
            // set where unknown block was, on up to end
            cs->colors[endLoc+i] = blockColor(endLoc+i);
        }
        save(cs);
    }
}
Beispiel #3
0
void ColorManager::Init(ColorScheme *cs)
{
    int i;
    for (i=0;i<NUM_BLOCKS;i++)
    {
        cs->colors[i]=blockColor(i);
    }
    for (int i=NUM_BLOCKS; i < 256; i++)
    {
        // fill the rest with almost-black; if we detect this color on loading
        // a color scheme in a place that should have been a normal color, then
        // we know the old color scheme is out of date and should be fixed on load.
        cs->colors[i]=NO_COLOR_ENTRY;
    }
}
void FlappyCatColorScheme::generateDayScheme() {

  std::uniform_real_distribution<HslColor::value_type> distribution(0.0, 360.0);
  HslColor::value_type hue = distribution(mGenerator);

  HslColor heroColor(hue, 100.0, 50.0);


  HslColor blockColor(heroColor);
  blockColor.rotateHue(150.0);
  blockColor.setSaturation(70.0);
  blockColor.setLuminance(40.0);

  HslColor dirtColor(blockColor);
  dirtColor.setLuminance(20.0);


  HslColor backgroundColor(heroColor);
  backgroundColor.rotateHue(210.0);
  backgroundColor.setSaturation(100.0);
  backgroundColor.setLuminance(85.0);

  HslColor cloudColor(heroColor);
  cloudColor.setLuminance(100.0);

  HslColor houseColor(heroColor);
  houseColor.rotateHue(210.0);
  houseColor.setSaturation(50.0);
  houseColor.setLuminance(55.0);


  mScheme[BackgroundColor] = backgroundColor.toRgb();
  mScheme[BlockColor]      = blockColor.toRgb();
  mScheme[HeroColor]       = heroColor.toRgb(128);
  mScheme[HouseColor]      = houseColor.toRgb();
  mScheme[CloudColor]      = cloudColor.toRgb();
  mScheme[DirtColor]       = dirtColor.toRgb();
  mScheme[MascotBodyColor] = Color(0, 0, 0);
  mScheme[MascotScarfColor] = Color(255, 255, 255);
  mScheme[MascotMouthColor] = Color(255, 128, 0);
}
Beispiel #5
0
	//! Return the current color of a block of a given type
	QColor Style::blockCurrentColor(const QString& type)
	{
		return blockColor(type, privateStyle.currentColor);
	}
void AnnotateCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
   wxPaintDC dc(this);
   PrepareDC(dc);

   if (!myAnnotations || !myNumLinesTotal)
      return;

   int width;
   int height;
   GetClientSize(&width, &height);

   float lineHeight = float(height) / float(myNumLinesTotal);

   unsigned int startLine = 0;
   unsigned int endLine = 0;
   wxColour blockColor(*((wxColour*)(*myAnnotations)[startLine]->Data()));
   for (unsigned int i = 1; i < myAnnotations->AnnotationCount(); ++i)
   {
      bool lastLine = (i == (myNumLinesTotal - 1));

      // We are currently in a run of lines, and this line also matches the block color
      // Adjust the ending line of the block and continue processing lines.
      if (blockColor == *((wxColour*)(*myAnnotations)[i]->Data()) && !lastLine)
         endLine = i;

      // We had a run of lines that has now ended, we need to draw the colored rect
      // for this block, and then continue processing lines.
      else if (blockColor != *((wxColour*)(*myAnnotations)[i]->Data()) || lastLine) 
      {
         if (lastLine)
            endLine = i;

         wxCoord yCoord = (wxCoord) (startLine * lineHeight);
         wxCoord height = (wxCoord) ((endLine + 1 - startLine) * lineHeight);

         bool isDefault = (blockColor == wxNullColour);

         wxBrush brush;
         wxPen pen;

         // Set the brush
         if (isDefault)
             brush = *wxTRANSPARENT_BRUSH;
         else
             brush = wxBrush(blockColor, wxSOLID);
         dc.SetBrush(brush);
         // Set the pen
         if (isDefault)
            pen = *wxTRANSPARENT_PEN;
         else if (myHighlightType == HIGHLIGHT_BY_AGE_FIXED || myHighlightType == HIGHLIGHT_BY_AGE_SCALED)
            pen = wxPen(blockColor, 1, wxSOLID);
         else
            pen = wxPen(wxColour(0x00, 0x00, 0x00), 1, wxSOLID);
         dc.SetPen(pen);

         dc.DrawRectangle(0, yCoord, 10, height);

         // Set up the next block
         blockColor = *((wxColour*)(*myAnnotations)[i]->Data());
         startLine = endLine = i;
      }
   }

   // Draw a border rect for the age types
   if (myHighlightType == HIGHLIGHT_BY_AGE_FIXED || myHighlightType == HIGHLIGHT_BY_AGE_SCALED)
   {
      dc.SetBrush(*wxTRANSPARENT_BRUSH);
      dc.SetPen(wxPen(wxColour(0x00,0x00,0x00), 1, wxSOLID));
      dc.DrawRectangle(0, 0, width, height);
   }
}