void RootWindow::DrawPict(HDC hdc) { RECT clientRc; long picDx, picDy; int winDx, winDy; HDC dcTmp = NULL; HBITMAP bmpTmp = NULL; HBITMAP bmpOld = NULL; if (NULL == g_pic) return; GetClientRect(m_hwnd, &clientRc); winDx = RectDx(&clientRc); winDy = RectDy(&clientRc); g_pic->get_Width(&picDx); g_pic->get_Height(&picDy); dcTmp = CreateCompatibleDC(hdc); if (NULL == dcTmp) return; bmpTmp = CreateCompatibleBitmap(hdc, winDx, winDy); if (NULL == bmpTmp) goto Exit; bmpOld = (HBITMAP)SelectObject(dcTmp, bmpTmp); HDC dcToDraw = dcTmp; FillRectangle(dcToDraw, 0, 0, RectDx(&clientRc), RectDy(&clientRc), COL_WHITE); if (m_fPictHasBorder) { RECT tmpRc = { 0 }; tmpRc.left = m_pictPosX - BORDER_PIXEL_SIZE; tmpRc.top = m_pictPosY - BORDER_PIXEL_SIZE; tmpRc.right = tmpRc.left + m_pictPixelDx + 2*BORDER_PIXEL_SIZE; tmpRc.bottom = tmpRc.top + m_pictPixelDy + 2*BORDER_PIXEL_SIZE; FillRectangle(dcToDraw, &tmpRc, COL_RED); } g_pic->Render(dcToDraw, m_pictPosX, m_pictPosY, m_pictPixelDx, m_pictPixelDy, 0, picDy, picDx, -picDy, NULL); BitBlt(hdc, 0, 0, winDx, winDy, dcToDraw, 0, 0, SRCCOPY); SelectObject(dcTmp, bmpOld); Exit: if (NULL != bmpTmp) DeleteObject(bmpTmp); if (NULL != dcTmp) DeleteDC(dcTmp); }
void DrawRectangle(int nFrameLineWidth, int nX, int nY, int nW, int nH) { if(nFrameLineWidth > 0){ if(nFrameLineWidth == 1){ DrawRectangle(nX, nY, nW, nH); }else{ FillRectangle(nX, nY, nW, nFrameLineWidth); FillRectangle(nX, nY + nW - 2 * nFrameLineWidth, nW, nFrameLineWidth); FillRectangle(nX, nY + nFrameLineWidth, nFrameLineWidth, nH - 2 * nFrameLineWidth); FillRectangle(nX + nW - 2 * nFrameLineWidth, nY + nFrameLineWidth, nFrameLineWidth, nH - 2 * nFrameLineWidth); } } }
void DrawWindow(struct Context *context) { struct Button *but; int r; XSync(display,1); /*DrawPlate(0,0,WINDOW_W-1,WINDOW_H-1,WHITE,PLATE_UP); DrawPlate(0,0,WINDOW_W-1,WINDOW_H-1,BLACK,PLATE_UP);*/ Color(BLACK); FillRectangle(WINDOW_H,WINDOW_H-120,WINDOW_W-1,WINDOW_H-1); NetDisplay(); //NR: Number of robots, r: robot number (do it NR times) for (r=0;r<NR;r++) { RobotDisplay(r,robots[r]); } but = context->Buttons;; while (but) { DrawButton(but); but = but->Next; } XSync(display,0); }
void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) { Q_ASSERT(painter); FillRectangle(rc, back); drawText(rc, font_, ybase, s, len, fore); }
/** ** Draw completed bar into top-panel. ** ** @param full the 100% value ** @param ready how much till now completed */ local void DrawCompleted(int full,int ready) { int f; f=(100*ready)/full; f=(f*152)/100; FillRectangle(ColorDarkGreen,12,168+145,f,14); DrawText(50,168+145,SMALL_FONT,"% Complete"); }
void XxWindow::SetBackground (XxColor Color) { DrawGC.SetForeground (Color); FillRectangle (DrawGC, 0, 0, GetWidth (), GetHeight ()); XxAttrs.background_pixel = Color.GetPixel (); XxAttrMask |= CWBackPixel; IntUpdateAttrs (); };
void MyWindow::OnPaint() { glColor3f(color.R / 255.0, color.G / 255.0, color.B / 255.0); FillRectangle(X + relativePos.X, Y + relativePos.Y, Width, Height); FillRectangle(X + relativePos.X + 1, Y + relativePos.Y + 1, Width - 2, Height - 2); for (int i = 0; i < controls.size(); i++) //Call OnPaint() for each control in the window { controls.at(i)->SetRelativePos(Point(this->X + relativePos.X, this->Y + relativePos.Y + 20)); controls.at(i)->OnPaint(); } glColor3f(0 / 255.0, 0 / 255.0, 0 / 255.0); FillRectangle(X + relativePos.X, Y + relativePos.Y, Width, 20); glColor3f(borderColor.R / 255.0, borderColor.G / 255.0, borderColor.B / 255.0); DrawRectangle(X + relativePos.X, Y + relativePos.Y, Width, 20); DrawString(titel, X + relativePos.X + 5, Y + relativePos.Y + 14); }
void MDrawContextR2::FillRectangleW(int x, int y, int cx, int cy) { if( RGetIsWidthScreen() ) { x = ( 800*x+80*RGetScreenWidth() )/960.f;//( x/float(RGetScreenWidth()) *800 + 80 )/960 * RGetScreenWidth(); cx = int(cx*800.f/960.f); } FillRectangle( x, y, cx, cy); }
/** ** Draw life bar of an unit at x,y. ** ** Placed under icons on top-panel. ** ** @param unit Pointer to unit. ** @param x Screen X postion of icon ** @param y Screen Y postion of icon */ local void DrawLifeBar(const Unit* unit,int x,int y) { int f; int color; y+=ICON_HEIGHT+8; FillRectangle(ColorBlack,x,y,ICON_WIDTH+8,7); if( unit->HP ) { f=(100*unit->HP)/unit->Stats->HitPoints; if( f>75) { color=ColorDarkGreen; } else if( f>50 ) { color=ColorYellow; } else { color=ColorRed; } f=(f*(ICON_WIDTH+4))/100; FillRectangle(color,x+2,y,f,5); } }
void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); FillRectangle(rc, back); // ybase is where the baseline should be, but wxWin uses the upper left // corner, so I need to calculate the real position for the text... hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); }
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); FillRectangle(rc, back); hdc->SetClippingRegion(wxRectFromPRectangle(rc)); // see comments above hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); hdc->DestroyClippingRegion(); }
//ignore void DrawPlate(int x,int y,int w,int h,u_char c,u_char state) { h--; w--; Color(c); FillRectangle(x+1,y+1,w-1,h-1); if (state == PLATE_DOWN) Color(BLACK); else Color(WHITE); DrawLine(x,y,x,y+h-1); DrawLine(x,y,x+w-1,y); if (state == PLATE_DOWN) Color(WHITE); else Color(BLACK); DrawLine(x+1,y+h,x+w,y+h); DrawLine(x+w,y+1,x+w,y+h); }
void SnippingWindow::OnRender() { if (screenshot != nullptr) { auto fullRect = D2D1::RectF(0.f, 0.f, PixelsToDipsX<float>(resolutionX), PixelsToDipsY<float>(resolutionY)); auto rt = GetRenderTarget(); rt->DrawBitmap(screenshot, fullRect); rt->PushLayer(D2D1::LayerParameters(), topLayer); rt->FillRectangle(fullRect, whiteBrush); rt->PopLayer(); rt->PushLayer(D2D1::LayerParameters(toolbarCtrl->manager->RectangleToShot), shownLayer); rt->DrawBitmap(screenshot, fullRect); rt->PopLayer(); } }
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { Q_ASSERT(painter); SurfaceImpl &si = static_cast<SurfaceImpl &>(surfacePattern); QPixmap *pm = static_cast<QPixmap *>(si.pd); if (pm) { QBrush brsh(Qt::black, *pm); painter->setPen(Qt::NoPen); painter->setBrush(brsh); painter->drawRect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); } else FillRectangle(rc, ColourAllocated(0)); }
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { Q_ASSERT(painter); SurfaceImpl &si = static_cast<SurfaceImpl &>(surfacePattern); QPixmap *pm = static_cast<QPixmap *>(si.pd); if (pm) { QBrush brsh(Qt::black, *pm); painter->setPen(Qt::NoPen); painter->setBrush(brsh); drawRect(rc); } else { FillRectangle(rc, ColourDesired(0)); } }
void Rectangle::CreateShadowTexture() { const auto pRenderTarget = sD3DMgr.GetRenderTarget(); const auto pOldSurface = pRenderTarget->GetRenderTargetSurface(); uint32 width = static_cast<uint32>(GetWidth()); uint32 height = static_cast<uint32>(GetHeight()); m_shadowTexture = pRenderTarget->CreateRenderTargetTexture(width, height); if (m_shadowTexture == nullptr) throw std::runtime_error("Could not create shadow texture!"); const auto pSurface = m_shadowTexture->GetObject()->QuerySurface(0); pRenderTarget->SetRenderTargetSurface(pSurface, 0, true); const auto dimensions = GetDimensions(); const auto gradientColors = GetGradientColors(); float4 horizRounding = GetHorizontalRoundings(); float4 vertRounding = GetVerticalRoundings(); if (((horizRounding._1 != 0.0f && vertRounding._1 != 0.0f) || (horizRounding._2 != 0.0f && vertRounding._2 != 0.0f) || (horizRounding._3 != 0.0f && vertRounding._3 != 0.0f) || (horizRounding._4 != 0.0f && vertRounding._4 != 0.0f))) { pRenderTarget->FillRoundedRectangle( Utils::Vector2(0.0f, 0.0f), dimensions, horizRounding, vertRounding, gradientColors); } else { pRenderTarget->FillRectangle( Utils::Vector2(0.0f, 0.0f), dimensions, gradientColors); } pRenderTarget->SetRenderTargetSurface(pOldSurface); GetGlobalInterface()->ClipStack.Apply(); }
void MyRadioButton::OnPaint() { glColor3f(color.R / 255.0, color.G / 255.0, color.B / 255.0); //Set color if (checked) { //DrawRectangle(X, Y, Width, Height); //FillRectangle(X + 2, Y + 3, Width - 5, Height - 5); DrawCircle(X + relativePos.X + 6, Y + relativePos.Y + 8, Width / 1.5); FillRectangle(X + relativePos.X + 2, Y + relativePos.Y + 6, Width / 2, Height / 2); } else { DrawCircle(X + relativePos.X +6, Y + relativePos.Y + 8, Width / 1.5); //DrawRectangle(X, Y, Width, Height); } label->SetRelativePos(this->GetRelativePos()); label->OnPaint(); }
/// <summary> /// IDWriteTextRenderer::DrawUnderline /// Draws an underline. /// </summary> HRESULT StateTextRender::DrawUnderline( LPVOID clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, const DWRITE_UNDERLINE * underline, LPUNKNOWN clientDrawingEffect) { UNREFERENCED_PARAMETER(clientDrawingEffect); D2D1_RECT_F rect = D2D1::RectF( baselineOriginX, baselineOriginY + underline->offset, baselineOriginX + underline->width, baselineOriginY + underline->offset + underline->thickness ); auto renderTarget = ((ID2D1RenderTarget*) clientDrawingContext); renderTarget->DrawRectangle(rect, mState->mBrushes[State::BrushType::TextStroke].brush, mState->mStateSettings.fontStrokeWidth); renderTarget->FillRectangle(rect, mState->mBrushes[State::BrushType::Text].brush); return S_OK; }
int Track_FindAllFaces (DET_PARAMS *ppDetParams[], // out const Image &Img, const char sDataDir[]) // in { Init(sDataDir); // init gFaceMask etc. int nLevs = 0; // figure out number of levels in pyramid int w = Img.width, h = Img.height; // (assumes image has a reasonable aspect ratio) while (w >= 20 && h >= 20) { w = int(w / 1.2); h = int(h / 1.2); nLevs++; } Image *ImagePyramid = new Image[nLevs]; // create pyramid: an array of images ImagePyramid[0] = Img; int iLev; for (iLev = 1; iLev < nLevs; iLev++) ReduceSizeBy1_2(ImagePyramid[iLev], ImagePyramid[iLev-1]); Image MainMask(Img.width, Img.height, true); // init to all zeroes: will later set 0=scan, 255=face found Image LevMask; // mask for current level List<Detection> AllDetectionsList[1]; // where we store detections for (iLev = nLevs-1; iLev >= 0; iLev--) { // get search mask at right level -- this scales MainMask into LevMask ResampleMask(LevMask, MainMask, ImagePyramid[iLev].width, ImagePyramid[iLev].height, POW12(-iLev)); // Find candidates for this level in the pyramid. // We search the given image using the 30x30 candidate detector. // LevMask is used to indicate which portions of the image not to // search because a face has already been found there. // When a face is found, the callback func SaveDetections // is invoked which basically saves the face in DetectionsList. // Note that the face mask is not used at this point. // iNet is hardcoded to 0 in SearchUme so we use umec.net (inited in Init). List<Detection> DetectionsList; SearchUme(ImagePyramid[iLev], &LevMask, iLev, SaveDetections, (ClientData)(&DetectionsList)); for (Detection* detect = DetectionsList.first; detect != NULL; detect = detect->next) { // Verify candidates. It works like this: // Given a candidate detection location and the image pyramid, // search the image around that candidate to try and find out // whether there is really a face there. // iNet=1 so we use nets 1 and 2 here (initialized // in Init to face17c.net and face18c.net). int newX, newY, newS; if (fFindNewLocation(&newX, &newY, &newS, nLevs, ImagePyramid, gFaceMask, detect->x, detect->y, detect->scale, 6, 6, 1, 2, 1)) // dx=6 dy=6 ds=1 step=2 iNet=1 { // got a verified candidate -- save it SaveDetections((ClientData)AllDetectionsList, &ImagePyramid[newS], newX, newY, 20, 20, newS, POW12(newS), 1.0); // put detection in main search mask, to save computation FillRectangle(MainMask, (int)(POW12(newS)*newX + 0.5), (int)(POW12(newS) * newY + 0.5), (int)(POW12(newS) * (newX+20) + 0.5), (int)(POW12(newS) * (newY+20) + 0.5), 255); } } } ReleaseProcessor(); // give others a chance // remove overlapping detections (a few may slip through) List<Detection> ResultsList; FuzzyVote2(Img.width, Img.height, 1, AllDetectionsList, SaveDetections, (ClientData)(&ResultsList), 2, 1, true, true, false, // 2 spread, 1 search, collapse, overlap, fFilterOdd gFaceMask); if (ResultsList.length == 0) *ppDetParams = NULL; else { *ppDetParams = (DET_PARAMS*)malloc(sizeof(DET_PARAMS) * ResultsList.length); int iLocs = 0; for (Detection *d = ResultsList.first; d != NULL; d = d->next) { DET_PARAMS *pDet = *ppDetParams + iLocs; // Update eye fields in pDet int nEyeScale = iFindEyesGivenRowleyFace(pDet, d, ImagePyramid); // Scale locations to original resolution // // Also convert x and y to cartesian coords with center of // image at 0,0 and center of face detector shape at x and y. // Do the same for the eye coords. double w0 = Img.width; double h0 = Img.height; double scale = POW12(d->scale); double width = 20 * scale; pDet->x = iround(d->x * scale - w0/2 + width/2); pDet->y = iround(h0/2 - d->y * scale - width/2); pDet->width = iround(width); pDet->height = iround(width); const double EyeScale = POW12(nEyeScale); if (pDet->lex != INVALID) { pDet->lex = iround(pDet->lex * EyeScale) - w0/2; pDet->ley = h0/2 - iround(pDet->ley * EyeScale); } if (pDet->rex != INVALID) { pDet->rex = iround(pDet->rex * EyeScale) - w0/2; pDet->rey = h0/2 - iround(pDet->rey * EyeScale); } iLocs++; } } for (iLev = 1; iLev < nLevs; iLev++) ImagePyramid[iLev].free(); delete[] ImagePyramid; return ResultsList.length; }
/** ** Draw decoration (invis, for the unit.) ** ** @param unit Pointer to the unit. ** @param type Type of the unit. ** @param x Screen X position of the unit. ** @param y Screen Y position of the unit. */ local void DrawDecoration(Unit* unit,UnitType* type,int x,int y) { int f; int color; UnitStats* stats; // // Health bar on left side of unit. // stats=unit->Stats; if( ShowHealthBar ) { if( stats->HitPoints && !(ShowNoFull && unit->HP==stats->HitPoints) ) { f=(100*unit->HP)/stats->HitPoints; if( f>75) { color=ColorDarkGreen; } else if( f>50 ) { color=ColorYellow; } else { color=ColorRed; } FillRectangle(color ,x+(type->TileWidth*TileSizeX -type->BoxWidth)/2 ,y+(type->TileHeight*TileSizeY -type->BoxHeight)/2 ,2,(f*type->BoxHeight)/100); } } // // Health dot on left side of unit. // if( ShowHealthDot ) { if( stats->HitPoints && !(ShowNoFull && unit->HP==stats->HitPoints) ) { int x1; int y1; int n; f=(100*unit->HP)/stats->HitPoints; if( f>75) { n=3-((f-75)/(25/3))+ 0; } else if( f>50 ) { n=3-((f-50)/(25/3))+ 4; DebugLevel3("%d - %d\n",f,n); } else { n=3-(f/(50/3))+ 8; DebugLevel3("%d - %d\n",f,n); } DebugCheck( n<0 ); x1=x-HealthSprite.HotX +(type->TileWidth*TileSizeX -type->BoxWidth)/2; y1=y-HealthSprite.HotY +(type->TileHeight*TileSizeY +type->BoxHeight)/2; DrawRleSpriteClipped(HealthSprite.RleSprite,n,x1,y1); } } // // Mana bar on right side of unit. // if( ShowManaBar ) { if( type->CanCastSpell && !(ShowNoFull && unit->Mana==255) ) { f=(100*unit->Mana)/255; FillRectangle(ColorBlue ,x+(type->TileWidth*TileSizeX +type->BoxWidth)/2 ,y+(type->TileHeight*TileSizeY -type->BoxHeight)/2 ,2,(f*type->BoxHeight)/100); } } // // Mana dot on right side of unit. // if( ShowManaDot ) { if( type->CanCastSpell && !(ShowNoFull && unit->Mana==255) ) { int x1; int y1; int n; f=(100*unit->Mana)/255; if( f>75) { n=0; } else if( f>50 ) { n=1; } else if( f>25 ) { n=2; } else { n=3; } x1=x-ManaSprite.HotX +(type->TileWidth*TileSizeX +type->BoxWidth)/2; y1=y-ManaSprite.HotY +(type->TileHeight*TileSizeY +type->BoxHeight)/2; DrawRleSpriteClipped(ManaSprite.RleSprite,n,x1,y1); } } // FIXME: group number could also be shown }
/** ** Clear the video screen. */ void CVideo::ClearScreen() { FillRectangle(ColorBlack, 0, 0, Video.Width, Video.Height); }
LRESULT StartMenuCtrlProc( HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam ) { RECT rc,rcItem,rcWin; HDC hDC; PAINTSTRUCT ps; int iWidth,iHeight; PWindowsTree pWin; int iCounter,iTotal; int iRetMsg; int x,y; pWin=(PWindowsTree)hWnd; switch(iMsg) { case LMSG_CREATE: pData = (PMENUDATA)malloc(sizeof(MENUDATA)); if(!pData) return false; memset(pData,0, sizeof(MENUDATA)); pWin->dwData = (DWORD)pData; pData->itemHeight = DEF_MENU_ITEM_HEIGHT;//default item height pData->itemHilighted = -1; pWin->dwData = (DWORD)pData; break; case LMSG_PENDOWN: CaptureMouse(hWnd,BYCLIENT); scrGetClientRect(hWnd,&rc); ScreenToClientRect(hWnd,&rc); x = (int)wParam; y = (int)lParam; ScreenToClient(hWnd,&x,&y); pData = (PMENUDATA)(pWin->dwData); iTotal =pData->itemCount; for(iCounter=0;iCounter<iTotal;iCounter++){ mnuGetItemsRect(pData,iCounter,&rcItem); rcItem.left=rc.left; rcItem.right =rc.right; if(PtInRect(&rcItem,x,y)){ pData->itemHilighted = iCounter; InvalidateRect(hWnd,&rcItem,true); break; } } break; case LMSG_PENUP: DisCaptureMouse(); scrGetClientRect(hWnd,&rc); ScreenToClientRect(hWnd,&rc); x = (int)wParam; y = (int)lParam; ScreenToClient(hWnd,&x,&y); pData = (PMENUDATA)(pWin->dwData); iTotal =pData->itemCount; for(iCounter=0;iCounter<iTotal;iCounter++){ mnuGetItemsRect(pData,iCounter,&rcItem); rcItem.left=rc.left; rcItem.right =rc.right; if(PtInRect(&rcItem,x,y)){ iRetMsg=STARTMENU_ITEM_CLICKED; iRetMsg=iRetMsg<<16; iRetMsg=iRetMsg | (unsigned long)(pData->items[iCounter].id); SendNotifyMessage((HWND)(pWin->pParent), LMSG_COMMAND,(WPARAM)iRetMsg,(LPARAM)NULL); break; } } break; case LMSG_PENMOVE: break; case LMSG_PAINT: { HFONT hFont; ps.bPaintDirect=false; hDC=BeginPaint(hWnd, &ps); if(!hDC){ return true; } scrGetClientRect(hWnd,&rc); ScreenToClientRect(hWnd,&rc); GetWindowRect(hWnd,&rcWin); iWidth =rcWin.right - rcWin.left + 1; iHeight =rcWin.bottom - rcWin.top + 1; pData = (PMENUDATA)(pWin->dwData); if(!pData) return false; iTotal =pData->itemCount; hFont = GetStockObject(FONT_12_12); SelectObject(hDC,hFont); for(iCounter=0;iCounter<iTotal;iCounter++){ mnuGetItemsRect(pData,iCounter,&rcItem); rcItem.left=rc.left; rcItem.right =rc.right; if(iCounter == pData->itemHilighted) FillRectangle(hDC,rcItem.left,rcItem.top,rcItem.right,rcItem.bottom,RGB_SYSTEMBRIGHT,RGB_SYSTEMBRIGHT); OutputBmpObjWithTrColor(hDC,rcItem.left , rcItem.top + 2, iWidth,iHeight,(HBITMAP)(pData->items[iCounter].pBitmap),RGB(230,230,230)); rcItem.left +=14; DrawText(hDC,pData->items[iCounter].lpszName, strlen(pData->items[iCounter].lpszName),&rcItem,DT_CENTER); } DeleteObject(hFont); EndPaint(hWnd, &ps); break; } case LMSG_DESTROY: DestroyStartMenuItems(hWnd); break; case SM_ADDITEM: pData = (PMENUDATA)(pWin->dwData); mnuAddItem(hWnd,pData,(PMENUITEM)wParam); return true; default: return DefWindowProc(hWnd, iMsg, wParam, lParam); } return true; }
void UpdateDebugDialog() { if(!debugDialogOpen) return; lCount++; if(lCount>=(SampleRate/10)) { HDC hdc = GetDC(hDebugDialog); if(!hf) { hf = CreateFont( 8, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Lucida Console") ); } SelectObject(hdc,hf); SelectObject(hdc,GetStockObject(DC_BRUSH)); SelectObject(hdc,GetStockObject(DC_PEN)); for(int c=0;c<2;c++) { for(int v=0;v<24;v++) { int IX = 8+256*c; int IY = 8+ 32*v; V_Voice& vc(Cores[c].Voices[v]); V_VoiceDebug& vcd( DebugCores[c].Voices[v] ); SetDCBrushColor(hdc,RGB( 0, 0, 0)); if((vc.ADSR.Phase>0)&&(vc.ADSR.Phase<6)) { SetDCBrushColor(hdc,RGB( 0, 0,128)); } else { if(vcd.lastStopReason==1) { SetDCBrushColor(hdc,RGB(128, 0, 0)); } if(vcd.lastStopReason==2) { SetDCBrushColor(hdc,RGB( 0,128, 0)); } } FillRectangle(hdc,IX,IY,252,30); SetDCPenColor(hdc,RGB( 255, 128, 32)); DrawRectangle(hdc,IX,IY,252,30); SetDCBrushColor (hdc,RGB( 0,255, 0)); int vl = abs(((vc.Volume.Left.Value >> 16) * 24) >> 15); int vr = abs(((vc.Volume.Right.Value >> 16) * 24) >> 15); FillRectangle(hdc,IX+38,IY+26 - vl, 4, vl); FillRectangle(hdc,IX+42,IY+26 - vr, 4, vr); int adsr = (vc.ADSR.Value>>16) * 24 / 32768; FillRectangle(hdc,IX+48,IY+26 - adsr, 4, adsr); int peak = vcd.displayPeak * 24 / 32768; FillRectangle(hdc,IX+56,IY+26 - peak, 4, peak); SetTextColor(hdc,RGB( 0,255, 0)); SetBkColor (hdc,RGB( 0, 0, 0)); static wchar_t t[1024]; swprintf_s(t,_T("%06x"),vc.StartA); TextOut(hdc,IX+4,IY+3,t,6); swprintf_s(t,_T("%06x"),vc.NextA); TextOut(hdc,IX+4,IY+12,t,6); swprintf_s(t,_T("%06x"),vc.LoopStartA); TextOut(hdc,IX+4,IY+21,t,6); vcd.displayPeak = 0; if(vcd.lastSetStartA != vc.StartA) { printf(" *** Warning! Core %d Voice %d: StartA should be %06x, and is %06x.\n", c,v,vcd.lastSetStartA,vc.StartA); vcd.lastSetStartA = vc.StartA; } } } ReleaseDC(hDebugDialog,hdc); lCount=0; }
//Left side Ground, Right side Rock void World::WorldGen() { int x = (GridSX >> 1) - 1; FillRectangle(0, 0, x, GridSY - 1, WorldDef_Ground); FillRectangle(x + 1, 0, GridSX - 1, GridSY - 1, WorldDef_Rock); }
static void copy_pixtemp(int id, int x, int y) { COLORREF cf; HDC hdc, hdcPix; HBITMAP xpixOld; HBRUSH hBrush, hOBrush; int x0, y0, x1, y1, x_abs, y_abs; if (!WI[id].pixcopymode) return; x -= tempx; y -= tempy; if (pixclamp) { x = max(clampx1, x); x = min(clampx2, x); y = max(clampy1, y); y = min(clampy2, y); } x0 = max(0, -x); x0 = min(x0, temp_dx); y0 = max(0, -y); y0 = min(y0, temp_dy); x1 = max(0, x); x1 = min(x1, temp_dx); y1 = max(0, y); y1 = min(y1, temp_dy); x_abs = abs(x); y_abs = abs(y); hdc = GetDC(WI[id].child[C_DRAWAREA].hwnd); hdcPix = CreateCompatibleDC(hdc); xpixOld = SelectObject(hdcPix, pixtemp); cf = GetNearestColor(hdc, RGB(127,127,127)); hBrush = CreateSolidBrush(cf); hOBrush = SelectObject(hdc, hBrush); if (x1) FillRectangle(tempx1, tempy1, x1, temp_dy, hdc, hBrush); if (y1) FillRectangle(tempx1, tempy1, temp_dx, y1, hdc, hBrush); if (x0) FillRectangle(tempx1 + (temp_dx - x_abs), tempy1, x0, temp_dy, hdc, hBrush); if (y0) FillRectangle(tempx1, tempy1 + (temp_dy - y_abs), temp_dx, y0, hdc, hBrush); SelectObject(hdc, hOBrush); DeleteObject(hBrush); BitBlt(hdc, tempx1 + x1, tempy1 + y1, temp_dx - x_abs, temp_dy - y_abs, hdcPix, x0, y0, SRCCOPY); SelectObject(hdcPix, xpixOld); DeleteDC(hdcPix); ReleaseDC(WI[id].child[C_DRAWAREA].hwnd, hdc); }
/** Fill the given rectangle with the background color defined in Display. This is a high level function. You should use it whenever you want to clear a area and give it the background color. The base class implements this method by pushing the backgroundColor, drawing a rectangle using DrawInfo.FillRectangle and then poping the color back. */ void DrawInfo::FillBackground(int x, int y, int width, int height) { PushForeground(Display::backgroundColor); FillRectangle(x,y,width,height); PopForeground(); }
HRESULT D3D12MemoryManagement::RenderScene(const RectF& ViewportBounds) { RectF SceneBounds = m_pSceneCamera->GenerateViewportBounds(); for (auto& Img : m_Images) { Resource* pResource = Img.pResource; // // Get image visibility and prefetching information. // UINT8 VisibleMip; UINT8 PrefetchMip; CalculateImagePagingData(&SceneBounds, &Img, &VisibleMip, &PrefetchMip); // // If the visibility or prefetch values have changed, notify the paging thread // so it can update this resource's priority. // if (pResource->VisibleMip != VisibleMip || pResource->PrefetchMip != PrefetchMip) { pResource->VisibleMip = VisibleMip; pResource->PrefetchMip = PrefetchMip; NotifyPagingWork(pResource); } // // Although visibility information is calculated above using the scene camera, for debug // purposes, we may want to render with another camera. We will calculate the real // image visibility for rendering purposes using the viewport bounds instead of the scene // bounds. // bool IsVisible = RectIntersects(Img.Bounds, ViewportBounds); if (IsVisible) { static const ColorF DefaultColor = { 1, 1, 1, 1 }; FillRectangle(&Img.Bounds, &DefaultColor, pResource); if (m_bDrawMipColors) { // // Render overlay and border around images to indicate both the visible // mipmap, and the mipmap that is resident. This shows the difference // between the requested and actual mipmap. // static const ColorF MipColors[MAX_MIP_COUNT] = { { 1.0f, 0.0f, 0.0f, 0.5f }, // Red { 1.0f, 0.5f, 0.0f, 0.5f }, // Orange { 1.0f, 1.0f, 0.0f, 0.5f }, // Yellow { 0.0f, 1.0f, 0.0f, 0.5f }, // Green { 0.0f, 1.0f, 1.0f, 0.5f }, // Aqua { 0.0f, 0.5f, 0.5f, 0.5f }, // LightBlue { 0.0f, 0.0f, 1.0f, 0.5f }, // Blue { 0.5f, 0.0f, 1.0f, 0.5f }, // Purple { 1.0f, 0.0f, 1.0f, 0.5f }, // Magenta { 0.6f, 0.3f, 0.0f, 0.5f }, // Brown { 0.4f, 0.4f, 0.0f, 0.5f }, // Gold { 1.0f, 1.0f, 1.0f, 0.5f }, // White { 0.7f, 0.7f, 0.7f, 0.5f }, // LightGray { 0.3f, 0.3f, 0.3f, 0.5f }, // DarkGray { 0.0f, 0.0f, 0.0f, 0.5f }, // Black }; VisibleMip = pResource->VisibleMip; const ColorF* pVisibleColor = &MipColors[VisibleMip]; FillRectangle(&Img.Bounds, pVisibleColor); UINT8 ResidentMip = pResource->MostDetailedMipResident; const ColorF* pResidentColor = &MipColors[ResidentMip]; DrawRectangle(&Img.Bounds, 2.0f, pResidentColor); } } } // // Render debug viewport. // { ColorF ViewportColor = { 1.0f, 0.0f, 0.0f, 0.25f }; ColorF ViewportColorNoPrefetch = { 1.0f, 0.0f, 0.0f, 1.0f }; const ColorF* pColor = &ViewportColorNoPrefetch; float Thickness = 2 / m_ViewportCamera.GetZoom(); float ScaledPrefetchDistance = PREFETCH_DISTANCE / m_pSceneCamera->GetZoom(); Thickness = ScaledPrefetchDistance; pColor = &ViewportColor; DrawRectangle(&SceneBounds, Thickness, pColor); } return S_OK; }
void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height) { FillRectangle(bitmap, x, y, width, height, BLACK_PIXEL); }
void UpdateDebugDialog() { if(!debugDialogOpen) return; lCount++; if(lCount>=(SampleRate/100)) // Increase to SampleRate/200 for smooth display. { HDC hdc = GetDC(hDebugDialog); if(!hf) { hf = CreateFont( 12, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Lucida Console" ); } SelectObject(hdc,hf); SelectObject(hdc,GetStockObject(DC_BRUSH)); SelectObject(hdc,GetStockObject(DC_PEN)); for(int c=0;c<2;c++) { V_Core& cx(Cores[c]); V_CoreDebug& cd(DebugCores[c]); for(int v=0;v<24;v++) { int cc = c*2 + (v/12); int vv = v % 12; int IX = 8+128*cc; int IY = 8+ 48*vv; V_Voice& vc(cx.Voices[v]); V_VoiceDebug& vcd(cd.Voices[v] ); SetDCBrushColor(hdc,RGB( 0, 0, 0)); if((vc.ADSR.Phase>0)&&(vc.ADSR.Phase<6)) { SetDCBrushColor(hdc,RGB( 0, 0,128)); } /* else { if(vcd.lastStopReason==1) { SetDCBrushColor(hdc,RGB(128, 0, 0)); } if(vcd.lastStopReason==2) { SetDCBrushColor(hdc,RGB( 0,128, 0)); } }*/ FillRectangle(hdc,IX,IY,124,46); SetDCPenColor(hdc,RGB( 255, 128, 32)); DrawRectangle(hdc,IX,IY,124,46); SetDCBrushColor(hdc,RGB( 0,255, 0)); int vl = abs(((vc.Volume.Left.Value >> 16) * 38) >> 15); int vr = abs(((vc.Volume.Right.Value >> 16) * 38) >> 15); FillRectangle(hdc,IX+58,IY+42 - vl, 4, vl); FillRectangle(hdc,IX+62,IY+42 - vr, 4, vr); int adsr = ((vc.ADSR.Value>>16) * 38) / 32768; FillRectangle(hdc,IX+66,IY+42 - adsr, 4, adsr); int peak = (vcd.displayPeak * 38) / 32768; if(vcd.displayPeak >= 32700) // leave a little bit of margin { SetDCBrushColor(hdc,RGB( 255, 0, 0)); } FillRectangle(hdc,IX+70,IY+42 - peak, 4, peak); if(vc.ADSR.Value>0) { if(vc.SBuffer) for(int i=0;i<28;i++) { int val = ((int)vc.SBuffer[i] * 20) / 32768; int y=0; if(val>0) { y=val; } else val=-val; if(val!=0) { FillRectangle(hdc,IX+90+i,IY+24-y, 1, val); } } } SetTextColor(hdc,RGB( 0,255, 0)); SetBkColor (hdc,RGB( 0, 0, 0)); static wchar_t t[256]; swprintf_s(t,L"%06x",vc.StartA); TextOut(hdc,IX+4,IY+4,t,6); swprintf_s(t,L"%06x",vc.NextA); TextOut(hdc,IX+4,IY+18,t,6); swprintf_s(t,L"%06x",vc.LoopStartA); TextOut(hdc,IX+4,IY+32,t,6); vcd.displayPeak = 0; if(vcd.lastSetStartA != vc.StartA) { printf(" *** Warning! Core %d Voice %d: StartA should be %06x, and is %06x.\n", c,v,vcd.lastSetStartA,vc.StartA); vcd.lastSetStartA = vc.StartA; } } // top now: 400 int JX = 8 + c * 256; int JY = 584; SetDCBrushColor(hdc,RGB( 0, 0, 0)); SetDCPenColor(hdc,RGB( 255, 128, 32)); FillRectangle(hdc,JX,JY,252,60); DrawRectangle(hdc,JX,JY,252,60); SetTextColor(hdc,RGB(255,255,255)); SetBkColor (hdc,RGB( 0, 0, 0)); static wchar_t t[256]; TextOut(hdc,JX+4,JY+ 4,L"REVB",4); TextOut(hdc,JX+4,JY+18,L"IRQE",4); TextOut(hdc,JX+4,JY+32,L"ADMA",4); swprintf_s(t,L"DMA%s",c==0 ? L"4" : L"7"); TextOut(hdc,JX+4,JY+46,t, 4); SetTextColor(hdc,RGB( 0,255, 0)); memset(t, 0, sizeof(t)); swprintf_s(t,L"ESA %x",cx.EffectsStartA); TextOut(hdc,JX+56,JY+ 4,t, 9); memset(t, 0, sizeof(t)); swprintf_s(t,L"EEA %x",cx.EffectsEndA); TextOut(hdc,JX+128,JY+ 4,t, 9); memset(t, 0, sizeof(t)); swprintf_s(t,L"(%x)",cx.EffectsBufferSize); TextOut(hdc,JX+200,JY+ 4,t,7); memset(t, 0, sizeof(t)); swprintf_s(t,L"IRQA %x",cx.IRQA); TextOut(hdc,JX+56,JY+18,t, 12); SetTextColor(hdc,RGB(255,255,255)); SetDCBrushColor(hdc,RGB( 255,0, 0)); if(cx.FxEnable) { FillRectangle(hdc,JX+40,JY+4,10,10); } if(cx.IRQEnable) { FillRectangle(hdc,JX+40,JY+18,10,10); } if(cx.AutoDMACtrl != 0) { FillRectangle(hdc,JX+40,JY+32,10,10); for(int j=0;j<64;j++) { int i=j*256/64; int val = (cd.admaWaveformL[i] * 26) / 32768; int y=0; if(val>0) y=val; else val=-val; if(val!=0) { FillRectangle(hdc,JX+60+j,JY+30-y, 1, val); } } for(int j=0;j<64;j++) { int i=j*256/64; int val = (cd.admaWaveformR[i] * 26) / 32768; int y=0; if(val>0) y=val; else val=-val; if(val!=0) { FillRectangle(hdc,JX+136+j,JY+30-y, 1, val); } } } if(cd.dmaFlag > 0) // So it shows x times this is called, since dmas are so fast { swprintf_s(t,L"size = %d",cd.lastsize); TextOut(hdc,JX+64,JY+46,t,wcslen(t)); FillRectangle(hdc,JX+40,JY+46,10,10); cd.dmaFlag--; } } ReleaseDC(hDebugDialog,hdc); lCount=0; }
int FillRectangle(SDL_Surface* dest, int x, int y, int w, int h, SDL_Color color) { return FillRectangle(dest, x, y, w, h, color.r, color.g, color.b); }