本文整理汇总了C++中Graphic::h方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphic::h方法的具体用法?C++ Graphic::h怎么用?C++ Graphic::h使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphic
的用法示例。
在下文中一共展示了Graphic::h方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boxGenericLength
void VRAMEditorLayeredGraphicScene::boxGenericLength(
Graphic& dst,
int baseIndex,
int numTiles,
Color color,
int width,
double scale) {
for (int i = 0; i < numTiles; i++) {
// Calculate position in Graphic
int xPos = tileIndexToXPos(baseIndex + i);
int yPos = tileIndexToYPos(baseIndex + i);
BoxGraphicSceneObject box(color,
width,
GGTile::width * scale,
GGTile::height * scale,
xPos * scale,
yPos * scale,
true);
box.render(dst,
Box(0, 0, dst.w(), dst.h()),
1.00);
}
}
示例2: drawPreviewGraphic
void PaletteEditor::drawPreviewGraphic(Graphic& dst) {
colorPreview_.setColor(
Color(currentColor().realR(),
currentColor().realG(),
currentColor().realB(),
Color::fullAlphaOpacity));
colorPreview_.render(dst,
Box(0, 0, dst.w(), dst.h()),
1.00);
}
示例3: updatePreview
void GraphicSubheaderAddDialog::updatePreview() {
GGTileSet tiles
= levelGraphicsData_.compressedGraphic(graphicIndex_);
if (flipped_) {
for (int i = 0; i < tiles.numTiles(); i++) {
tiles[i].flipHorizontal();
}
}
Graphic graphic
= tiles.toPalettizedGraphic(16,
objectPalette_,
Color(0, 0, 0, Color::fullAlphaOpacity));
Graphic scaledGraphic(graphic.w() * 2,
graphic.h() * 2);
graphic.scale(scaledGraphic);
ui->graphicPreview->setPixmap(
TalesQtFormatConversion::graphicToPixmap(scaledGraphic));
ui->previewNumTilesLabel->setText(
(StringConversion::toString(tiles.numTiles()) + " tiles").c_str());
}
示例4: render
void MetatilePickerLayeredGraphicScene::render(Graphic& dst,
Box srcbox,
double scale) {
dst.clear();
int metatileNum = 0;
for (int j = 0; j < metatilesPerColumn_; j++) {
for (int i = 0; i < metatilesPerRow_; i++) {
if (bgLayerEnabled_) {
dst.blit(metatilesVisualBG_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::transUpdate);
}
if (fgLayerEnabled_) {
dst.blit(metatilesVisualFG_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::transUpdate);
}
if (effectLayerEnabled_) {
dst.blit(metatilesEffect_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::noTransUpdate);
}
if (verticalSolidityLayerEnabled_) {
dst.blit(metatilesVerticalSolidity_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::noTransUpdate);
}
if (horizontalSolidityLayerEnabled_) {
dst.blit(metatilesHorizontalSolidity_[metatileNum],
Box(i * MetatileStructure::metatileWidth,
j * MetatileStructure::metatileHeight,
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight),
Graphic::noTransUpdate);
}
++metatileNum;
}
}
if (gridLayerEnabled_) {
gridLayer_.render(dst,
Box(srcbox.x(),
srcbox.y(),
dst.w(),
dst.h()),
1.00);
}
if ((highlightedMetatileBoxEnabled_)) {
dst.drawRectBorder(metatileIndexToX(highlightedMetatileIndex_),
metatileIndexToY(highlightedMetatileIndex_),
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight,
Color(0xFF, 0xFF, 0x00, Color::fullAlphaOpacity),
2);
}
if ((toolManager_->currentTool() == LevelEditorTools::metatilePaint)) {
dst.drawRectBorder(metatileIndexToX(toolManager_->pickedMetatileIndex()),
metatileIndexToY(toolManager_->pickedMetatileIndex()),
MetatileStructure::metatileWidth,
MetatileStructure::metatileHeight,
Color(0xFF, 0x00, 0x00, Color::fullAlphaOpacity),
2);
}
}
示例5: drawMetatilePickerGraphic
void MetatileStructureEditor::drawMetatilePickerGraphic(Graphic& dst) {
metatilePicker_.render(dst,
Box(0, 0,
dst.w(), dst.h()),
1.00);
}
示例6: render
void GridGraphicSceneLayer::render(Graphic& dst,
Box srcbox,
double scale) {
if (!visible_) {
return;
}
// int maxPos = basePos + (srcbox.w() * scale);
int realSpacing = lineSpacing_ * scale;
int realXLimit = xLimit_ * scale;
int realYLimit = yLimit_ * scale;
if (xLimit_ == 0) {
// realXLimit = (srcbox.x() + srcbox.w()) * scale;
realXLimit = dst.w();
}
if (yLimit_ == 0) {
// realYLimit = (srcbox.y() + srcbox.h()) * scale;
realYLimit = dst.h();
}
if (dst.w() < realXLimit) {
realXLimit = dst.w();
}
if (dst.h() < realYLimit) {
realYLimit = dst.h();
}
int realLineWidth = lineWidth_;
if (enlargeOnZoom_) {
realLineWidth *= scale;
}
// Compute where to start drawing lines
int baseXPos = srcbox.x() * scale;
// int baseXPos = srcbox.x();
int drawXBase = -(baseXPos % realSpacing);
int baseYPos = srcbox.y() * scale;
// int baseYPos = srcbox.y();
int drawYBase = -(baseYPos % realSpacing);
// Draw vertical lines
for (int i = drawXBase; i < realXLimit; i += realSpacing) {
dst.drawLine(i, 0,
i, realYLimit,
color_,
realLineWidth,
Graphic::noTransUpdate);
}
// Draw horizontal lines
for (int i = drawYBase; i < realYLimit; i += realSpacing) {
dst.drawLine(0, i,
realXLimit, i,
color_,
realLineWidth,
Graphic::noTransUpdate);
}
}
示例7: render
void VRAMEditorLayeredGraphicScene::render(
Graphic& dst,
Box srcbox,
double scale) {
// Create empty graphic with white background (TODO: selectable BG color)
// The normal background color is black, so unused tiles will show up
// as white
// Graphic g(nativeWidth(), nativeHeight());
// g.clear(Color(0, 0, 0, 0));
g_.clear();
// Get level graphics header containing graphics to render
int levelGraphicsHeaderIndex
= levelGraphicsData_.levelHeaderIndexByMapnum(areaNum_,
mapNum_);
LevelGraphicsHeader& levelGraphicsHeader
= levelGraphicsData_.levelGraphicsHeader(levelGraphicsHeaderIndex);
// Look up palette header for this level
LevelPaletteHeader& levelPaletteHeader
= paletteHeaders_.headerByIndex(
paletteHeaders_.indexOfMapNum(areaNum_,
mapNum_));
// Get level palettes
GGPalette palette0
= palettes_.palette(levelPaletteHeader.palette0Index());
GGPalette palette1
= palettes_.palette(levelPaletteHeader.palette1Index());
// Get map graphic index
int mapGraphicIndex = levelGraphicsHeader.mapGraphicIndex();
// Get map graphic
GGTileSet mapGraphic
= levelGraphicsData_.compressedGraphic(mapGraphicIndex);
// Get index of the start of the map tiles
int mapTileIndex
= vramAddressToTileIndex(levelGraphicsHeader.vdpWriteAddress());
// Render map graphic
renderTiles(g_,
mapTileIndex,
mapGraphic,
palette0,
Graphic::noTileTrans);
// Get object graphics header index
int objectGraphicsHeaderIndex
= levelGraphicsHeader.objectGraphicsHeaderIndex();
// Get object graphics header
ObjectGraphicsHeader& objectGraphicsHeader
= levelGraphicsData_.objectGraphicsHeader(objectGraphicsHeaderIndex);
// Iterate over graphics subheaders and add object graphics to render
for (int i = 0; i < objectGraphicsHeader.size(); i++) {
ObjectGraphicSubheader& subheader
= objectGraphicsHeader.subheader(i);
int objectGraphicIndex = subheader.objectGraphicIndex();
// Get graphic
GGTileSet objectGraphic
= levelGraphicsData_.compressedGraphic(objectGraphicIndex);
// Flip tiles if horizontal flip flag is set
if (subheader.substitutionOption()
== ObjectGraphicSubheader::substitutionEnabled) {
for (int j = 0; j < objectGraphic.numTiles(); j++) {
objectGraphic[j].flipHorizontal();
}
}
// Get index of the tile
int tileIndex = vramAddressToTileIndex(subheader.vdpWriteAddress());
// Render object graphic.
// Use palette 1 (sprite palette) for objects.
// Technically we "should" use transparency here, but it's possible
// to overwrite one graphic with another and we don't want to leave
// scraps of the previous graphic visible when that happens.
// TODO: add some concept of background color (maybe change color 0
// in palette?)
renderTiles(g_,
tileIndex,
objectGraphic,
palette1,
Graphic::noTileTrans);
// Draw full graphic selection box if enabled and needed
// (this will be scaled with the graphic, negating the benefits of vector-
// based drawing!)
if ((i == fullSelectionBoxGraphicIndex_)
&& fullSelectionBoxEnabled_) {
/* // Draw line on left side of first tile
int firstXPos = tileIndexToXPos(tileIndex);
int firstYPos = tileIndexToYPos(tileIndex);
//.........这里部分代码省略.........
示例8: drawPreviewGraphic
void LevelEditor::drawPreviewGraphic(Graphic& dst) {
// dst.copy(levelGraphicsData_.compressedGraphic(0).toGrayscaleGraphic(16),
// Box(0, 0, 0, 0),
// Graphic::noTransUpdate);
// levelGraphicsData_.compressedGraphic(0).toGrayscaleGraphic(16)
// .scale(dst,
// Graphic::noTransUpdate);
previewScene_.render(dst,
Box(scrollX(),
scrollY(),
dst.w() / scale(),
dst.h() / scale()),
scale());
/* if ((needWrapCacheRefresh_)
|| (wrapScrollCache_.surface().w() != (int)(dst.w() / scale()))
|| (wrapScrollCache_.surface().h() != (int)(dst.h() / scale()))) {
wrapScrollCache_ = WrapScrollGraphic(dst.w() / scale(),
dst.h() / scale());
// std::cout << wrapScrollCache_.surface().w() << " " << dst.w() << std::endl;
previewScene_.render(dst,
wrapScrollCache_,
Box(scrollX_,
scrollY_,
dst.w() / scale(),
dst.h() / scale()),
scale());
needWrapCacheRefresh_ = false;
return;
}
if (lastRenderedScrollX_ != scrollX_) {
wrapScrollCache_.scrollInX(scrollX_ - lastRenderedScrollX_);
Box scrollBox(scrollX_, scrollY_,
scrollX_ - lastRenderedScrollX_,
wrapScrollCache_.surface().h());
// If width is negative, adjust x-position and make width positive
if (scrollBox.w() < 0) {
scrollBox.setX(scrollBox.x() + scrollBox.w());
scrollBox.setW(-(scrollBox.w()));
}
// Render changed columns
previewScene_.render(dst,
wrapScrollCache_,
scrollBox,
scale());
}
if (lastRenderedScrollY_ != scrollY_) {
wrapScrollCache_.scrollInY(scrollY_ - lastRenderedScrollY_);
Box scrollBox(scrollX_, scrollY_,
wrapScrollCache_.surface().w(),
scrollY_ - lastRenderedScrollY_);
// If height is negative, adjust y-position and make height positive
if (scrollBox.h() < 0) {
scrollBox.setY(scrollBox.y() + scrollBox.h());
scrollBox.setH(-(scrollBox.h()));
}
// Render changed rows
previewScene_.render(dst,
wrapScrollCache_,
scrollBox,
scale());
}
lastRenderedScrollX_ = scrollX_;
lastRenderedScrollY_ = scrollY_; */
}