本文整理汇总了C++中Rect::Center方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::Center方法的具体用法?C++ Rect::Center怎么用?C++ Rect::Center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::Center方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TranslateCoordinates
Point TranslateCoordinates(Point p, Rect world, Rect view) {
Point cw = world.Center();
Point slope = p.Add(cw).Sub(view.Center());
Point scaleFactor = world.ScaleFactorFor(view).Mul(1, -1);
return scaleFactor.Mul(slope).Add(cw);
// return Point(
// sf.x * (p.x + cw.x - cv.x) + cw.x,
// -sf.y * (p.y + cw.y - cv.y) + cw.y
// );
}
示例2: TranslateMoreCoordinates
Point TranslateMoreCoordinates(Point p, Rect world, Rect view) {
Point p1;
Point wd = world.Dimensions();
Point vd = view.Dimensions();
Point cw = world.Center();
Point cv = view.Center();
p1.x = vd.x + (+p.x * vd.x + wd.x * cw.x - wd.x * cv.x + cw.x * vd.x) / wd.x;
p1.y = vd.y + (-p.y * vd.y + wd.y * cw.y - wd.y * cv.y + cw.y * vd.y) / wd.y;
return p1;
}
示例3: IsOnGround
/**
* Returns true if the given box is directly above the ground
*/
bool MovementMap::IsOnGround(const Rect box)
{
// Checks the lower limit
if (!IsZero(box.Center().GetX(), box.GetY()+box.GetH()+1)) return true;
// Checks the lower-right limit
if (!IsZero(box.GetX()+box.GetW(), box.GetY()+box.GetH()+1)) return true;
// Checks the lower-left limit
if (!IsZero(box.GetX(), box.GetY()+box.GetH()+1)) return true;
return false;
}
示例4: IsColliding
/**
* This method uses the new position of the given object,
* its previous position and the map to determine whether
* the object is colliding with the walls
*/
bool MovementMap::IsColliding(const Rect box)
{
// // Checks the center
// if (!IsZero(box.Center().GetX(), box.Center().GetY())) return true;
// Checks the above limit
if (!IsZero(box.GetX()+box.GetW()/2, box.GetY())) return true;
// Checks the right limit
if (!IsZero(box.GetX() + box.GetW(), box.GetY() + box.GetH()/2)) return true;
// Checks the left limit
if (!IsZero(box.GetX(), box.GetY()+box.GetH()/2)) return true;
// Checks the upper-right limit
if (!IsZero(box.GetX()+box.GetW(), box.GetY())) return true;
// Checks the upper-left limit
if (!IsZero(box.GetX(), box.GetY())) return true;
// Checks the lower limit
if (!IsZero(box.Center().GetX(), box.Center().GetY() + box.GetH()/2)) return true;
// Checks the lower-right limit
if (!IsZero(box.GetX()+box.GetW(), box.GetY()+box.GetH())) return true;
// Checks the lower-left limit
if (!IsZero(box.GetX(), box.GetY()+box.GetH())) return true;
return false;
// return IsCollidingWithGround(box);
}
示例5: VideoModeChange
void Window::VideoModeChange( void ) {
Rect pos = *this;
pos.Align( *view );
pos.Clip( *view );
if ( flags & WIN_CENTER ) pos.Center( *view );
if ( (pos.w != w) || (pos.h != h) ) {
SetSize( pos.x, pos.y, pos.w, pos.h );
Draw();
} else {
x = pos.x;
y = pos.y;
}
}
示例6: FillRhombMask
void FillRhombMask(View & mask, const Rect & rect, uint8_t index)
{
assert(mask.format == View::Gray8 && Rect(mask.Size()).Contains(rect));
Simd::Fill(mask, 0);
Point c = rect.Center();
for(ptrdiff_t row = rect.top; row < rect.bottom; ++row)
{
ptrdiff_t indent = std::abs(row - c.y)*rect.Width()/rect.Height();
ptrdiff_t left = rect.left + indent;
ptrdiff_t right = rect.right - indent;
ptrdiff_t offset = row*mask.stride + left;
for(ptrdiff_t col = left; col < right; ++col, ++offset)
mask.data[offset] = Random(2) ? index : 0;
}
}
示例7: ellipse2bezier
// Create points to simulate ellipse using beziers
// senses coordinate translation, generates CW (swap top and bottom for CCW)
void ellipse2bezier(Rect &r, Line &out) {
out.degree = 3;
out.resize(13,Coord());
// MAGICAL CONSTANT to map ellipse to beziers
// 2/3*(sqrt(2)-1)
const double EToBConst = 0.2761423749154,
translation = (r.b>r.t)?-1.0:1.0;
Coord offset(r.Width() * EToBConst, r.Height() * EToBConst);
Coord center(r.Center());
out[0].x = //------------------------/
out[1].x = // /
out[11].x = // 2___3___4 /
out[12].x = r.l; // 1 5 /
out[5].x = // | | /
out[6].x = // | | /
out[7].x = r.r; // 0,12 6 /
out[2].x = // | | /
out[10].x = center.x - offset.x; // | | /
out[4].x = // 11 7 /
out[8].x = center.x + offset.x; // 10___9___8 /
out[3].x = // /
out[9].x = center.x; //------------------------*
out[2].y =
out[3].y =
out[4].y = r.t;
out[8].y =
out[9].y =
out[10].y = r.b;
out[7].y =
out[11].y = center.y - translation*offset.y;
out[1].y =
out[5].y = center.y + translation*offset.y;
out[0].y =
out[12].y =
out[6].y = center.y;
}
示例8: Render
void Render(Context* pcontext)
{
Rect rect = GetViewRect()->GetValue();
pcontext->Translate(rect.Center());
pcontext->Scale2(0.5f * rect.XSize());
pcontext->Begin3DLayer(GetCamera(), false);
#ifndef FixPermedia
pcontext->SetShadeMode(ShadeModeCopy);
#endif
pcontext->SetShadeMode(ShadeModeGlobalColor);
pcontext->SetGlobalColor( Color::White() );
pcontext->SetBlendMode( BlendModeAlphaStampThrough );
TList<PosterData, DefaultNoEquals>::Iterator iter(m_list);
while (!iter.End()) {
PosterData& data = iter.Value();
Point point;
if (pcontext->TransformDirectionToImage(data.m_vec, point)) {
pcontext->SetTexture(data.m_pimage->GetSurface());
pcontext->PushState();
pcontext->Multiply(data.m_mat);
#ifdef FixPermedia
Geo::GetWhiteEmissiveSquare()->Render(pcontext);
#else
Geo::GetSquare()->Render(pcontext);
#endif
pcontext->PopState();
}
iter.Next();
}
pcontext->End3DLayer();
}
示例9: SortCompare
bool MovementMap::SortCompare(Rect i, Rect j)
{
if (i.Center().Distance(previousPos.Center()) < j.Center().Distance(previousPos.Center()))
return true;
return false;
}