BOOL CSkinBase::GradientFillSlow(CDC* pDCDest, LPRECT lpRect, COLORREF crFrom, COLORREF crTo, BOOL bHorz) { if (!pDCDest || !lpRect) return FALSE; int nWidth = lpRect->right - lpRect->left; int nHeight = lpRect->bottom - lpRect->top; if (bHorz) { for (int nX = lpRect->left; nX < lpRect->right; nX++) pDCDest->FillSolidRect(nX, lpRect->top, 1, nHeight, BlendColors(crFrom, crTo, (lpRect->right - nX) / (float)nWidth)); } else { for (int nY = lpRect->top; nY < lpRect->bottom; nY++) pDCDest->FillSolidRect(lpRect->left, nY, nWidth, 1, BlendColors(crFrom, crTo, (lpRect->bottom - nY) / (float)nHeight)); } return TRUE; }
void CVisualizerStatic::Draw() { const char STR[] = "0CC-FamiTracker"; // // // const size_t COUNT = std::size(STR); static long long t = 0; const auto FixRGB = [] (int x) { return MakeRGB(GetB(x), GetG(x), GetR(x)); }; const COLORREF Back[] = { FixRGB(FTEnv.GetSettings()->Appearance.iColBackground), FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite), FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite2), }; const COLORREF Color = FixRGB(FTEnv.GetSettings()->Appearance.iColPatternText); const COLORREF Shadow = BlendColors(Color, 1, Back[0], 2); for (int y = m_iHeight - 1; y >= 0; --y) for (int x = m_iWidth - 1; x >= 0; --x) { int Dist = (abs(x - m_iWidth / 2) + abs(y - m_iHeight / 2) - t / 5) % 12; if (Dist < 0) Dist += 12; m_pBlitBuffer[y * m_iWidth + x] = Back[Dist / 4]; } for (size_t i = 0; i < COUNT; ++i) { double Phase = .07 * t - .9 * i; double x = sin(Phase) * 2. + m_iWidth + 11. * i - .4 * t; double y = sin(Phase) * 7.; const double MAX = m_iWidth + 120.; if (x < 0) { x = fmod(x, MAX); if (x < -40.) x += MAX; } DrawChar(STR[i], static_cast<int>(x) + 1, static_cast<int>(m_iHeight / 2. - 3.5 - y) + 1, Shadow); DrawChar(STR[i], static_cast<int>(x), static_cast<int>(m_iHeight / 2. - 3.5 - y), Color); } ++t; }
void CMine::Illuminate ( INT16 source_segnum, INT16 source_sidenum, UINT32 brightness, double fLightScale, bool bAll, bool bCopyTexLights) { CDSegment *seg = Segments (); CDSegment *child_seg; double effect[4]; // find orthogonal angle of source segment vms_vector A; //fLightScale /= 100.0; CalcOrthoVector (A,source_segnum,source_sidenum); // remember to flip the sign since we want it to point inward A.x = -A.x; A.y = -A.y; A.z = -A.z; // calculate the center of the source segment vms_vector source_center; CalcCenter (source_center,source_segnum,source_sidenum); if ((source_segnum == 911) && (source_sidenum == 3)) A = A; // mark those Segments () within N children of current cube // set child numbers //Segments ()[source_segnum].seg_number = m_lightRenderDepth; int i; for (i = SegCount (); i; i--, seg++) seg->seg_number = -1; SetSegmentChildNum (NULL, source_segnum, m_lightRenderDepth); CDColor *plc = LightColor (source_segnum, source_sidenum); if (!plc->index) { plc->index = 255; plc->color.r = plc->color.g = plc->color.b = 1.0; } if (UseTexColors () && bCopyTexLights) { CDColor *psc = LightColor (source_segnum, source_sidenum, false); *psc = *plc; } seg = Segments (source_segnum); seg->seg_number = m_lightRenderDepth; bool bWall = false; //FindWall (source_segnum, source_sidenum) != NULL; // loop on child Segments () int child_segnum; for (child_segnum=0, child_seg = Segments ();child_segnum<SegCount ();child_segnum++, child_seg++) { // skip if this is not viewable if (child_seg->seg_number < 0) continue; // skip if not marked // if (!(bAll || (child_seg->wall_bitmask & MARKED_MASK))) // continue; // setup source corner vertex for length calculation later vms_vector source_corner[4]; int j; for (j = 0; j < 4; j++) { int vertnum = side_vert [source_sidenum][j]; int h = seg->verts [vertnum]; source_corner[j].x = Vertices (h)->x; source_corner[j].y = Vertices (h)->y; source_corner[j].z = Vertices (h)->z; } // loop on child sides int child_sidenum; for (child_sidenum = 0; child_sidenum < 6; child_sidenum++) { // if side has a child.. if (!(bAll || SideIsMarked (child_segnum, child_sidenum))) continue; if (child_seg->children[child_sidenum] >= 0) { UINT16 nWall = child_seg->sides[child_sidenum].nWall; // .. but there is no wall .. if (nWall >= GameInfo ().walls.count) continue; // .. or its not a door .. if (Walls (nWall)->type == WALL_OPEN) continue; } // CBRK (psc->index > 0); // if the child side is the same as the source side, then set light and continue #ifdef _DEBUG CBRK (child_segnum == qqq1 && child_sidenum == qqq2); #endif if (child_sidenum == source_sidenum && child_segnum == source_segnum) { uvl *uvlP = child_seg->sides [child_sidenum].uvls; UINT32 vBr, lBr; theApp.SetModified (TRUE); int j; for (j = 0; j < 4; j++, uvlP++) { CDColor *pvc = VertexColors (child_seg->verts [side_vert [child_sidenum][j]]); vBr = (UINT16) uvlP->l; lBr = (UINT32) (brightness * fLightScale); BlendColors (plc, pvc, lBr, vBr); vBr += lBr; vBr = min (0x8000, vBr); uvlP->l = (UINT16) vBr; } continue; } // calculate vector between center of source segment and center of child // CBRK (child_segnum == 1 && child_sidenum == 2); if (CalcSideLights (child_segnum, child_sidenum, source_center, source_corner, A, effect, fLightScale, bWall)) { UINT32 vBr, lBr; //vertex brightness, light brightness uvl *uvlP = child_seg->sides [child_sidenum].uvls; theApp.SetModified (TRUE); int j; for (j = 0; j < 4; j++, uvlP++) { CDColor *pvc = VertexColors (child_seg->verts [side_vert [child_sidenum][j]]); if (child_seg->verts [side_vert [child_sidenum][j]] == 2368) j = j; vBr = (UINT16) uvlP->l; lBr = (UINT16) (brightness * effect [j] / 32); BlendColors (plc, pvc, lBr, vBr); vBr += lBr; vBr = min (0x8000, vBr); uvlP->l = (UINT16) vBr; } } } } }