void showLed(LedGroup* group, int i) { int index = random(1, 3); byte r = min(Red(currentColor) + index, Red(currentColor)); byte g = min(Green(currentColor) + index, Green(currentColor)); byte b = min(Blue(currentColor) + index, Blue(currentColor)); group->waitFrames = 100; group->targetColors[i] = createColor(r,g,b); }
void main(void) { _RD = 1; P0=0xf0; _RES = 1; Delay(10); _RES = 0; Delay(50); _RES = 1; Delay(10); SPFD5420A_CPT30W_Initial(); Clear(); juxing(0,0,239,40,0x07e0); Blue(1,238,1,39); ShowString(1,1,"Hello ,world!!!"); ShowString(1,17,"My name is KKK!!!"); Delay(10000); Clear(); juxing(0,0,239,20,0x07e0); Blue(1,238,1,19); ShowString(1,1,"Now let's have a look!"); Delay(10000); while(1) { blue_dark_zong(); Delay(1000); red_dark_heng(); Delay(1000); green_dark_zong(); Delay(1000); blue_dark_heng(); Delay(1000); red_dark_zong(); Delay(1000); green_dark_heng(); Delay(10000); Clear(); drawline(0,0x00ef,0,0x018f,0xffff); Delay(1000); drawline(0,0x00ef,0,0x018f,0xffff); Delay(1000); drawline(0,0,0,399,0xffff); drawline(239,239,0,399,0xffff); drawline(0,239,0,0,0xffff); drawline(0,239,399,399,0xffff); Delay(10000); Clear(); sin(); Delay(1000); Clear(); // show_pic(gImage_1,0,0,49,49); // show_pic(gImage_1,40,40,60,40); } }
void Stroke(Painter& sw) { const char *txt = "GRM"; Font fnt = Arial(100).Bold(); Size tsz = GetTextSize(txt, fnt); sw.Scale(3, 3); sw.Text(100, 100, txt, fnt) .Stroke(10, 100, 100, Blue(), 100 + tsz.cx, 100, LtRed()) .Stroke(0.25, White()); sw.Path("M 100 100 L 200 100 L 210 90 L 220 40 L 230 90 L 240 100 L 400 100") .Stroke(24, Blue()); }
LKColor LKColor::MixColors(const LKColor& Color2, double fFact1) const { double fFact2 = 1.0f - fFact1; #ifdef GREYSCALE int Luminosity1 = GetLuminosity(); int Luminosity2 = Color2.GetLuminosity(); int Luminosity = (int) (fFact1 * (double) Luminosity1 + fFact2 * (double) Luminosity2); if (Luminosity > 255) Luminosity = 255; return Color(Luminosity, Alpha()); #else uint8_t red1 = Red(); uint8_t green1 = Green(); uint8_t blue1 = Blue(); uint8_t red2 = Color2.Red(); uint8_t green2 = Color2.Green(); uint8_t blue2 = Color2.Blue(); int red = (int) (fFact1 * (double) red1 + fFact2 * (double) red2); if (red > 255) red = 255; int green = (int) (fFact1 * (double) green1 + fFact2 * (double) green2); if (green > 255) green = 255; int blue = (int) (fFact1 * (double) blue1 + fFact2 * (double) blue2); if (blue > 255) blue = 255; return LKColor((uint8_t) red, (uint8_t) green, (uint8_t) blue); #endif }
double ON_Color::Hue() const { // returns 0 to 2*pi // 0 = red, pi/3 = yellow, 2*pi/3 = green, // pi = cyan, 4*pi/3 = blue, 5*pi/3 = magenta, // 2*pi = red double h; int r = Red(); int g = Green(); int b = Blue(); int minrgb, maxrgb; if ( r <= g ) {minrgb = r; maxrgb = g;} else {minrgb = g; maxrgb = r;} if (minrgb > b) minrgb = b; else if (maxrgb < b ) maxrgb = b; if ( maxrgb != minrgb ) { double d = 1.0/(maxrgb - minrgb); if ( r == maxrgb) { h = (g - b)*d; if ( h < 0.0 ) h += 6.0; } else if ( g == maxrgb) h = 2.0 + (b - r)*d; else h = 4.0 + (r - g)*d; h *= ON_PI/3.0; } else h = 0.0; return h; }
// returns the addition of this color with another color Color Color::operator+ (const Color& vRhs) const { double trans=Transparent() > vRhs.Transparent() ? Transparent() : vRhs.Transparent(); return Color(Red()+vRhs.Red(),Green()+vRhs.Green(),Blue()+vRhs.Blue(), trans); }
int wxColour::AllocColour(WXDisplay* display, bool realloc) { if ((m_pixel != -1) && !realloc) return m_pixel; XColor color; color.red = (unsigned short) Red (); color.red |= color.red << 8; color.green = (unsigned short) Green (); color.green |= color.green << 8; color.blue = (unsigned short) Blue (); color.blue |= color.blue << 8; color.flags = DoRed | DoGreen | DoBlue; WXColormap cmap = wxTheApp->GetMainColormap(display); if (!XAllocColor ((Display*) display, (Colormap) cmap, &color)) { m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap); return m_pixel; } else { m_pixel = (int) color.pixel; return m_pixel; } }
/** * Returns the highlighted version of this color. */ constexpr Color Highlight() const { return Color((Red() + 0xff * 3) / 4, (Green() + 0xff * 3) / 4, (Blue() + 0xff * 3) / 4); }
// Update the Fade Pattern void FadeUpdate() { // Calculate linear interpolation between Color1 and Color2 // Optimise order of operations to minimize truncation error uint8_t red = ((Red(Color1) * (TotalSteps - Index)) + (Red(Color2) * Index)) / TotalSteps; uint8_t green = ((Green(Color1) * (TotalSteps - Index)) + (Green(Color2) * Index)) / TotalSteps; uint8_t blue = ((Blue(Color1) * (TotalSteps - Index)) + (Blue(Color2) * Index)) / TotalSteps; uint8_t white = ((White(Color1) * (TotalSteps - Index)) + (White(Color2) * Index)) / TotalSteps; // Serial.print(red); Serial.print(","); // Serial.print(green); Serial.print(","); // Serial.print(blue); Serial.print(","); // Serial.print(white); Serial.println(); ColorSet(Color(red, green, blue, white)); show(); Increment(); }
Color::Color(double vRed, double vGreen, double vBlue, double vTransparent) { Red(vRed); Green(vGreen); Blue(vBlue); Transparent(vTransparent); }
void TextStrokeGradient(Painter& sw) { const char *txt = "GRADIENT TEXT"; Font fnt = Arial(100).Bold(); Size tsz = GetTextSize(txt, fnt); sw.Text(100, 100, txt, fnt) .Stroke(4, 100, 100, Blue(), 100 + tsz.cx, 100, LtRed()); }
/******************************************************************************* Function : DDV_DrawSequenceName() Purpose : draw the name of the sequence (left column of the DDV panel) Parameters : GrData; graphical data (font size, etc) ScaleStyle;style of the ParaG scale top, left; coord to start the draw Return value : none *******************************************************************************/ static void DDV_DrawSequenceName(UnDViewerGraphDataPtr GrData,ParaGPtr pgp, Int2 top,Int2 left,Int4 cur_row,Int4 CurEditRow,Int4 CurMasterRow) { SeqIdPtr sip = NULL; RecT rc; Int2 x,y,decal=1,size;/*text position/size*/ Char szAccess[21]; BioseqPtr bsp; /*get a name*/ bsp = BioseqLockById(pgp->sip); if(bsp) { sip = SeqIdFindBestAccession(bsp->id); BioseqUnlock(bsp); } if (!sip) sip = SeqIdFindBest(pgp->sip, 0); SeqIdWrite(sip, szAccess,PRINTID_TEXTID_ACCESSION, 20); /*compute position*/ if (pgp->ScaleStyle==SCALE_POS_TOP) decal++; /*draw name*/ size=StringWidth(szAccess); x=left/*-GrData->udv_scale.cxLeftScale*/-size; y=top+decal*GrData->udv_font.LineHeight; MoveTo(x,y); if (cur_row==CurEditRow){ Magenta(); } PaintString (szAccess); if (cur_row==CurMasterRow){ Blue(); MoveTo(x,y); LineTo(x+size,y); } /*draw a little box (for selection a full sequence)*/ left+=GrData->udv_font.cxChar; top+=GrData->udv_font.cxChar/2; LoadRect(&rc,left,top,left+GrData->udv_font.cxChar, top+GrData->udv_font.cxChar); Blue(); PaintOval(&rc); Black(); }
void OnPath(Painter& sw) { sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue()); for(int i = -1; i <= 16; i++) { sw.BeginOnPath(i / 15.0); sw.Move(0, -6).Line(6, 0).Line(0, 6).Close().Stroke(1, Black()); sw.End(); } }
constexpr Color WithAlpha(uint8_t alpha) const { #ifdef GREYSCALE return Color(GetLuminosity(), alpha); #else return Color(Red(), Green(), Blue(), alpha); #endif }
double ON_Color::Value() const { // 0.0 to 1.0 0.0 = black, 1.0 = white int r = Red(); int g = Green(); int b = Blue(); int maxrgb = ( r <= g ) ? g : r; if ( maxrgb < b ) maxrgb = b; return (maxrgb/255.0); }
void GradientStop(Painter& sw) { sw.Rectangle(20.5, 20.5, 500, 100) .ColorStop(0.25, Green()) .ColorStop(0.5, Yellow()) .ColorStop(0.75, Gray()) .Fill(0, 0, Blue(), 500, 0, LtRed()) .Stroke(1, Black()); }
void happy(LedGroup* group) { byte r = Red(currentColor); byte g = Green(currentColor); byte b = Blue(currentColor); Color highColor1 = createColor(r/ 2, g/2, b/2); Color highColor2 = createColor(250, 250, 250); for(int i=0;i<group->selectionLen; i++) { switch(group->pixelState[i]) { case 0: group->targetColors[i] = highColor1; group->pixelState[i]++; break; case 1: updateState(group, i, i); break; case 2: if(i == group->selectionLen - 1 && group->selectionLen < 10) { group->animatingPixel[group->selectionLen] = nextUnselected(group); group->pixelState[group->selectionLen] = 0; group->selectionLen++; } group->targetColors[i] = highColor2; group->pixelState[i]++; break; case 3: updateState(group, i, i); break; case 4: group->targetColors[i] = currentColor; group->pixelState[i]++; break; case 5: updateState(group, i, i); break; default: group->pixelState[i] = 0; group->animatingPixel[i] = nextUnselected(group); if(firstUnselected(group) >= group->length - 1) { group->animation = &flicker; group->selection = &flickerStrategy; group->counter = 0; group->waitFrames = 0; } } } }
void swapCurrentColor() { byte r = Red(currentColor); byte g = Green(currentColor); byte b = Blue(currentColor); currentColor = createColor(b, r,g); Serial.print("color:"); Serial.println(currentColor); }
void OnPathBee(Painter& sw) { sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue()); for(int i = -1; i <= 16; i++) { sw.BeginOnPath(i / 15.0); sw.DrawImage(0, -TestImg::Bee().GetHeight() / 2, TestImg::Bee()); sw.End(); } }
LKColor LKColor::ContrastTextColor() const { #ifdef GREYSCALE return (GetLuminosity() > 127 ? RGB_BLACK : RGB_WHITE); #else // human eye brightness color factors // Y=0.30 R + 0.59 G + 0.11 B. return ((0.30 * (double) Blue() + 0.59 * (double) Green() + 0.11 * (double) Red() > 127) ? RGB_BLACK : RGB_WHITE); #endif }
/** * Returns the shadowed version of this color. */ constexpr Color Shadow() const { #ifdef GREYSCALE return Color(GetLuminosity() * 15u / 16u); #else return Color(Red() * 15u / 16u, Green() * 15u / 16u, Blue() * 15u / 16u, Alpha()); #endif }
void StateEvaluationTreePanel::drawIndicatorAtArea(wxDC &DC, IndicatorStyle const &Style, wxCoord X, wxCoord Y, wxCoord W, wxCoord H) { auto const Kind = Style.GetKind(); auto const FG = Style.GetForeground(); wxPen const PrevPen = DC.GetPen(); wxBrush const PrevBrush = DC.GetBrush(); switch (Kind) { case IndicatorStyle::EKind::Plain: DC.SetPen(wxPen{FG, Settings.PenWidth}); DC.DrawLine(X, Y+H, X+W, Y+H); break; case IndicatorStyle::EKind::Box: DC.SetPen(wxPen{FG, Settings.PenWidth}); DC.DrawRectangle(X, Y, W, H); break; case IndicatorStyle::EKind::StraightBox: // Many DCs don't support alpha at all, so manually calculate an alpha // against the background colour. auto const BG = PrevBrush.GetColour(); double const Alpha = (double)Style.GetAlpha() / 255; double const OutlineAlpha = (double)Style.GetOutlineAlpha() / 255; DC.SetPen(wxPen{ wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), OutlineAlpha), wxColour::AlphaBlend(FG.Green(), BG.Green(), OutlineAlpha), wxColour::AlphaBlend(FG.Blue(), BG.Blue(), OutlineAlpha)), Settings.PenWidth}); DC.SetBrush(wxBrush{ wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), Alpha), wxColour::AlphaBlend(FG.Green(), BG.Green(), Alpha), wxColour::AlphaBlend(FG.Blue(), BG.Blue(), Alpha))}); DC.DrawRectangle(X, Y, W, H); break; } DC.SetPen(PrevPen); DC.SetBrush(PrevBrush); }
void wxColourExt::GetCMY(float* c, float* m, float* y) const { if(!WasLastMode(CMY)) { C = 1 - (float)Red()/255; M = 1 - (float)Green()/255; Y = 1 - (float)Blue()/255; } *c = C; *m = M; *y = Y; }
void wxColourExt::GetRGB(float* r, float* g, float* b) const { if(!WasLastMode(RGB)) { R = (float)Red()/255; G = (float)Green()/255; B = (float)Blue()/255; } *r = R; *g = G; *b = B; }
void setProportionalTargetColor(LedGroup* group, int i, float colorIntensity) { float fr = Red(currentColor); float fg = Green(currentColor); float fb = Blue(currentColor); byte r = (fr / 100.) * colorIntensity; byte g = (fg / 100.) * colorIntensity; byte b = (fb / 100.) * colorIntensity; group->targetColors[i] = createColor(r, g, b); }
/** * Returns the highlighted version of this color. */ constexpr Color Highlight() const { #ifdef GREYSCALE return Color((GetLuminosity() + 0xff * 3) / 4); #else return Color((Red() + 0xff * 3) / 4, (Green() + 0xff * 3) / 4, (Blue() + 0xff * 3) / 4); #endif }
void flickerSelectColor(LedGroup* group, int i, int min_, int max_) { float proportion = random(min_, max_); float fr = Red(currentColor); float fg = Green(currentColor); float fb = Blue(currentColor); byte r = fr / proportion; byte g = fg / proportion; byte b = fb / proportion; Color c = group->getColor(i); float cr = Red(c); float cg = Green(c); float cb = Blue(c); group->increment[i][0] = max(abs(cr - fr) / 10, 1); group->increment[i][1] = max(abs(cg - fg) / 10, 1); group->increment[i][2] = max(abs(cb - fb) / 10, 1); group->targetColors[i] = createColor(r,g,b); }
void hideStrategy(LedGroup* group) { group->selectionLen = 10; group->animationDone = false; for(int i=0;i<group->selectionLen; i++) { group->pixelState[i] = 2; byte proportion = random(1, 5); group->increment[i][0] = Red(currentColor) / proportion; group->increment[i][1] = Green(currentColor) / proportion; group->increment[i][2] = Blue(currentColor) / proportion; } }
LKColor LKColor::ChangeBrightness(double fBrightFact) const { #ifdef GREYSCALE int Luminosity = GetLuminosity()*fBrightFact; if (Luminosity > 255) Luminosity = 255; return Color(Luminosity, Alpha()); #else int red = (int) (fBrightFact * (double) Red()); if (red > 255) red = 255; int blue = (int) (fBrightFact * (double) Blue()); if (blue > 255) blue = 255; int green = (int) (fBrightFact * (double) Green()); if (green > 255) green = 255; return LKColor((uint8_t) red, (uint8_t) green, (uint8_t) blue); #endif }
double ON_Color::Saturation() const { // 0.0 to 1.0 0.0 = gray, 1.0 = saturated double s; int r = Red(); int g = Green(); int b = Blue(); int minrgb, maxrgb; if ( r <= g ) {minrgb = r; maxrgb = g;} else {minrgb = g; maxrgb = r;} if (minrgb > b) minrgb = b; else if (maxrgb < b ) maxrgb = b; if ( maxrgb > 0 ) { s = ((double)(maxrgb - minrgb))/((double)maxrgb); } else s = 0.0; return s; }