本文整理汇总了C++中gfx::Rect类的典型用法代码示例。如果您正苦于以下问题:C++ Rect类的具体用法?C++ Rect怎么用?C++ Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rectgrid
static void rectgrid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile)
{
if (tile.w < 1 || tile.h < 1)
return;
int x, y, u, v;
gfx::Color c1 = gfx::rgba(128, 128, 128);
gfx::Color c2 = gfx::rgba(192, 192, 192);
u = 0;
v = 0;
for (y=rc.y; y<rc.y2()-tile.h; y+=tile.h) {
for (x=rc.x; x<rc.x2()-tile.w; x+=tile.w)
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, tile.w, tile.h));
if (x < rc.x2())
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, rc.x2()-x, tile.h));
u = (++v);
}
if (y < rc.y2()) {
for (x=rc.x; x<rc.x2()-tile.w; x+=tile.w)
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, tile.w, rc.y2()-y));
if (x < rc.x2())
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, rc.x2()-x, rc.y2()-y));
}
}
开发者ID:1007650105,项目名称:aseprite,代码行数:29,代码来源:gfx.cpp
示例2: DrawSurfaceWithTextureCoords
static void
DrawSurfaceWithTextureCoords(DrawTarget *aDest,
const gfx::Rect& aDestRect,
SourceSurface *aSource,
const gfx::Rect& aTextureCoords,
gfx::Filter aFilter,
float aOpacity,
SourceSurface *aMask,
const Matrix* aMaskTransform)
{
// Convert aTextureCoords into aSource's coordinate space
gfxRect sourceRect(aTextureCoords.x * aSource->GetSize().width,
aTextureCoords.y * aSource->GetSize().height,
aTextureCoords.width * aSource->GetSize().width,
aTextureCoords.height * aSource->GetSize().height);
// Floating point error can accumulate above and we know our visible region
// is integer-aligned, so round it out.
sourceRect.Round();
// Compute a transform that maps sourceRect to aDestRect.
Matrix matrix =
gfxUtils::TransformRectToRect(sourceRect,
gfx::IntPoint(aDestRect.x, aDestRect.y),
gfx::IntPoint(aDestRect.XMost(), aDestRect.y),
gfx::IntPoint(aDestRect.XMost(), aDestRect.YMost()));
// Only use REPEAT if aTextureCoords is outside (0, 0, 1, 1).
gfx::Rect unitRect(0, 0, 1, 1);
ExtendMode mode = unitRect.Contains(aTextureCoords) ? ExtendMode::CLAMP : ExtendMode::REPEAT;
FillRectWithMask(aDest, aDestRect, aSource, aFilter, DrawOptions(aOpacity),
mode, aMask, aMaskTransform, &matrix);
}
开发者ID:hoosteeno,项目名称:gecko-dev,代码行数:34,代码来源:BasicCompositor.cpp
示例3: SetAbsoluteBounds
void BrowserBubble::SetAbsoluteBounds(const gfx::Rect& window_bounds)
{
// Convert screen coordinates to frame relative.
gfx::Point relative_origin = window_bounds.origin();
view::View::ConvertPointToView(NULL, frame_->GetRootView(),
&relative_origin);
SetBounds(relative_origin.x(), relative_origin.y(),
window_bounds.width(), window_bounds.height());
}
开发者ID:leer168,项目名称:x-framework,代码行数:9,代码来源:browser_bubble.cpp
示例4: NonClientTopBorderHeight
gfx::Rect CustomFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const
{
int top_height = NonClientTopBorderHeight();
int border_thickness = NonClientBorderThickness();
return gfx::Rect(std::max(0, client_bounds.x()-border_thickness),
std::max(0, client_bounds.y()-top_height),
client_bounds.width()+(2*border_thickness),
client_bounds.height()+top_height+border_thickness);
}
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:10,代码来源:custom_frame_view.cpp
示例5: jniFrame
void
AndroidGeckoLayerClient::SetPageRect(const gfx::Rect& aCssPageRect)
{
NS_ASSERTION(!isNull(), "SetPageRect called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
if (!env)
return;
AutoLocalJNIFrame jniFrame(env, 0);
return env->CallVoidMethod(wrapped_obj, jSetPageRect,
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:12,代码来源:AndroidJavaWrappers.cpp
示例6: device
void
CompositorD3D9::ClearRect(const gfx::Rect& aRect)
{
D3DRECT rect;
rect.x1 = aRect.X();
rect.y1 = aRect.Y();
rect.x2 = aRect.XMost();
rect.y2 = aRect.YMost();
device()->Clear(1, &rect, D3DCLEAR_TARGET,
0x00000000, 0, 0);
}
开发者ID:martasect,项目名称:gecko,代码行数:12,代码来源:CompositorD3D9.cpp
示例7: DrawQuad
void
Compositor::DrawGeometry(const gfx::Rect& aRect,
const gfx::IntRect& aClipRect,
const EffectChain& aEffectChain,
gfx::Float aOpacity,
const gfx::Matrix4x4& aTransform,
const gfx::Rect& aVisibleRect,
const Maybe<gfx::Polygon3D>& aGeometry)
{
if (!aGeometry) {
DrawQuad(aRect, aClipRect, aEffectChain,
aOpacity, aTransform, aVisibleRect);
return;
}
// Cull invisible polygons.
if (aRect.Intersect(aGeometry->BoundingBox()).IsEmpty()) {
return;
}
gfx::Polygon3D clipped = aGeometry->ClipPolygon(aRect);
nsTArray<gfx::Triangle> triangles = clipped.ToTriangles();
for (gfx::Triangle& geometry : triangles) {
const gfx::Rect intersection = aRect.Intersect(geometry.BoundingBox());
// Cull invisible triangles.
if (intersection.IsEmpty()) {
continue;
}
MOZ_ASSERT(aRect.width > 0.0f && aRect.height > 0.0f);
MOZ_ASSERT(intersection.width > 0.0f && intersection.height > 0.0f);
gfx::TexturedTriangle triangle(Move(geometry));
triangle.width = aRect.width;
triangle.height = aRect.height;
// Since the texture was created for non-split geometry, we need to
// update the texture coordinates to account for the split.
if (aEffectChain.mPrimaryEffect->mType == EffectTypes::RGB) {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
UpdateTextureCoordinates(triangle, aRect, intersection,
texturedEffect->mTextureCoords);
}
DrawTriangle(triangle, aClipRect, aEffectChain,
aOpacity, aTransform, aVisibleRect);
}
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:52,代码来源:Compositor.cpp
示例8: SharesEdgeWith
bool Rect::SharesEdgeWith(const gfx::Rect& rect) const
{
return (y()==rect.y() && height()==rect.height() &&
(x()==rect.right() || right()==rect.x())) ||
(x()==rect.x() && width()==rect.width() &&
(y()==rect.bottom() || bottom()==rect.y()));
}
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:7,代码来源:rect.cpp
示例9: fill_rect
void fill_rect(Image* image, const gfx::Rect& rc, color_t c)
{
gfx::Rect clip = rc.createIntersect(image->bounds());
if (!clip.isEmpty())
image->fillRect(clip.x, clip.y,
clip.x+clip.w-1, clip.y+clip.h-1, c);
}
开发者ID:ololo1982,项目名称:aseprite,代码行数:7,代码来源:primitives.cpp
示例10: create
void ExtraCel::create(doc::Sprite* sprite,
const gfx::Rect& bounds,
doc::frame_t frame,
int opacity)
{
ASSERT(sprite);
if (!m_image ||
m_image->pixelFormat() != sprite->pixelFormat() ||
m_image->width() != bounds.w ||
m_image->height() != bounds.h) {
if (!m_imageBuffer)
m_imageBuffer.reset(new doc::ImageBuffer(1));
doc::Image* newImage = doc::Image::create(sprite->pixelFormat(),
bounds.w, bounds.h,
m_imageBuffer);
m_image.reset(newImage);
}
if (!m_cel) {
// Ignored fields for this cel (frame, and image index)
m_cel.reset(new doc::Cel(doc::frame_t(0), doc::ImageRef(nullptr)));
}
m_cel->setPosition(bounds.getOrigin());
m_cel->setOpacity(opacity);
m_cel->setFrame(frame);
}
开发者ID:riggtravis,项目名称:aseprite,代码行数:28,代码来源:extra_cel.cpp
示例11: WithImage
ClearRect::ClearRect(Cel* cel, const gfx::Rect& bounds)
{
app::Document* doc = static_cast<app::Document*>(cel->document());
Image* image = (cel ? cel->image(): NULL);
if (!image)
return;
m_offsetX = bounds.x - cel->x();
m_offsetY = bounds.y - cel->y();
gfx::Rect bounds2 =
image->bounds().createIntersection(
gfx::Rect(
m_offsetX, m_offsetY,
bounds.w, bounds.h));
if (bounds.isEmpty())
return;
m_dstImage.reset(new WithImage(image));
m_bgcolor = doc->bgColor(cel->layer());
m_copy.reset(crop_image(image,
bounds2.x, bounds2.y, bounds2.w, bounds2.h, m_bgcolor));
}
开发者ID:1007650105,项目名称:aseprite,代码行数:25,代码来源:clear_rect.cpp
示例12: PaintText
void Label::PaintText(gfx::Canvas* canvas,
const std::wstring& text,
const gfx::Rect& text_bounds,
int flags)
{
canvas->DrawStringInt(text, font_, color_,
text_bounds.x(), text_bounds.y(),
text_bounds.width(), text_bounds.height(), flags);
if(HasFocus() || paint_as_focused_)
{
gfx::Rect focus_bounds = text_bounds;
focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(),
focus_bounds.width(), focus_bounds.height());
}
}
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:17,代码来源:label.cpp
示例13: DrawRegion
void Layer::DrawRegion(const ui::TextureDrawParams& params,
const gfx::Rect& region_to_draw)
{
if(!region_to_draw.IsEmpty())
{
texture_->Draw(params, region_to_draw);
}
}
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:8,代码来源:layer.cpp
示例14: fillAreaBetweenRects
void Graphics::fillAreaBetweenRects(gfx::Color color,
const gfx::Rect& outer, const gfx::Rect& inner)
{
if (!outer.intersects(inner))
fillRect(color, outer);
else {
gfx::Region rgn(outer);
rgn.createSubtraction(rgn, gfx::Region(inner));
fillRegion(color, rgn);
}
}
开发者ID:ololo1982,项目名称:aseprite,代码行数:11,代码来源:graphics.cpp
示例15: switch
Dirty::Dirty(Image* image, Image* image_diff, const gfx::Rect& bounds)
: m_format(image->getPixelFormat())
, m_x1(bounds.x), m_y1(bounds.y)
, m_x2(bounds.x2()-1), m_y2(bounds.y2()-1)
{
int y, x1, x2;
for (y=m_y1; y<=m_y2; y++) {
x1 = m_x1;
x2 = m_x2;
bool res;
switch (image->getPixelFormat()) {
case IMAGE_RGB:
res = shrink_row<RgbTraits>(image, image_diff, x1, y, x2);
break;
case IMAGE_GRAYSCALE:
res = shrink_row<GrayscaleTraits>(image, image_diff, x1, y, x2);
break;
case IMAGE_INDEXED:
res = shrink_row<IndexedTraits>(image, image_diff, x1, y, x2);
break;
default:
ASSERT(false && "Not implemented for bitmaps");
return;
}
if (!res)
continue;
Col* col = new Col(x1, x2-x1+1);
col->data.resize(getLineSize(col->w));
Row* row = new Row(y);
row->cols.push_back(col);
m_rows.push_back(row);
}
}
开发者ID:CalinLeafshade,项目名称:aseprite,代码行数:41,代码来源:dirty.cpp
示例16: DidChangeBounds
void SingleSplitView::DidChangeBounds(const gfx::Rect& previous,
const gfx::Rect& current)
{
if(resize_leading_on_bounds_change_)
{
// We do not update divider_offset_ on minimize (to zero) and on restore
// (to largest value). As a result we get back to the original value upon
// window restore.
bool is_minimize_or_restore = previous.height()==0 ||
current.height()==0;
if(!is_minimize_or_restore)
{
if(is_horizontal_)
{
divider_offset_ += (current.width() - previous.width()) / 2;
}
else
{
divider_offset_ += (current.height() - previous.height()) / 2;
}
if(divider_offset_ < 0)
{
divider_offset_ = kDividerSize;
}
}
}
View::DidChangeBounds(previous, current);
}
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:30,代码来源:single_split_view.cpp
示例17: paintArtifactToWebDisplayItemList
static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const PaintArtifact& artifact, const gfx::Rect& bounds)
{
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
// This is a temporary path to paint the artifact using the paint chunk
// properties. Ultimately, we should instead split the artifact into
// separate layers and send those to the compositor, instead of sending
// one big flat SkPicture.
SkRect skBounds = SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
RefPtr<SkPicture> picture = paintArtifactToSkPicture(artifact, skBounds);
list->appendDrawingItem(WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()), picture.get());
return;
}
artifact.appendToWebDisplayItemList(list);
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:14,代码来源:ContentLayerDelegate.cpp
示例18: replace_color
static void replace_color(Image* image, const gfx::Rect& bounds, int src_color, int tolerance, void *data, AlgoHLine proc)
{
typename ImageTraits::address_t address;
for (int y=bounds.y; y<bounds.y2(); ++y) {
address = reinterpret_cast<typename ImageTraits::address_t>(image->getPixelAddress(bounds.x, y));
for (int x=bounds.x; x<bounds.x2(); ++x, ++address) {
int right = -1;
if (color_equal<ImageTraits>((int)(*address), src_color, tolerance)) {
++address;
for (right=x+1; right<bounds.x2(); ++right, ++address) {
if (!color_equal<ImageTraits>((int)(*address), src_color, tolerance))
break;
}
(*proc)(x, y, right-1, data);
x = right;
}
}
}
}
开发者ID:Mailaender,项目名称:aseprite,代码行数:22,代码来源:algofill.cpp
示例19: onPaint
void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const char* text)
{
SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get());
if (m_part && m_part->countBitmaps() > 0) {
if (m_part->countBitmaps() == 1) {
if (!gfx::is_transparent(m_color))
g->fillRect(m_color, bounds);
she::Surface* bmp = m_part->bitmap(0);
if (m_repeat == BackgroundRepeat::NO_REPEAT) {
g->drawRgbaSurface(bmp, bounds.x, bounds.y);
}
else {
ui::IntersectClip clip(g, bounds);
if (!clip)
return;
for (int y=bounds.y; y<bounds.y2(); y+=bmp->height()) {
for (int x=bounds.x; x<bounds.x2(); x+=bmp->width()) {
g->drawRgbaSurface(bmp, x, y);
if (m_repeat == BackgroundRepeat::REPEAT_Y)
break;
}
if (m_repeat == BackgroundRepeat::REPEAT_X)
break;
}
}
}
else if (m_part->countBitmaps() == 8) {
theme->drawRect(g, bounds, m_part.get(), m_color);
}
}
else if (!gfx::is_transparent(m_color)) {
g->fillRect(m_color, bounds);
}
}
开发者ID:Censacrof,项目名称:aseprite,代码行数:38,代码来源:style.cpp
示例20: GetMonitorBoundsForRect
gfx::Rect GetMonitorBoundsForRect(const gfx::Rect& rect)
{
RECT p_rect = rect.ToRECT();
HMONITOR monitor = MonitorFromRect(&p_rect, MONITOR_DEFAULTTONEAREST);
if(monitor)
{
MONITORINFO mi = { 0 };
mi.cbSize = sizeof(mi);
GetMonitorInfo(monitor, &mi);
return gfx::Rect(mi.rcWork);
}
NOTREACHED();
return gfx::Rect();
}
开发者ID:leer168,项目名称:x-framework,代码行数:14,代码来源:monitor_win.cpp
注:本文中的gfx::Rect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论