本文整理汇总了C++中RectanglePlacement::applyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ RectanglePlacement::applyTo方法的具体用法?C++ RectanglePlacement::applyTo怎么用?C++ RectanglePlacement::applyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RectanglePlacement
的用法示例。
在下文中一共展示了RectanglePlacement::applyTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawImageWithin
void Graphics::drawImageWithin (const Image& imageToDraw,
const int destX, const int destY,
const int destW, const int destH,
const RectanglePlacement& placementWithinTarget,
const bool fillAlphaChannelWithCurrentBrush) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (destX, destY, destW, destH));
if (imageToDraw.isValid())
{
const int imageW = imageToDraw.getWidth();
const int imageH = imageToDraw.getHeight();
if (imageW > 0 && imageH > 0)
{
double newX = 0.0, newY = 0.0;
double newW = imageW;
double newH = imageH;
placementWithinTarget.applyTo (newX, newY, newW, newH,
destX, destY, destW, destH);
if (newW > 0 && newH > 0)
{
drawImage (imageToDraw,
roundToInt (newX), roundToInt (newY),
roundToInt (newW), roundToInt (newH),
0, 0, imageW, imageH,
fillAlphaChannelWithCurrentBrush);
}
}
}
}
示例2: setBoundsWithCorrectAspectRatio
void QuickTimeMovieComponent::setBoundsWithCorrectAspectRatio (const Rectangle& spaceToFitWithin,
const RectanglePlacement& placement)
{
int normalWidth, normalHeight;
getMovieNormalSize (normalWidth, normalHeight);
if (normalWidth > 0 && normalHeight > 0 && ! spaceToFitWithin.isEmpty())
{
double x = 0.0, y = 0.0, w = normalWidth, h = normalHeight;
placement.applyTo (x, y, w, h,
spaceToFitWithin.getX(), spaceToFitWithin.getY(),
spaceToFitWithin.getWidth(), spaceToFitWithin.getHeight());
if (w > 0 && h > 0)
{
setBounds (roundToInt (x), roundToInt (y),
roundToInt (w), roundToInt (h));
}
}
else
{
setBounds (spaceToFitWithin);
}
}
示例3: drawCurrentImage
void drawCurrentImage (Graphics& g, int x, int y, int w, int h)
{
if (imageNeedsFlipping)
{
const ScopedLock sl (imageSwapLock);
std::swap (loadingImage, activeImage);
imageNeedsFlipping = false;
}
RectanglePlacement rp (RectanglePlacement::centred);
double dx = 0, dy = 0, dw = width, dh = height;
rp.applyTo (dx, dy, dw, dh, x, y, w, h);
const int rx = roundToInt (dx), ry = roundToInt (dy);
const int rw = roundToInt (dw), rh = roundToInt (dh);
{
Graphics::ScopedSaveState ss (g);
g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh));
g.fillAll (Colours::black);
}
g.drawImage (activeImage, rx, ry, rw, rh, 0, 0, width, height);
}