예제 #1
0
파일: cursor.cpp 프로젝트: bambams/ma5king
// creates a cursor shadow from a cursor bitmap
void MAS::Cursor::MakeShadow() {
   int x, y, i;

   Point pOffset(PADDING, PADDING);
   Point pOrigin(0,0);
   for (i=0; i<frameCount; i++) {
      Bitmap bmp;

      if (MAS::Settings::mouseShadow) {
         bmp.Create(Size(sprite[i]->w() + 2*PADDING, sprite[i]->h() + 2*PADDING), Bitmap::MEMORY);
      
         // create the alpha channel for the shadow by masking the cursor and bluring the results
         Bitmap alpha(bmp.size(), Bitmap::MEMORY);
         alpha.Clear(Color::transparent);
         sprite[i]->Blit(alpha, pOrigin, pOffset, sprite[i]->size());

         for (y=0; y<bmp.h(); y++) {
            for (x=0; x<bmp.w(); x++) {
               Point p(x,y);
               if (alpha.Getpixel(p) == Color::transparent)
                  alpha.Putpixel(p, Color::black);
               else
                  alpha.Putpixel(p, Color::white);
            }
         }

         Blur(alpha, PADDING);

         // write the alpha channel to the shadow bitmap
         for (y=0; y<bmp.h(); y++) {
            for (x=0; x<bmp.w(); x++) {
               Point p(x,y);
               bmp.Putpixel(p, Color(shadowColor.r(), shadowColor.g(), shadowColor.b(), alpha.Getpixel(p).r()));
            }
         }
      
         alpha.Destroy();
      }
      else {
         bmp.Create(1, 1);
         bmp.Putpixel(0, 0, Color::transparent);
      }

      Bitmap *result = new Bitmap(bmp.w(), bmp.h());
	  bmp.Blit(*result, 0, 0, 0, 0, bmp.w(), bmp.h());
      shadow.push_back(result);
   }
}
예제 #2
0
파일: skin.cpp 프로젝트: bambams/ma5king
////////////////////////////////////////////////////////////////////////////////
// Colors the skin bitmaps with the specified color and alpha intensity
//TODO: do this using turbofast A5 blending functions
void MAS::Skin::Colorize(const Color &col, int alpha) {
   Bitmap *bmp;
   int i, x, y;
   Color pink = Color::transparent;

   Reload();
   for (i=0; i<nBitmaps; i++) {
      bmp = bmpList[i];
      for (y=0; y<bmp->h(); y++) {
         for (x=0; x<bmp->w(); x++) {
            Color p = bmp->Getpixel(x, y);
            if (p == pink)
               continue;

            p.Colorize(col, alpha);
            bmp->Putpixel(x, y, p);
         }
      }
   }

   //if (box_back != -1) box_back = MASColorizePixel(box_back, col, alpha);
   c_back.Colorize(col, alpha);
   c_deselect.Colorize(col, alpha);
   c_disable.Colorize(col, alpha);
   c_face.Colorize(col, alpha);
   c_focus.Colorize(col, alpha);
   c_font.Colorize(col, alpha);
   c_select.Colorize(col, alpha);
   c_shad1.Colorize(col, alpha);
   c_shad2.Colorize(col, alpha);
   c_sunken.Colorize(col, alpha);
}
예제 #3
0
파일: skin.cpp 프로젝트: bambams/ma5king
////////////////////////////////////////////////////////////////////////////////
// Draws a default skin bitmap
void MAS::Skin::GenerateDefaultBitmap(int i) {
   Bitmap *bmp = bmpList[i];
   static int w[] =  { 64,64,18,26,72,18,18,11,15,15,15,15,36,64,18, 48,64,64,64,64,12,36,26,16,18,18,16,16,16,16,16,16,16,12, 2,18,64,88,88,30,30,30, 8, 8,12,30 };
   static int h[] =  { 64,64,72,52,72,80,88,88,56,56,56,56,96,64,24,112,64,64,64,64,36,12,52,64,64,64,64,64,64,64,64,48,64, 2,12,72,64,18,11, 8,30,36,72,72,17, 8 };
   static int tw[] = { 60,58,14,13,68,18,14,11,15,15,15,15,32,60,18, 16,60,60,60,60, 8,14,13,16,14,14,12,16,16,16,12,12,12, 8, 2,14,60,18,22,-1,-1,-1,-1,-1,-1,-1 };
   static int th[] = { 48,58,14,13,68,20,18,22,14,14,14,14, 8,60,12, 16,60,60,60,60,14, 8,13,16,12,12,12,16,16,16,12, 8,12, 2, 8,14,60,14,11,-1,-1,-1,-1,-1,-1,-1 };

   bmp->Create(w[i], h[i], MAS::Settings::useVideoMemory ? Bitmap::VIDEO : Bitmap::MEMORY);
   bmp->ThickX(tw[i]);
   bmp->ThickY(th[i]);
   bmp->Clear(c_face);

   switch (i) {
      case BOX:
         bmp->Rectangle(1, 4, 63, 63, c_shad1);
         bmp->Rectangle(0, 3, 62, 62, c_shad2);
         break;

      case BOX_SHADOW:
         bmp->Draw3DFrame(0, 0, 62, 62, c_face, c_shad1, c_shad2);
         bmp->Hline(1, 63, 63, Color::black);
         bmp->Vline(63, 1, 63, Color::black);
         break;

      case BUTTON:
         bmp->Draw3DFrame(0,  0, 17, 17, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 18, 17, 35, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 36, 17, 53, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 54, 17, 71, c_focus, c_shad1, c_shad2);
         break;

      case CHECKBOX:
         bmp->Draw3DFrame(0,  0, 12, 12,  c_sunken, c_shad2, c_shad1);
         bmp->Draw3DFrame(13,  0, 25, 12, c_sunken, c_shad2, c_shad1);
         bmp->DrawXMark(19, 6, 6, c_font);
         bmp->Draw3DFrame(0,  13, 12, 25, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(13, 13, 25, 25, c_select, c_shad2, c_shad1);
         bmp->DrawXMark(19, 19, 6, c_font);
         bmp->Draw3DFrame(0, 26, 12, 38,  c_face, c_shad2, c_shad1);
         bmp->Draw3DFrame(13, 26, 25, 38, c_face, c_shad2, c_shad1);
         bmp->DrawXMark(19, 32, 6, c_disable);
         bmp->Draw3DFrame(0, 39, 12, 51,  c_focus, c_shad2, c_shad1);
         bmp->Draw3DFrame(13,39, 25, 51,  c_focus, c_shad2, c_shad1);
         bmp->DrawXMark(19, 45, 6, c_font);
         break;

      case CLEAR_BACK:
         bmp->Clear(c_back);
         break;

      case COMBO_BUTTON:
         bmp->Clear(Color::transparent);
         bmp->DrawArrow(4,  9, c_font, 3);
         bmp->DrawArrow(4, 29, c_font, 3);
         bmp->DrawArrow(4, 49, c_disable, 3);
         bmp->DrawArrow(4, 69, c_font, 3);
         break;

      case HSLIDER_BACK:
         bmp->Draw3DFrame(0,  9, 17, 12, Color::transparent, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 31, 17, 34, Color::transparent, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 53, 17, 56, Color::transparent, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 75, 17, 78, Color::transparent, c_shad2, c_shad1);
         break;

      case HSLIDER_GRIP:
         bmp->Draw3DFrame(0,  0, 10, 21, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 22, 10, 43, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 44, 10, 65, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 66, 10, 87, c_focus, c_shad1, c_shad2);
         break;

      case ICONEXIT:
         bmp->Draw3DFrame(0,  0, 14, 13, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 14, 14, 27, c_face, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 28, 14, 41, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 42, 14, 55, c_face, c_shad1, c_shad2);
         bmp->DrawXMark(7,  7, 6, c_font);
         bmp->DrawXMark(7, 21, 6, c_font);
         bmp->DrawXMark(7, 35, 6, c_disable);
         bmp->DrawXMark(7, 49, 6, c_font);
         break;

      case ICONMAX:
         bmp->Draw3DFrame(0,  0, 14, 13, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 14, 14, 27, c_face, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 28, 14, 41, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 42, 14, 55, c_face, c_shad1, c_shad2);
         bmp->Rectangle(3,  3, 10, 10, c_font);
         bmp->Rectangle(3, 17, 10, 24, c_font);
         bmp->Rectangle(3, 31, 10, 38, c_disable);
         bmp->Rectangle(3, 45, 10, 52, c_font);
         bmp->Hline(3,  4, 10, c_font);
         bmp->Hline(3, 18, 10, c_font);
         bmp->Hline(3, 32, 10, c_disable);
         bmp->Hline(3, 46, 10, c_font);
         break;

      case ICONMIN:
         bmp->Draw3DFrame(0,  0, 14, 13, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 14, 14, 27, c_face, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 28, 14, 41, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 42, 14, 55, c_face, c_shad1, c_shad2);
         bmp->Rectangle(3,  9, 10, 10, c_font);
         bmp->Rectangle(3, 23, 10, 24, c_font);
         bmp->Rectangle(3, 37, 10, 38, c_disable);
         bmp->Rectangle(3, 51, 10, 52, c_font);
         break;

      case ICONRESTORE:
         bmp->Draw3DFrame(0,  0, 14, 13, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 14, 14, 27, c_face, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 28, 14, 41, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 42, 14, 55, c_face, c_shad1, c_shad2);
         bmp->Rectangle(3,  3, 10, 10, c_font);
         bmp->Rectangle(3, 17, 10, 24, c_font);
         bmp->Rectangle(3, 31, 10, 38, c_disable);
         bmp->Rectangle(3, 45, 10, 52, c_font);
         bmp->Hline(3,  4, 10, c_font);
         bmp->Hline(3, 18, 10, c_font);
         bmp->Hline(3, 32, 10, c_disable);
         bmp->Hline(3, 46, 10, c_font);
         break;

      case LIST:
         bmp->Rectfill(0,  0, 35, 11, c_sunken);
         bmp->Rectfill(0, 12, 35, 23, c_face);
         bmp->Rectfill(0, 24, 35, 35, c_sunken);
         bmp->Rectfill(0, 36, 35, 47, c_face);
         bmp->Rectfill(0, 48, 35, 59, c_select);
         bmp->Rectfill(0, 60, 35, 71, c_select);
         bmp->Rectfill(0, 72, 35, 83, c_face);
         bmp->Rectfill(0, 84, 35, 95, c_face);
         break;

      case MENU_BACK:
         bmp->Draw3DFrame(0, 0, 63, 63, c_face, c_shad1, c_shad2);
         break;

      case MENU_BUTTON:
         bmp->Clear(c_deselect);
         bmp->Rectfill(0, 12, 17, 23, c_select);
         break;

      case MENU_ITEM:
         bmp->Clear(c_face);

         bmp->Rectfill( 2, 2, 45, 13, c_face);

         bmp->Rectfill( 2, 18, 45, 29,   c_select);

         bmp->Hline( 4, 38, 43, c_shad2);
         bmp->Hline( 4, 39, 43, c_shad1);

         bmp->Rectfill( 2, 50, 45, 61, c_face);
         bmp->DrawArrow(40, 53, c_font, 1);

         bmp->Rectfill( 2, 66, 45, 77,   c_select);
         bmp->DrawArrow(40, 69, c_sunken, 1);

         bmp->Rectfill( 2, 82, 45, 93, c_face);
         bmp->DrawCheckMark(5, 85, c_font);

         bmp->Rectfill( 2, 98, 45, 109,   c_select);
         bmp->DrawCheckMark(5, 101, c_sunken);
         break;

      case PANEL_GROOVE:
         bmp->Rectangle(1, 1, 63, 63, c_shad2);
         bmp->Rectangle(0, 0, 62, 62, c_shad1);
         break;

      case PANEL_RAISED:
         bmp->Draw3DFrame(0, 0, 63, 63, c_face, c_shad1, c_shad2);
         break;

      case PANEL_RIDGE:
         bmp->Rectangle(1, 1, 63, 63, c_shad1);
         bmp->Rectangle(0, 0, 62, 62, c_shad2);
         break;

      case PANEL_SUNKEN:
         bmp->Draw3DFrame(0, 0, 63, 63, c_sunken, c_shad2, c_shad1);
         break;

      case PROGRESSH:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0, 0, 11, 17, c_face, c_shad2, c_shad1);
         bmp->Rectfill(2, 20, 10, 33, c_select);
         break;

      case PROGRESSV:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0, 0, 17, 11, c_face, c_shad2, c_shad1);
         bmp->Rectfill(20, 2, 34, 9, c_select);
         break;

      case RADIO:
         bmp->Draw3DCircle(6, 6, 6, c_sunken, c_shad2, c_shad1);
         bmp->Draw3DCircle(19, 6, 6, c_sunken, c_shad2, c_shad1);
         bmp->Circlefill(19, 6, 2, c_font);
         bmp->Draw3DCircle(6, 19, 6, c_select, c_shad2, c_shad1);
         bmp->Draw3DCircle(19, 19, 6, c_select, c_shad2, c_shad1);
         bmp->Circlefill(19, 19, 2, c_font);
         bmp->Draw3DCircle(6, 32, 6, c_face, c_shad2, c_shad1);
         bmp->Draw3DCircle(19, 32, 6, c_face, c_shad2, c_shad1);
         bmp->Circlefill(19, 32, 2, c_disable);
         bmp->Draw3DCircle(6, 45, 6, c_focus, c_shad2, c_shad1);
         bmp->Draw3DCircle(19, 45, 6, c_focus, c_shad2, c_shad1);
         bmp->Circlefill(19, 45, 2, c_font);
         break;

      case SCROLL_DOWN:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0, 0, 15, 15, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 16, 15, 31, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 32, 15, 47, c_face, c_shad2, c_shad2);
         bmp->Draw3DFrame(0, 48, 15, 63, c_focus, c_shad1, c_shad2);
         bmp->DrawArrow(4, 6, c_font, 3);
         bmp->DrawArrow(5, 23, c_font, 3);
         bmp->DrawArrow(4, 38, c_disable, 3);
         bmp->DrawArrow(4, 54, c_font, 3);
         break;

      case SCROLL_HBACK:
         break;

      case SCROLL_HGRIP:
         bmp->Draw3DFrame(0,   0, 17, 15, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 16, 17, 31,   c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 32, 17, 47,    c_face, c_shad2, c_shad2);
         bmp->Draw3DFrame(0, 48, 17, 63,   c_select, c_shad1, c_shad2);
         break;

      case SCROLL_HGRIPOVERLAY:
         bmp->Clear(Color::transparent);
         break;

      case SCROLL_LEFT:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0, 0, 15, 15, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 16, 15, 31, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 32, 15, 47, c_face, c_shad2, c_shad2);
         bmp->Draw3DFrame(0, 48, 15, 63, c_focus, c_shad1, c_shad2);
         bmp->DrawArrow(5, 4, c_font, 0);
         bmp->DrawArrow(6, 21, c_font, 0);
         bmp->DrawArrow(5, 36, c_disable, 0);
         bmp->DrawArrow(5, 52, c_font, 0);
         break;

      case SCROLL_RIGHT:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0, 0, 15, 15, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 16, 15, 31, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 32, 15, 47, c_face, c_shad2, c_shad2);
         bmp->Draw3DFrame(0, 48, 15, 63, c_focus, c_shad1, c_shad2);
         bmp->DrawArrow(6, 4, c_font, 1);
         bmp->DrawArrow(7, 21, c_font, 1);
         bmp->DrawArrow(6, 36, c_disable, 1);
         bmp->DrawArrow(6, 52, c_font, 1);
         break;

      case SCROLL_UP:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0, 0, 15, 15, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 16, 15, 31, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 32, 15, 47, c_face, c_shad2, c_shad2);
         bmp->Draw3DFrame(0, 48, 15, 63, c_focus, c_shad1, c_shad2);
         bmp->DrawArrow(4, 6, c_font, 2);
         bmp->DrawArrow(5, 23, c_font, 2);
         bmp->DrawArrow(4, 38, c_disable, 2);
         bmp->DrawArrow(4, 54, c_font, 2);
         break;

      case SCROLL_VBACK:
         break;

      case SCROLL_VGRIP:
         bmp->Draw3DFrame(0,   0, 15, 11, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(0, 12, 15, 23,   c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(0, 24, 15, 35,    c_face, c_shad2, c_shad2);
         bmp->Draw3DFrame(0, 36, 15, 47,   c_select, c_shad1, c_shad2);
         break;

      case SCROLL_VGRIPOVERLAY:
         bmp->Clear(Color::transparent);
         break;

      case SEPARATORH:
         bmp->Hline(0, 0, 11, c_shad2);
         bmp->Hline(0, 1, 11, c_shad1);
         break;

      case SEPARATORV:
         bmp->Vline(0, 0, 11, c_shad2);
         bmp->Vline(1, 0, 11, c_shad1);
         break;

      case TAB_BUTTON:
         bmp->Clear(Color::transparent);
         bmp->Draw3DFrame(0,  0, 17, 19, c_face, c_shad1, c_shad2);
         bmp->Hline(      1, 17, 16,     c_shad1);
         bmp->Putpixel(   0, 17,         Color::transparent);
         bmp->Putpixel(  17, 17,         Color::transparent);
         bmp->Draw3DFrame(0, 18, 17, 38, c_face, c_shad1, c_shad2);
         bmp->Putpixel(   0, 35,         Color::transparent);
         bmp->Putpixel(  17, 35,         Color::transparent);
         bmp->Draw3DFrame(0, 36, 17, 55, c_face, c_shad1, c_shad2);
         bmp->Hline(      1, 53, 16,     c_shad1);
         bmp->Putpixel(   0, 53,         Color::transparent);
         bmp->Putpixel(  17, 53,         Color::transparent);
         bmp->Draw3DFrame(0, 54, 17, 74, c_face, c_shad1, c_shad2);
         bmp->Hline(      1, 71, 16,     c_shad1);
         bmp->Putpixel(   0, 71,         Color::transparent);
         bmp->Putpixel(  17, 71,         Color::transparent);
         break;

      case TAB_WINDOW:
         bmp->Draw3DFrame(0, 0, 63, 63, c_face, c_shad1, c_shad2);
         break;

      case VSLIDER_BACK:
         bmp->Draw3DFrame( 9, 0, 12, 17, Color::transparent, c_shad2, c_shad1);
         bmp->Draw3DFrame(31, 0, 34, 17, Color::transparent, c_shad2, c_shad1);
         bmp->Draw3DFrame(53, 0, 56, 17, Color::transparent, c_shad2, c_shad1);
         bmp->Draw3DFrame(75, 0, 78, 17, Color::transparent, c_shad2, c_shad1);
         break;

      case VSLIDER_GRIP:
         bmp->Draw3DFrame( 0, 0, 21, 10, c_deselect, c_shad1, c_shad2);
         bmp->Draw3DFrame(22, 0, 43, 10, c_select, c_shad2, c_shad1);
         bmp->Draw3DFrame(44, 0, 65, 10, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(66, 0, 87, 10, c_focus, c_shad1, c_shad2);
         break;

      case WINBOTTOM:
         bmp->Draw3DFrame(-2, 0, 31, 7, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(-2, -2, 31, 3, c_face, c_shad1, c_shad2);
         break;

      case WINDOW:
         break;

      case WINGRIP:
         bmp->Rectfill( 0, 0, 29, 17, c_select);
         bmp->Rectfill( 0, 18, 29, 35, c_shad2);
         break;

      case WINLEFT:
         bmp->Draw3DFrame(0, 0, 7, 71, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(4, 0, 10, 71, c_face, c_shad1, c_shad2);
         break;

      case WINRIGHT:
         bmp->Draw3DFrame(0, 0, 7, 71, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(-2, 0, 3, 71, c_face, c_shad1, c_shad2);
         break;

      case WINTEXT:
         bmp->Clear(Color::transparent);
         break;

      case WINTOP:
         bmp->Draw3DFrame(-2, 0, 31, 7, c_face, c_shad1, c_shad2);
         bmp->Draw3DFrame(-2, 4, 31, 10, c_face, c_shad1, c_shad2);
         break;
   };
}