void RenderingManager::Initialize(bool installMode) { useAlphaLanes = true; // set up double buffering m_backbuf1 = create_system_bitmap(640, 480); m_backbuf2 = create_system_bitmap(640, 480); m_temp64 = create_bitmap(64, 64); currentPage = 1; m_backbuf = rm.m_backbuf1; // load other stuff - these can be NULL during the install process! if ( !installMode ) { m_whiteFont = loadImage("DATA/etc/white_font.bmp"); m_textFont = loadImage("DATA/etc/text_font.bmp"); m_boldFont[0] = loadImage("DATA/etc/bold_font.bmp"); m_boldFont[1] = loadImage("DATA/etc/bold_font.bmp"); m_boldFont[2] = loadImage("DATA/etc/bold_font.bmp"); m_boldFont[3] = loadImage("DATA/etc/bold_font.bmp"); replaceColor(m_boldFont[1], makecol(248,248,248), makecol(170,255,170)); replaceColor(m_boldFont[2], makecol(248,248,248), makecol(255,170,170)); replaceColor(m_boldFont[3], makecol(248,248,248), makecol(170,170,255)); m_artistFont = loadImage("DATA/etc/artist_font.bmp"); m_scoreFont = loadImage("DATA/etc/score_font.bmp"); m_nameFont[0] = loadImage("DATA/etc/name_font_white.bmp"); m_nameFont[1] = loadImage("DATA/etc/name_font_green.bmp"); m_nameFont[2] = loadImage("DATA/etc/name_font_red.bmp"); } }
QIcon appIcon(AppIconType iconType) { const bool running = iconType == AppIconRunning; const QString suffix = running ? "-busy" : "-normal"; const QString sessionName = qApp->property("CopyQ_session_name").toString(); QIcon icon; if (sessionName.isEmpty()) icon = QIcon::fromTheme("copyq" + suffix); else icon = QIcon::fromTheme("copyq-" + sessionName + "-" + suffix); if (icon.isNull()) { const QString resourceSuffix = running ? "-running" : ""; QPixmap pix = imageFromPrefix(suffix + ".svg", "icon" + resourceSuffix); if (!sessionName.isEmpty()) { const QColor color1(0x7f, 0xca, 0x9b); const QColor color2 = sessionNameToColor(sessionName); replaceColor(&pix, color1, color2); } icon.addPixmap(pix); // This makes the icon smoother on some systems. updateIcon(&icon, pix, 48); updateIcon(&icon, pix, 32); updateIcon(&icon, pix, 24); updateIcon(&icon, pix, 16); } return icon; }
QIcon IconFactory::appIcon(AppIconFlags flags) { const bool running = flags.testFlag(AppIconRunning); const QString suffix = running ? "-busy" : "-normal"; const QString sessionName = qApp->property("CopyQ_session_name").toString(); QIcon icon; if (sessionName.isEmpty()) icon = QIcon::fromTheme("copyq" + suffix); if (icon.isNull()) { const QString resourceSuffix = running ? "-running" : ""; QPixmap pix = imageFromPrefix(suffix + ".svg", "icon" + resourceSuffix); if (!sessionName.isEmpty()) { const QColor color1(0x7f, 0xca, 0x9b); const QColor color2 = sessionNameToColor(sessionName); replaceColor(&pix, color1, color2); } icon.addPixmap(pix); } if (flags.testFlag(AppIconDisabled)) { QIcon disabledIcon; foreach (const QSize &size, icon.availableSizes()) disabledIcon.addPixmap(icon.pixmap(size, QIcon::Disabled)); return disabledIcon; }
void MapConstructor::findGate(int const i, int const j, int const value) { int random; int max; if (countValues(_map[std::make_pair(i, j)]) < value) { random = rand() % 4; for (max = 0; max < 4; ++max) { if (isValid(i, j, random, value)) { _map[std::make_pair(i + _dir[random].first / 2, j + _dir[random].second / 2)] = _map[std::make_pair(i, j)]; replaceColor(_map[std::make_pair(i + _dir[random].first, j + _dir[random].second)], _map[std::make_pair(i, j)]); break; } random = (random + 1) % 4; } } }
QIcon IconFactory::appIcon(AppIconFlags flags) { QPixmap pix = flags.testFlag(AppIconRunning) ? imageFromPrefix("-busy.svg", "icon-running") : imageFromPrefix("-normal.svg", "icon"); const QString sessionName = qApp->property("CopyQ_session_name").toString(); if (!sessionName.isEmpty()) { const QColor color1 = QColor(0x7f, 0xca, 0x9b); const QColor color2 = sessionNameToColor(sessionName); replaceColor(&pix, color1, color2); } if (flags.testFlag(AppIconDisabled)) { QPainter p(&pix); p.setCompositionMode(QPainter::CompositionMode_DestinationOut); p.fillRect(pix.rect(), QColor(100, 100, 100, 100)); } return QIcon(pix); }
static void processFillCanvasMouse(Sprite* sprite, s32 x, s32 y, s32 l, s32 t) { tic_mem* tic = sprite->tic; tic_rect rect = {x, y, CANVAS_SIZE, CANVAS_SIZE}; const s32 Size = CANVAS_SIZE / sprite->size; if(checkMousePos(&rect)) { setCursor(tic_cursor_hand); s32 mx = getMouseX() - x; s32 my = getMouseY() - y; mx -= mx % Size; my -= my % Size; drawCursorBorder(sprite, x + mx, y + my, Size, Size); bool left = checkMouseClick(&rect, tic_mouse_left); bool right = checkMouseClick(&rect, tic_mouse_right); if(left || right) { s32 sx = l + mx / Size; s32 sy = t + my / Size; u8 color = getSheetPixel(sprite, sx, sy); u8 fill = left ? sprite->color : sprite->color2; if(color != fill) { tic->api.key(tic, tic_key_ctrl) ? replaceColor(sprite, l, t, l + sprite->size-1, t + sprite->size-1, sx, sy, color, fill) : floodFill(sprite, l, t, l + sprite->size-1, t + sprite->size-1, sx, sy, color, fill); } history_add(sprite->history); } } }
static LVRefVec<LVImageSource> getBatteryIcons(lUInt32 color) { CRLog::debug("Making list of Battery icon bitmats"); // #include "battery_icons.h" lUInt32 cl1 = 0x00000000 | (color & 0xFFFFFF); lUInt32 cl2 = 0x40000000 | (color & 0xFFFFFF); lUInt32 cl3 = 0x80000000 | (color & 0xFFFFFF); lUInt32 cl4 = 0xFF000000 | (color & 0xFFFFFF); static char color1[] = "0 c #80000000"; static char color2[] = "X c #80000000"; static char color3[] = "o c #80AAAAAA"; static char color4[] = ". c #80FFFFFF"; #define BATTERY_HEADER \ "28 15 5 1", \ color1, \ color2, \ color3, \ color4, \ " c None", static const char * battery8[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0.XXXX.XXXX.XXXX.XXXX.0.", ".0000.XXXX.XXXX.XXXX.XXXX.0.", ".0..0.XXXX.XXXX.XXXX.XXXX.0.", ".0..0.XXXX.XXXX.XXXX.XXXX.0.", ".0..0.XXXX.XXXX.XXXX.XXXX.0.", ".0..0.XXXX.XXXX.XXXX.XXXX.0.", ".0..0.XXXX.XXXX.XXXX.XXXX.0.", ".0000.XXXX.XXXX.XXXX.XXXX.0.", "....0.XXXX.XXXX.XXXX.XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery7[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0.oooo.XXXX.XXXX.XXXX.0.", ".0000.oooo.XXXX.XXXX.XXXX.0.", ".0..0.oooo.XXXX.XXXX.XXXX.0.", ".0..0.oooo.XXXX.XXXX.XXXX.0.", ".0..0.oooo.XXXX.XXXX.XXXX.0.", ".0..0.oooo.XXXX.XXXX.XXXX.0.", ".0..0.oooo.XXXX.XXXX.XXXX.0.", ".0000.oooo.XXXX.XXXX.XXXX.0.", "....0.oooo.XXXX.XXXX.XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery6[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0......XXXX.XXXX.XXXX.0.", ".0000......XXXX.XXXX.XXXX.0.", ".0..0......XXXX.XXXX.XXXX.0.", ".0..0......XXXX.XXXX.XXXX.0.", ".0..0......XXXX.XXXX.XXXX.0.", ".0..0......XXXX.XXXX.XXXX.0.", ".0..0......XXXX.XXXX.XXXX.0.", ".0000......XXXX.XXXX.XXXX.0.", "....0......XXXX.XXXX.XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery5[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0......oooo.XXXX.XXXX.0.", ".0000......oooo.XXXX.XXXX.0.", ".0..0......oooo.XXXX.XXXX.0.", ".0..0......oooo.XXXX.XXXX.0.", ".0..0......oooo.XXXX.XXXX.0.", ".0..0......oooo.XXXX.XXXX.0.", ".0..0......oooo.XXXX.XXXX.0.", ".0000......oooo.XXXX.XXXX.0.", "....0......oooo.XXXX.XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery4[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0...........XXXX.XXXX.0.", ".0000...........XXXX.XXXX.0.", ".0..0...........XXXX.XXXX.0.", ".0..0...........XXXX.XXXX.0.", ".0..0...........XXXX.XXXX.0.", ".0..0...........XXXX.XXXX.0.", ".0..0...........XXXX.XXXX.0.", ".0000...........XXXX.XXXX.0.", "....0...........XXXX.XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery3[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0...........oooo.XXXX.0.", ".0000...........oooo.XXXX.0.", ".0..0...........oooo.XXXX.0.", ".0..0...........oooo.XXXX.0.", ".0..0...........oooo.XXXX.0.", ".0..0...........oooo.XXXX.0.", ".0..0...........oooo.XXXX.0.", ".0000...........oooo.XXXX.0.", "....0...........oooo.XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery2[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0................XXXX.0.", ".0000................XXXX.0.", ".0..0................XXXX.0.", ".0..0................XXXX.0.", ".0..0................XXXX.0.", ".0..0................XXXX.0.", ".0..0................XXXX.0.", ".0000................XXXX.0.", "....0................XXXX.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery1[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", " .0................oooo.0.", ".0000................oooo.0.", ".0..0................oooo.0.", ".0..0................oooo.0.", ".0..0................oooo.0.", ".0..0................oooo.0.", ".0..0................oooo.0.", ".0000................oooo.0.", " .0................oooo.0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery0[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", " .0.....................0.", ".0000.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0000.....................0.", "....0.....................0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; //#endif static const char * battery_charge[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0.....................0.", ".0000............XX.......0.", ".0..0...........XXXX......0.", ".0..0..XX......XXXXXX.....0.", ".0..0...XXX...XXXX..XX....0.", ".0..0....XXX..XXXX...XX...0.", ".0..0.....XXXXXXX.....XX..0.", ".0000.......XXXX..........0.", "....0........XX...........0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; static const char * battery_frame[] = { BATTERY_HEADER " .........................", " .00000000000000000000000.", " .0.....................0.", "....0.....................0.", ".0000.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0..0.....................0.", ".0000.....................0.", "....0.....................0.", " .0.....................0.", " .00000000000000000000000.", " .........................", }; const char * * icon_bpm[] = { battery_charge, battery0, battery1, battery2, battery3, battery4, battery5, battery6, battery7, battery8, battery_frame, NULL }; replaceColor(color1, cl1); replaceColor(color2, cl2); replaceColor(color3, cl3); replaceColor(color4, cl4); LVRefVec<LVImageSource> icons; for (int i = 0; icon_bpm[i]; i++) icons.add(LVCreateXPMImageSource(icon_bpm[i])); return icons; }
void Font::setColor(uint16 color) { if (_data && _color != color) { replaceColor(_color, color); _color = color; } }
int main(int argc, char* argv[]) { GPU_Target* screen; printRenderers(); screen = GPU_Init(800, 600, GPU_DEFAULT_INIT_FLAGS); if(screen == NULL) return -1; printCurrentRenderer(); { Uint32 startTime; long frameCount; Uint8 done; SDL_Event event; GPU_Image* image; GPU_Image* image1; GPU_Image* image1a; SDL_Color yellow = {246, 255, 0}; SDL_Color red = {200, 0, 0}; GPU_Image* image2; GPU_Image* image3; GPU_Image* image4; image = GPU_LoadImage("data/test3.png"); if(image == NULL) return -1; image1 = GPU_CopyImage(image); makeColorTransparent(image1, yellow); image1a = GPU_CopyImage(image); replaceColor(image1a, yellow, red); image2 = GPU_CopyImage(image); shiftHSV(image2, 100, 0, 0); image3 = GPU_CopyImage(image); shiftHSV(image3, 0, -100, 0); image4 = GPU_CopyImage(image); shiftHSV(image4, 0, 0, 100); startTime = SDL_GetTicks(); frameCount = 0; done = 0; while(!done) { while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) done = 1; else if(event.type == SDL_KEYDOWN) { if(event.key.keysym.sym == SDLK_ESCAPE) done = 1; } } GPU_Clear(screen); GPU_Blit(image, NULL, screen, 150, 150); GPU_Blit(image1, NULL, screen, 300, 150); GPU_Blit(image1a, NULL, screen, 450, 150); GPU_Blit(image2, NULL, screen, 150, 300); GPU_Blit(image3, NULL, screen, 300, 300); GPU_Blit(image4, NULL, screen, 450, 300); GPU_Flip(screen); frameCount++; if(frameCount%500 == 0) printf("Average FPS: %.2f\n", 1000.0f*frameCount/(SDL_GetTicks() - startTime)); } printf("Average FPS: %.2f\n", 1000.0f*frameCount/(SDL_GetTicks() - startTime)); GPU_FreeImage(image); GPU_FreeImage(image1); GPU_FreeImage(image1a); GPU_FreeImage(image2); GPU_FreeImage(image3); GPU_FreeImage(image4); } GPU_Quit(); return 0; }