本文整理汇总了C++中BShape::MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BShape::MoveTo方法的具体用法?C++ BShape::MoveTo怎么用?C++ BShape::MoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BShape
的用法示例。
在下文中一共展示了BShape::MoveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BShape
BShape*
TransportControlGroup::_CreateSkipForwardShape(float height) const
{
BShape* shape = new BShape();
shape->MoveTo(BPoint(height, height / 2));
shape->LineTo(BPoint(0, height));
shape->LineTo(BPoint(0, 0));
shape->Close();
shape->MoveTo(BPoint(height * 2, height / 2));
shape->LineTo(BPoint(height, height));
shape->LineTo(BPoint(height, 0));
shape->Close();
float stopWidth = ceilf(height / 6);
shape->MoveTo(BPoint(height * 2, height));
shape->LineTo(BPoint(height * 2 + stopWidth, height));
shape->LineTo(BPoint(height * 2 + stopWidth, 0));
shape->LineTo(BPoint(height * 2, 0));
shape->Close();
return shape;
}
示例2: BPoint
void
MouseView::_CreateButtonsPicture()
{
BeginPicture(&fButtonsPicture);
SetScale(1.8 * fScaling);
SetOrigin(-21 * fScaling, -14 * fScaling);
BShape mouseShape;
mouseShape.MoveTo(BPoint(48, 12));
// top
BPoint control3[3] = { BPoint(44, 8), BPoint(20, 8), BPoint(16, 12) };
mouseShape.BezierTo(control3);
// left
BPoint control[3] = { BPoint(12, 16), BPoint(13, 27), BPoint(13, 27) };
mouseShape.BezierTo(control);
// bottom
BPoint control4[] = { BPoint(18, 30), BPoint(46, 30), BPoint(51, 27) };
mouseShape.BezierTo(control4);
// right
BPoint control2[3] = { BPoint(51, 27), BPoint(50, 14), BPoint(48, 12) };
mouseShape.BezierTo(control2);
mouseShape.Close();
SetHighColor(255, 0, 0, 255);
FillShape(&mouseShape, B_SOLID_HIGH);
EndPicture();
SetScale(1);
}
示例3: r
void
PDFWriter::ClipChar(BFont* font, const char* unicode, const char* utf8,
int16 size, float width)
{
BShape glyph;
bool hasGlyph[1];
font->GetHasGlyphs(utf8, 1, hasGlyph);
if (hasGlyph[0]) {
BShape *glyphs[1];
glyphs[0] = &glyph;
font->GetGlyphShapes(utf8, 1, glyphs);
} else {
REPORT(kWarning, fPage, "glyph for %*.*s not found!", size, size, utf8);
// create a rectangle instead
font_height height;
fState->beFont.GetHeight(&height);
BRect r(0, 0, width, height.ascent);
float w = r.Width() < r.Height() ? r.Width()*0.1 : r.Height()*0.1;
BRect o = r; o.InsetBy(w, w);
w *= 2.0;
BRect i = r; i.InsetBy(w, w);
o.OffsetBy(0, -height.ascent);
i.OffsetBy(0, -height.ascent);
glyph.MoveTo(BPoint(o.left, o.top));
glyph.LineTo(BPoint(o.right, o.top));
glyph.LineTo(BPoint(o.right, o.bottom));
glyph.LineTo(BPoint(o.left, o.bottom));
glyph.Close();
glyph.MoveTo(BPoint(i.left, i.top));
glyph.LineTo(BPoint(i.left, i.bottom));
glyph.LineTo(BPoint(i.right, i.bottom));
glyph.LineTo(BPoint(i.right, i.top));
glyph.Close();
}
BPoint p(fState->penX, fState->penY);
PushInternalState(); SetOrigin(p);
{
DrawShape iterator(this, false);
iterator.Iterate(&glyph);
}
PopInternalState();
}
示例4: testStrokeShape
static void testStrokeShape(BView *view, BRect frame)
{
frame.InsetBy(2, 2);
BShape shape;
shape.MoveTo(BPoint(frame.left, frame.bottom));
shape.LineTo(BPoint(frame.right, frame.top));
shape.LineTo(BPoint(frame.left, frame.top));
shape.LineTo(BPoint(frame.right, frame.bottom));
view->StrokeShape(&shape);
}
示例5:
void
LineChartRenderer::Render(BView* view, BRect updateRect)
{
if (!updateRect.IsValid() || updateRect.left > fFrame.right
|| fFrame.left > updateRect.right) {
return;
}
if (fDomain.min >= fDomain.max || fRange.min >= fRange.max)
return;
if (!_UpdateSamples())
return;
// get the range to draw (draw one more sample on each side)
int32 left = (int32)fFrame.left;
int32 first = (int32)updateRect.left - left - 1;
int32 last = (int32)updateRect.right - left + 1;
if (first < 0)
first = 0;
if (last > fFrame.IntegerWidth())
last = fFrame.IntegerWidth();
if (first > last)
return;
double minRange = fRange.min;
double sampleRange = fRange.max - minRange;
if (sampleRange == 0) {
minRange = fRange.min - 0.5;
sampleRange = 1;
}
double scale = (double)fFrame.IntegerHeight() / sampleRange;
// draw
view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
for (int32 i = 0; DataSourceInfo* info = fDataSources.ItemAt(i); i++) {
float bottom = fFrame.bottom;
BShape shape;
shape.MoveTo(BPoint(left + first,
bottom - ((info->samples[first] - minRange) * scale)));
for (int32 i = first; i <= last; i++) {
shape.LineTo(BPoint(float(left + i),
float(bottom - ((info->samples[i] - minRange) * scale))));
}
view->SetHighColor(info->config.Color());
view->MovePenTo(B_ORIGIN);
view->StrokeShape(&shape);
}
}
示例6: BPoint
static void
DrawStuff(BView *view)
{
// StrokeShape
BShape shape;
BPoint bezier[3] = {BPoint(100,0), BPoint(100, 100), BPoint(25, 50)};
shape.MoveTo(BPoint(150,0));
shape.LineTo(BPoint(200,100));
shape.BezierTo(bezier);
shape.Close();
view->StrokeShape(&shape);
// Stroke/FillRect, Push/PopState, SetHighColor, SetLineMode, SetPenSize
view->PushState();
const rgb_color blue = { 0, 0, 240, 0 };
view->SetHighColor(blue);
view->SetLineMode(B_BUTT_CAP, B_BEVEL_JOIN);
view->SetPenSize(7);
view->StrokeRect(BRect(10, 220, 50, 260));
view->FillRect(BRect(65, 245, 120, 300));
view->PopState();
// Stroke/FillEllipse
view->StrokeEllipse(BPoint(50, 150), 50, 50);
view->FillEllipse(BPoint(100, 120), 50, 50);
// Stroke/FillArc
view->StrokeArc(BRect(0, 200, 50, 250), 180, 180);
view->FillArc(BPoint(150, 250), 50, 50, 0, 125);
// DrawString, SetHighColor, SetFontSize
const rgb_color red = { 240, 0, 0, 0 };
view->SetHighColor(red);
view->SetFontSize(20);
view->DrawString("BPicture ", BPoint(30, 20));
view->DrawString("test");
// DrawLine with pen position
const rgb_color purple = { 200, 0, 220, 0 };
view->SetHighColor(purple);
view->StrokeLine(BPoint(50, 30), BPoint(30, 50));
view->StrokeLine(BPoint(80, 50));
view->StrokeLine(BPoint(50, 30));
}
示例7: gradient
void
Leaves::Draw(BView* view, int32 frame)
{
float scale = fLeafSize / kLeafWidth / (kMaximumLeafSize * 2);
scale *= view->Bounds().Width();
scale += scale * drand48() * fSizeVariation / 100.;
BAffineTransform transform;
transform.TranslateBy(-kLeafWidth / 2, -kLeafHeight / 2);
// draw the leaf centered on the point
transform.RotateBy(drand48() * 2. * M_PI);
if ((rand() & 64) == 0) transform.ScaleBy(-1., 1.);
// flip half of the time
transform.ScaleBy(scale);
transform.TranslateBy(_RandomPoint(view->Bounds()));
BPoint center = transform.Apply(BPoint(kLeafWidth / 2, kLeafHeight / 2));
BPoint gradientOffset = BPoint(60 * scale, 80 * scale);
BGradientLinear gradient(center - gradientOffset, center + gradientOffset);
int color = (rand() / 7) % kColorCount;
gradient.AddColor(kColors[color][0], 0.f);
gradient.AddColor(kColors[color][1], 255.f);
BShape leafShape;
leafShape.MoveTo(transform.Apply(kLeafBegin));
for (int i = 0; i < kLeafCurveCount; ++i) {
BPoint control[3];
for (int j = 0; j < 3; ++j)
control[j] = transform.Apply(kLeafCurves[i][j]);
leafShape.BezierTo(control);
}
leafShape.Close();
view->PushState();
view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 50);
for (int i = 2; i >= 0; --i) {
view->SetOrigin(i * 0.1, i * 0.3);
view->SetPenSize(i * 2);
view->StrokeShape(&leafShape);
}
view->PopState();
view->FillShape(&leafShape, gradient);
}
示例8: gradient
void
LeafView::Draw(BRect updateRect)
{
float scale = Bounds().Width() / kLeafWidth;
BAffineTransform transform;
transform.ScaleBy(scale);
// BGradientRadial gradient(BPoint(kLeafWidth * 0.75, kLeafHeight * 1.5),
// kLeafWidth * 2);
BGradientLinear gradient(B_ORIGIN,
transform.Apply(BPoint(kLeafWidth, kLeafHeight)));
rgb_color lightBlue = make_color(6, 169, 255);
rgb_color darkBlue = make_color(0, 50, 126);
gradient.AddColor(darkBlue, 0.0);
gradient.AddColor(lightBlue, 255.0);
// build leaf shape
BShape leafShape;
leafShape.MoveTo(transform.Apply(kLeafBegin));
for (int i = 0; i < kNumLeafCurves; ++i) {
BPoint controlPoints[3];
for (int j = 0; j < 3; ++j)
controlPoints[j] = transform.Apply(kLeafCurves[i][j]);
leafShape.BezierTo(controlPoints);
}
leafShape.Close();
PushState();
SetDrawingMode(B_OP_ALPHA);
SetHighColor(0, 0, 0, 50);
for (int i = 2; i >= 0; --i) {
SetOrigin(i * 0.1, i * 0.3);
SetPenSize(i * 2);
StrokeShape(&leafShape);
}
PopState();
FillShape(&leafShape, gradient);
}
示例9: r
void
BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor)
{
fSuper->PushState();
BRect r(fBounds);
float rightMargin;
MenuPrivate(fSuper).GetItemMargins(NULL, NULL, &rightMargin, NULL);
r.left = r.right - rightMargin + 3;
r.right -= 1;
BPoint center(floorf((r.left + r.right) / 2.0),
floorf((r.top + r.bottom) / 2.0));
float size = min_c(r.Height() - 2, r.Width());
r.top = floorf(center.y - size / 2 + 0.5);
r.bottom = floorf(center.y + size / 2 + 0.5);
r.left = floorf(center.x - size / 2 + 0.5);
r.right = floorf(center.x + size / 2 + 0.5);
BShape arrowShape;
center.x += 0.5;
center.y += 0.5;
size *= 0.25;
float hSize = size * 0.7;
arrowShape.MoveTo(BPoint(center.x - hSize, center.y - size));
arrowShape.LineTo(BPoint(center.x + hSize, center.y));
arrowShape.LineTo(BPoint(center.x - hSize, center.y + size));
fSuper->SetDrawingMode(B_OP_OVER);
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
fSuper->SetPenSize(ceilf(size * 0.4));
// NOTE: StrokeShape() offsets the shape by the current pen position,
// it is not documented in the BeBook, but it is true!
fSuper->MovePenTo(B_ORIGIN);
fSuper->StrokeShape(&arrowShape);
fSuper->PopState();
}
示例10: Draw
void PathView::Draw(BRect updateRect) {
if (fMode == kDrawOutline) {
} else if (fMode == kStroke) {
const int n = fPath.CountPoints();
BShape shape;
for (int i = 0; i < n; i++) {
if (i == 0)
shape.MoveTo(fPath.PointAt(i));
else
shape.LineTo(fPath.PointAt(i));
}
if (fPath.IsClosed()) shape.Close();
SetPenSize(fWidth);
StrokeShape(&shape);
ShapeLPB path(&fPath, fWidth, LineCapMode(), LineJoinMode(), LineMiterLimit());
path.CreateLinePath();
SetPenSize(1);
BPicture picture;
BeginPicture(&picture);
FillShape(path.Shape());
EndPicture();
PushState();
ClipToPicture(&picture);
SetHighColor(0, 255, 0);
FillRect(Bounds());
PopState();
SetOrigin(200, 0);
SetHighColor(255, 0, 0);
StrokeShape(path.Shape());
Flush();
}
}
示例11: truncatedString
void
PlaylistListView::Item::Draw(BView* owner, BRect frame, const font_height& fh,
bool tintedLine, uint32 mode, bool active, uint32 playbackState)
{
rgb_color color = (rgb_color){ 255, 255, 255, 255 };
if (tintedLine)
color = tint_color(color, 1.04);
// background
if (IsSelected())
color = tint_color(color, B_DARKEN_2_TINT);
owner->SetLowColor(color);
owner->FillRect(frame, B_SOLID_LOW);
// label
rgb_color black = (rgb_color){ 0, 0, 0, 255 };
owner->SetHighColor(black);
const char* text = Text();
switch (mode) {
case DISPLAY_NAME:
// TODO
break;
case DISPLAY_PATH:
// TODO
break;
default:
break;
}
float playbackMarkSize = playback_mark_size(fh);
float textOffset = text_offset(fh);
BString truncatedString(text);
owner->TruncateString(&truncatedString, B_TRUNCATE_MIDDLE,
frame.Width() - playbackMarkSize - textOffset);
owner->DrawString(truncatedString.String(),
BPoint(frame.left + playbackMarkSize + textOffset,
floorf(frame.top + frame.bottom + fh.ascent) / 2 - 1));
// playmark
if (active) {
rgb_color green = (rgb_color){ 0, 255, 0, 255 };
if (playbackState != PLAYBACK_STATE_PLAYING)
green = tint_color(color, B_DARKEN_1_TINT);
BRect r(0, 0, playbackMarkSize, playbackMarkSize);
r.OffsetTo(frame.left + 4,
ceilf((frame.top + frame.bottom - playbackMarkSize) / 2));
uint32 flags = owner->Flags();
owner->SetFlags(flags | B_SUBPIXEL_PRECISE);
BShape shape;
shape.MoveTo(r.LeftTop());
shape.LineTo(r.LeftBottom());
shape.LineTo(BPoint(r.right, (r.top + r.bottom) / 2));
shape.Close();
owner->MovePenTo(B_ORIGIN);
owner->FillShape(&shape);
shape.Clear();
r.InsetBy(1, 1);
shape.MoveTo(r.LeftTop());
shape.LineTo(r.LeftBottom());
shape.LineTo(BPoint(r.right, (r.top + r.bottom) / 2));
shape.Close();
BGradientLinear gradient;
gradient.SetStart(r.LeftTop());
gradient.SetEnd(r.LeftBottom());
gradient.AddColor(tint_color(green, B_LIGHTEN_1_TINT), 0);
gradient.AddColor(tint_color(green, B_DARKEN_1_TINT), 255.0);
owner->FillShape(&shape, gradient);
owner->SetFlags(flags);
}
}
示例12: lt
void
TextDocumentView::_GetSelectionShape(BShape& shape, int32 start, int32 end)
{
float startX1;
float startY1;
float startX2;
float startY2;
fTextDocumentLayout.GetTextBounds(start, startX1, startY1, startX2,
startY2);
startX1 = floorf(startX1);
startY1 = floorf(startY1);
startX2 = ceilf(startX2);
startY2 = ceilf(startY2);
float endX1;
float endY1;
float endX2;
float endY2;
fTextDocumentLayout.GetTextBounds(end, endX1, endY1, endX2, endY2);
endX1 = floorf(endX1);
endY1 = floorf(endY1);
endX2 = ceilf(endX2);
endY2 = ceilf(endY2);
int32 startLineIndex = fTextDocumentLayout.LineIndexForOffset(start);
int32 endLineIndex = fTextDocumentLayout.LineIndexForOffset(end);
if (startLineIndex == endLineIndex) {
// Selection on one line
BPoint lt(startX1, startY1);
BPoint rt(endX1, endY1);
BPoint rb(endX1, endY2);
BPoint lb(startX1, startY2);
shape.MoveTo(lt);
shape.LineTo(rt);
shape.LineTo(rb);
shape.LineTo(lb);
shape.Close();
} else if (startLineIndex == endLineIndex - 1 && endX1 <= startX1) {
// Selection on two lines, with gap:
// ---------
// ------###
// ##-------
// ---------
float width = ceilf(fTextDocumentLayout.Width());
BPoint lt(startX1, startY1);
BPoint rt(width, startY1);
BPoint rb(width, startY2);
BPoint lb(startX1, startY2);
shape.MoveTo(lt);
shape.LineTo(rt);
shape.LineTo(rb);
shape.LineTo(lb);
shape.Close();
lt = BPoint(0, endY1);
rt = BPoint(endX1, endY1);
rb = BPoint(endX1, endY2);
lb = BPoint(0, endY2);
shape.MoveTo(lt);
shape.LineTo(rt);
shape.LineTo(rb);
shape.LineTo(lb);
shape.Close();
} else {
// Selection over multiple lines
float width = ceilf(fTextDocumentLayout.Width());
shape.MoveTo(BPoint(startX1, startY1));
shape.LineTo(BPoint(width, startY1));
shape.LineTo(BPoint(width, endY1));
shape.LineTo(BPoint(endX1, endY1));
shape.LineTo(BPoint(endX1, endY2));
shape.LineTo(BPoint(0, endY2));
shape.LineTo(BPoint(0, startY2));
shape.LineTo(BPoint(startX1, startY2));
shape.Close();
}
}
示例13: BPoint
point.y += fOffsetY;
return B_OK;
}
private:
float fOffsetX;
float fOffsetY;
} translator;
MovePenTo(B_ORIGIN);
const float arcRX = 50;
const float arcRY = 80;
BShape shape;
shape.MoveTo(BPoint(20, 10));
shape.LineTo(BPoint(10, 90));
shape.LineTo(BPoint(90, 100));
shape.ArcTo(arcRX, arcRY, 45, true, true, BPoint(100, 20));
shape.Close();
StrokeShape(&shape);
shape.Clear();
shape.MoveTo(BPoint(20, 10));
shape.LineTo(BPoint(10, 90));
shape.LineTo(BPoint(90, 100));
shape.ArcTo(arcRX, arcRY, 45, false, true, BPoint(100, 20));
shape.Close();
translator.SetOffset(10, 10);
示例14: _
void
ActivityView::_DrawHistory(bool drawBackground)
{
_UpdateOffscreenBitmap();
BView* view = this;
if (fOffscreen != NULL) {
fOffscreen->Lock();
view = _OffscreenView();
}
BRect frame = _HistoryFrame();
BRect outerFrame = frame.InsetByCopy(-2, -2);
// draw the outer frame
uint32 flags = 0;
if (!drawBackground)
flags |= BControlLook::B_BLEND_FRAME;
be_control_look->DrawTextControlBorder(this, outerFrame,
outerFrame, fLegendBackgroundColor, flags);
// convert to offscreen view if necessary
if (view != this)
frame.OffsetTo(B_ORIGIN);
view->SetLowColor(fHistoryBackgroundColor);
view->FillRect(frame, B_SOLID_LOW);
uint32 step = 2;
uint32 resolution = fDrawResolution;
if (fDrawResolution > 1) {
step = 1;
resolution--;
}
uint32 width = frame.IntegerWidth() - 10;
uint32 steps = width / step;
bigtime_t timeStep = RefreshInterval() * resolution;
bigtime_t now = system_time();
// Draw scale
// TODO: add second markers?
view->SetPenSize(1);
rgb_color scaleColor = view->LowColor();
uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
if (average < 96)
scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
else
scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);
view->SetHighColor(scaleColor);
view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
BPoint(frame.right, frame.top + frame.Height() / 2));
// Draw values
view->SetPenSize(1.5);
BAutolock _(fSourcesLock);
for (uint32 i = fSources.CountItems(); i-- > 0;) {
ViewHistory* viewValues = fViewValues.ItemAt(i);
DataSource* source = fSources.ItemAt(i);
DataHistory* values = fValues.ItemAt(i);
viewValues->Update(values, steps, fDrawResolution, now, timeStep,
RefreshInterval());
uint32 x = viewValues->Start() * step;
BShape shape;
bool first = true;
for (uint32 i = viewValues->Start(); i < steps; x += step, i++) {
float y = _PositionForValue(source, values,
viewValues->ValueAt(i));
if (first) {
shape.MoveTo(BPoint(x, y));
first = false;
} else
shape.LineTo(BPoint(x, y));
}
view->SetHighColor(source->Color());
view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
view->MovePenTo(B_ORIGIN);
view->StrokeShape(&shape);
}
// TODO: add marks when an app started or quit
view->Sync();
if (fOffscreen != NULL) {
fOffscreen->Unlock();
DrawBitmap(fOffscreen, outerFrame.LeftTop());
}
}
示例15: MoveTo
void ShapeLPB::MoveTo(BPoint p)
{
fShape.MoveTo(p);
}