本文整理汇总了C++中Graphic::drawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphic::drawLine方法的具体用法?C++ Graphic::drawLine怎么用?C++ Graphic::drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphic
的用法示例。
在下文中一共展示了Graphic::drawLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMetatileEffect
void LevelEffectGraphicSceneLayer::drawMetatileEffect(
Graphic& metatileGraphic,
int indexNum,
const MetatileBehavior& behavior) {
metatileGraphic.clear(Color(0xFF, 0xFF, 0xFF, Color::fullAlphaOpacity));
switch (behavior.metatileType()) {
case MetatileTypes::nullType:
metatileGraphic.clear(
Color(0xFF, 0xFF, 0xFF, Color::fullAlphaOpacity));
break;
case MetatileTypes::climbable1:
case MetatileTypes::climbable2:
metatileGraphic.clear(
Color(0x88, 0x88, 0x88, Color::fullAlphaOpacity));
break;
// case MetatileTypes::climbable2:
// metatileGraphic.clear(
// Color(0xCC, 0xCC, 0xCC, Color::fullAlphaOpacity));
// break;
case MetatileTypes::nonclimbable:
metatileGraphic.clear(
Color(0x44, 0x44, 0x44, Color::fullAlphaOpacity));
// Color(0x22, 0x22, 0x22, Color::fullAlphaOpacity));
break;
case MetatileTypes::damaging:
metatileGraphic.clear(
Color(0xFF, 0x00, 0x00, Color::fullAlphaOpacity));
switch (indexNum) {
case 0x68:
case 0x69:
// up
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(i, 15,
i + 4, 2,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(i + 4, 2,
i + 8, 15,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x6A:
case 0x6B:
// down
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(i, 0,
i + 4, 13,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(i + 4, 13,
i + 8, 0,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x6C:
case 0x6D:
// right
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(0, i,
13, i + 4,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(13, i + 4,
0, i + 8,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x6E:
case 0x6F:
// left
for (int i = 0; i < 16; i += 8) {
metatileGraphic.drawLine(15, i,
1, i + 4,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
metatileGraphic.drawLine(2, i + 4,
15, i + 8,
Color(0xFF, 0xFF, 0x00,
Color::fullAlphaOpacity),
1);
}
break;
case 0x70:
case 0x71:
// all
default:
break;
}
break;
//.........这里部分代码省略.........
示例2: 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);
}
}