void TVolumenob::Update(){ rgb_color color = {128, 128, 128}; rgb_color color2= {100, 100, 100}; rgb_color color3= {150, 150, 150}; SetHighColor( color ); FillEllipse(nbcenter,r+1,r+1,B_SOLID_HIGH); SetHighColor( color2 ); FillArc(nbcenter,r+1,r+1,225,180,B_SOLID_HIGH); SetHighColor( color3 ); FillEllipse(nbcenter,r-3,r-3,B_SOLID_HIGH); SetPenSize(3); StrokeLine(nbcenter,nbpoint,B_SOLID_LOW); SetPenSize(1); }
void GradientsView::DrawLinear(BRect update) { BGradientLinear gradient; rgb_color c; c.red = 255; c.green = 0; c.blue = 0; gradient.AddColor(c, 0); c.red = 0; c.green = 255; c.blue = 0; gradient.AddColor(c, 127); c.red = 0; c.green = 0; c.blue = 255; gradient.AddColor(c, 255); // RoundRect SetHighColor(0, 0, 0); FillRoundRect(BRect(10, 10, 110, 110), 5, 5); gradient.SetStart(BPoint(120, 10)); gradient.SetEnd(BPoint(220, 110)); FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient); // Rect SetHighColor(0, 0, 0); FillRect(BRect(10, 120, 110, 220)); gradient.SetStart(BPoint(120, 120)); gradient.SetEnd(BPoint(220, 220)); FillRect(BRect(120, 120, 220, 220), gradient); // Triangle SetHighColor(0, 0, 0); FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330)); gradient.SetStart(BPoint(60, 230)); gradient.SetEnd(BPoint(60, 330)); FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient); // Ellipse SetHighColor(0, 0, 0); FillEllipse(BPoint(60, 390), 50, 50); gradient.SetStart(BPoint(60, 340)); gradient.SetEnd(BPoint(60, 440)); FillEllipse(BPoint(170, 390), 50, 50, gradient); }
void ColorPreview::Draw(BRect update) { rgb_color color; if (is_enabled) color = currentcol; else color = disabledcol; if (is_rect) { if (is_enabled) { rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color shadow = tint_color(background, B_DARKEN_1_TINT); rgb_color darkShadow = tint_color(background, B_DARKEN_3_TINT); rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT); BRect bounds(Bounds()); BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), shadow); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), shadow); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), light); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), light); EndLineArray(); bounds.InsetBy(1.0, 1.0); BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), darkShadow); AddLine(BPoint(bounds.left + 1.0, bounds.top), BPoint(bounds.right, bounds.top), darkShadow); AddLine(BPoint(bounds.right, bounds.top + 1.0), BPoint(bounds.right, bounds.bottom), background); AddLine(BPoint(bounds.right - 1.0, bounds.bottom), BPoint(bounds.left + 1.0, bounds.bottom), background); EndLineArray(); bounds.InsetBy(1.0, 1.0); SetHighColor(color); FillRect(bounds); } else { SetHighColor(color); FillRect(Bounds()); } } else { // fill background SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); FillRect(update); SetHighColor(color); FillEllipse(Bounds()); if (is_enabled) StrokeEllipse(Bounds(), B_SOLID_LOW); } }
void GradientsView::DrawRadialFocus(BRect update) { BGradientRadialFocus gradient; rgb_color c; c.red = 255; c.green = 0; c.blue = 0; gradient.AddColor(c, 0); c.red = 0; c.green = 255; c.blue = 0; gradient.AddColor(c, 127); c.red = 0; c.green = 0; c.blue = 255; gradient.AddColor(c, 255); // RoundRect SetHighColor(0, 0, 0); FillRoundRect(BRect(10, 10, 110, 110), 5, 5); gradient.SetCenter(BPoint(170, 60)); FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient); // Rect SetHighColor(0, 0, 0); FillRect(BRect(10, 120, 110, 220)); gradient.SetCenter(BPoint(170, 170)); FillRect(BRect(120, 120, 220, 220), gradient); // Triangle SetHighColor(0, 0, 0); FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330)); gradient.SetCenter(BPoint(170, 280)); FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), gradient); // Ellipse SetHighColor(0, 0, 0); FillEllipse(BPoint(60, 390), 50, 50); gradient.SetCenter(BPoint(170, 390)); FillEllipse(BPoint(170, 390), 50, 50, gradient); }
void FillEllipseMask(IplImage* mask, uint8_t setnum, int x, int y, int width, int height) { int x_ = min(x, x + width); int y_ = min(y, y + height); int width_ = abs(width); int height_ = abs(height); int a = width_/2; int b = height_/2; //楕円を描画 FillEllipse(mask, setnum, x_ + width_/2, y_ + height_/2, a*b, b*b, a*a); }
void Activity::Draw(BRect rect) { bigtime_t present = system_time() - 600000; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { BPoint aPoint(i * 60 + 70, j * 60 + 70); SetHighColor(0, 0, 0); StrokeEllipse(aPoint, 5, 5); SetHighColor(0, 255, 0); if (present < fActivity[j * 4 + i]) FillEllipse(aPoint, 4, 4); } }
NS_IMETHODIMP nsThebesRenderingContext::FillEllipse(const nsRect& aRect) { return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height); }
void nsRenderingContext::FillEllipse(const nsRect& aRect) { FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height); }
void BRadioButton::Draw(BRect updateRect) { // its size depends on the text height font_height fontHeight; GetFontHeight(&fontHeight); if (be_control_look != NULL) { rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); uint32 flags = be_control_look->Flags(this); if (fOutlined) flags |= BControlLook::B_CLICKED; BRect knobRect(_KnobFrame(fontHeight)); BRect rect(knobRect); be_control_look->DrawRadioButton(this, rect, updateRect, base, flags); BRect labelRect(Bounds()); labelRect.left = knobRect.right + be_control_look->DefaultLabelSpacing(); be_control_look->DrawLabel(this, Label(), labelRect, updateRect, base, flags); return; } float textHeight = ceilf(fontHeight.ascent + fontHeight.descent); // layout the rect for the dot BRect rect = _KnobFrame(fontHeight); BPoint labelPos(rect.right + floorf(textHeight / 2.0), floorf((rect.top + rect.bottom + textHeight) / 2.0 - fontHeight.descent + 0.5) + 1.0); // if the focus is changing, just redraw the focus indicator if (IsFocusChanging()) { if (IsFocus()) SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); else SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BPoint underLine = labelPos; underLine.y += fontHeight.descent; StrokeLine(underLine, underLine + BPoint(StringWidth(Label()), 0.0)); return; } // colors rgb_color bg = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lightenmax; rgb_color lighten1; rgb_color darken1; rgb_color darken2; rgb_color darken3; rgb_color darkenmax; rgb_color naviColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); rgb_color knob; rgb_color knobDark; rgb_color knobLight; if (IsEnabled()) { lightenmax = tint_color(bg, B_LIGHTEN_MAX_TINT); lighten1 = tint_color(bg, B_LIGHTEN_1_TINT); darken1 = tint_color(bg, B_DARKEN_1_TINT); darken2 = tint_color(bg, B_DARKEN_2_TINT); darken3 = tint_color(bg, B_DARKEN_3_TINT); darkenmax = tint_color(bg, B_DARKEN_MAX_TINT); knob = naviColor; knobDark = tint_color(naviColor, B_DARKEN_3_TINT); knobLight = tint_color(naviColor, 0.15); } else { lightenmax = tint_color(bg, B_LIGHTEN_2_TINT); lighten1 = bg; darken1 = bg; darken2 = tint_color(bg, B_DARKEN_1_TINT); darken3 = tint_color(bg, B_DARKEN_2_TINT); darkenmax = tint_color(bg, B_DISABLED_LABEL_TINT); knob = tint_color(naviColor, B_LIGHTEN_2_TINT); knobDark = tint_color(naviColor, B_LIGHTEN_1_TINT); knobLight = tint_color(naviColor, (B_LIGHTEN_2_TINT + B_LIGHTEN_MAX_TINT) / 2.0); } // dot if (Value() == B_CONTROL_ON) { // full SetHighColor(knobDark); FillEllipse(rect); SetHighColor(knob); FillEllipse(BRect(rect.left + 2, rect.top + 2, rect.right - 3, rect.bottom - 3)); SetHighColor(knobLight); FillEllipse(BRect(rect.left + 3, rect.top + 3, rect.right - 5, rect.bottom - 5)); } else { // empty SetHighColor(lightenmax); FillEllipse(rect); } rect.InsetBy(-1.0, -1.0); // outer circle if (fOutlined) { // indicating "about to change value" SetHighColor(darken3); StrokeEllipse(rect); } else { SetHighColor(darken1); StrokeArc(rect, 45.0, 180.0); SetHighColor(lightenmax); StrokeArc(rect, 45.0, -180.0); } rect.InsetBy(1, 1); // inner circle SetHighColor(darken3); StrokeArc(rect, 45.0, 180.0); SetHighColor(bg); StrokeArc(rect, 45.0, -180.0); // for faster font rendering, we can restore B_OP_COPY SetDrawingMode(B_OP_COPY); // label SetHighColor(darkenmax); DrawString(Label(), labelPos); // underline label if focused if (IsFocus()) { SetHighColor(naviColor); BPoint underLine = labelPos; underLine.y += fontHeight.descent; StrokeLine(underLine, underLine + BPoint(StringWidth(Label()), 0.0)); } }
void VolumeSlider::DrawThumb() { #if ROUND_KNOB // Draw a round thumb BRect rect(ThumbFrame()); rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color frameLightColor; rgb_color frameShadowColor; rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 }; float topTint = 0.49; float middleTint1 = 0.62; float middleTint2 = 0.76; float bottomTint = 0.90; if (!IsEnabled()) { topTint = (topTint + B_NO_TINT) / 2; middleTint1 = (middleTint1 + B_NO_TINT) / 2; middleTint2 = (middleTint2 + B_NO_TINT) / 2; bottomTint = (bottomTint + B_NO_TINT) / 2; shadowColor = (rgb_color){ 0, 0, 0, 30 }; } // Draw shadow #if !KNOB_EMBEDDED rect.left++; rect.top++; SetDrawingMode(B_OP_ALPHA); SetHighColor(shadowColor); FillEllipse(rect); // Draw thumb shape rect.OffsetBy(-1, -1); #endif if (IsFocus()) { // focused frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); frameShadowColor = frameLightColor; } else { // figure out the tints to be used float frameLightTint; float frameShadowTint; if (!IsEnabled()) { frameLightTint = 1.30; frameShadowTint = 1.35; shadowColor.alpha = 30; } else { frameLightTint = 1.6; frameShadowTint = 1.65; } frameLightColor = tint_color(base, frameLightTint); frameShadowColor = tint_color(base, frameShadowTint); } BGradientLinear frameGradient; frameGradient.AddColor(frameShadowColor, 0); frameGradient.AddColor(frameLightColor, 255); frameGradient.SetStart(rect.LeftTop()); frameGradient.SetEnd(rect.RightBottom()); FillEllipse(rect, frameGradient); rect.InsetBy(1, 1); // frameGradient.MakeEmpty(); // frameGradient.AddColor(borderColor, 0); // frameGradient.AddColor(tint_color(borderColor, 0.8), 255); // view->FillEllipse(rect, frameGradient); // rect.InsetBy(1, 1); BGradientLinear gradient; if (!IsEnabled()) { gradient.AddColor(tint_color(base, topTint), 0); gradient.AddColor(tint_color(base, bottomTint), 255); } else { gradient.AddColor(tint_color(base, topTint), 0); gradient.AddColor(tint_color(base, middleTint1), 132); gradient.AddColor(tint_color(base, middleTint2), 136); gradient.AddColor(tint_color(base, bottomTint), 255); } gradient.SetStart(rect.LeftTop()); gradient.SetEnd(rect.LeftBottom()); FillEllipse(rect, gradient); #else BSlider::DrawThumb(); #endif }
void ACanvasSkia::FillEllipse(int x1,int y1,int x2,int y2) { FillEllipse(ARect(x1,y1,x2,y2)); }
float PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan, float beginAngle, int colorIdx, int level) { if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize + kPieOuterMargin + kPieInnerMargin)) { return 0.0; } if (info != NULL && info->color >= 0 && level == 0) colorIdx = info->color % kBasePieColorCount; else if (info != NULL) info->color = colorIdx; VolumeSnapshot* snapshot = fScanner->Snapshot(); float cx = floorf(b.left + b.Width() / 2.0 + 0.5); float cy = floorf(b.top + b.Height() / 2.0 + 0.5); float mySpan; if (level == 0) { // Make room for mouse over info. fMouseOverInfo.clear(); fMouseOverInfo[0] = SegmentList(); // Draw the center circle. const char* displayName; if (info == NULL) { // NULL represents the entire volume. Show used and free space in // the center circle, with the used segment representing the // volume's root directory. off_t volCapacity = snapshot->capacity; mySpan = 360.0 * (volCapacity - snapshot->freeBytes) / volCapacity; SetHighColor(kEmptySpcColor); FillEllipse(BPoint(cx, cy), kPieCenterSize, kPieCenterSize); SetHighColor(kBasePieColor[0]); FillArc(BPoint(cx, cy), kPieCenterSize, kPieCenterSize, 0.0, mySpan); // Show total volume capacity. char label[B_PATH_NAME_LENGTH]; size_to_string(volCapacity, label, sizeof(label)); SetHighColor(kPieBGColor); SetDrawingMode(B_OP_OVER); DrawString(label, BPoint(cx - StringWidth(label) / 2.0, cy + fFontHeight + kSmallVMargin)); SetDrawingMode(B_OP_COPY); displayName = snapshot->name.c_str(); // Record in-use space and free space for use during MouseMoved(). info = snapshot->rootDir; info->color = colorIdx; fMouseOverInfo[0].push_back(Segment(0.0, mySpan, info)); if (mySpan < 360.0 - kMinSegmentSpan) { fMouseOverInfo[0].push_back(Segment(mySpan, 360.0, snapshot->freeSpace)); } } else { // Show a normal directory. SetHighColor(kBasePieColor[colorIdx]); FillEllipse(BRect(cx - kPieCenterSize, cy - kPieCenterSize, cx + kPieCenterSize + 0.5, cy + kPieCenterSize + 0.5)); displayName = info->ref.name; mySpan = 360.0; // Record the segment for use during MouseMoved(). fMouseOverInfo[0].push_back(Segment(0.0, mySpan, info)); } SetPenSize(1.0); SetHighColor(kOutlineColor); StrokeEllipse(BPoint(cx, cy), kPieCenterSize + 0.5, kPieCenterSize + 0.5); // Show the name of the volume or directory. BString label(displayName); BFont font; GetFont(&font); font.TruncateString(&label, B_TRUNCATE_END, 2.0 * (kPieCenterSize - kSmallHMargin)); float labelWidth = font.StringWidth(label.String()); SetHighColor(kPieBGColor); SetDrawingMode(B_OP_OVER); DrawString(label.String(), BPoint(cx - labelWidth / 2.0, cy)); SetDrawingMode(B_OP_COPY); beginAngle = 0.0; } else { // Draw an exterior segment. float parentSize; if (info->parent == NULL) parentSize = (float)snapshot->capacity; else parentSize = (float)info->parent->size; mySpan = parentSpan * (float)info->size / parentSize; if (mySpan >= kMinSegmentSpan) { const float tint = 1.4f - level * 0.08f; float radius = kPieCenterSize + level * kPieRingSize - kPieRingSize / 2.0; // Draw the grey border SetHighColor(tint_color(kOutlineColor, tint)); SetPenSize(kPieRingSize + 1.5f); StrokeArc(BPoint(cx, cy), radius, radius, beginAngle - 0.001f * radius, mySpan + 0.002f * radius); // Draw the colored area rgb_color color = tint_color(kBasePieColor[colorIdx], tint); SetHighColor(color); SetPenSize(kPieRingSize); StrokeArc(BPoint(cx, cy), radius, radius, beginAngle, mySpan); // Record the segment for use during MouseMoved(). if (fMouseOverInfo.find(level) == fMouseOverInfo.end()) fMouseOverInfo[level] = SegmentList(); fMouseOverInfo[level].push_back( Segment(beginAngle, beginAngle + mySpan, info)); } } // Draw children. vector<FileInfo*>::iterator i = info->children.begin(); while (i != info->children.end()) { float childSpan = _DrawDirectory(b, *i, mySpan, beginAngle, colorIdx, level + 1); if (childSpan >= kMinSegmentSpan) { beginAngle += childSpan; colorIdx = (colorIdx + 1) % kBasePieColorCount; } i++; } return mySpan; }
void BRadioButton::Draw(BRect updateRect) { if (Window() == NULL) return; BFont font; GetFont(&font); font_height fontHeight; font.GetHeight(&fontHeight); float sHeight = fontHeight.ascent + fontHeight.descent; BRect rect = Frame().OffsetToSelf(B_ORIGIN); rect.InsetBy(5, (rect.Height() - sHeight) / 2); if (rect.IsValid() == false) return; if ((IsFocus() || IsFocusChanging()) && IsEnabled() && Label() != NULL) { BPoint penLocation; penLocation.Set(rect.left + rect.Height() + 5, rect.Center().y + sHeight / 2 + 1); SetHighColor((IsFocus() && Window()->IsActivate()) ? ui_color(B_NAVIGATION_BASE_COLOR) : ViewColor()); StrokeLine(penLocation, penLocation + BPoint(font.StringWidth(Label()), 0)); } if (IsFocusChanging()) return; rgb_color shineColor = ui_color(B_SHINE_COLOR); rgb_color shadowColor = ui_color(B_SHADOW_COLOR); if (!IsEnabled()) { shineColor.disable(ViewColor()); shadowColor.disable(ViewColor()); } rect.right = rect.left + rect.Height(); SetHighColor(shineColor.mix_copy(0, 0, 0, 5)); FillEllipse(rect); SetHighColor(shineColor); StrokeArc(rect, 225, 180); SetHighColor(shadowColor); StrokeArc(rect, 45, 180); if (Value() == B_CONTROL_ON) { SetHighColor(shadowColor.mix_copy(255, 255, 255, 50)); BRect r = rect.InsetByCopy(3, 3); FillEllipse(r); } if (Label() != NULL) { BPoint penLocation; penLocation.x = rect.right + 5; penLocation.y = rect.Center().y - sHeight / 2.f; penLocation.y += fontHeight.ascent + 1; SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor())); SetLowColor(ViewColor()); DrawString(Label(), penLocation); if (!IsEnabled()) { SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor())); DrawString(Label(), penLocation - BPoint(1, 1)); } } }