本文整理汇总了C++中DrawingContext::draw_line方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawingContext::draw_line方法的具体用法?C++ DrawingContext::draw_line怎么用?C++ DrawingContext::draw_line使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawingContext
的用法示例。
在下文中一共展示了DrawingContext::draw_line方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Color
void
EditorInputCenter::draw_path(DrawingContext& context) {
if (!edited_path) return;
if (!marked_object) return;
if (!marked_object->is_valid()) return;
if (!edited_path->is_valid()) return;
for(auto i = edited_path->nodes.begin(); i != edited_path->nodes.end(); ++i) {
auto j = i+1;
Path::Node* node1 = &(*i);
Path::Node* node2;
if (j == edited_path->nodes.end()) {
if (edited_path->mode == Path::CIRCULAR || edited_path->mode == Path::UNORDERED) {
//loop to the first node
node2 = &(*edited_path->nodes.begin());
} else {
continue;
}
} else {
node2 = &(*j);
}
auto cam_translation = Editor::current()->currentsector->camera->get_translation();
context.draw_line(node1->position - cam_translation,
node2->position - cam_translation,
Color(1, 0, 0), LAYER_GUI - 21);
}
}
示例2: int
void
SmallMap::draw(DrawingContext& gc)
{
// FIXME: This is potentially dangerous, since we don't know how
// long 'gc' will be alive. Should use a DrawingContext for caching.
gc_ptr = &gc;
World* const& world = server->get_world();
Vector2i of = playfield->get_pos();
Rect view_rect;
if (world->get_width() > gc.get_width())
{
int rwidth = int(gc.get_width() * rect.get_width() / world->get_width());
view_rect.left = rect.left + (of.x * rect.get_width() / world->get_width()) - rwidth/2;
view_rect.right = view_rect.left + rwidth;
}
else
{
view_rect.left = rect.left;
view_rect.right = rect.left + rect.get_width();
}
if (world->get_height() > gc.get_height())
{
int rheight = int(gc.get_height() * rect.get_height() / world->get_height());
view_rect.top = rect.top + (of.y * rect.get_height() / world->get_height()) - rheight/2;
view_rect.bottom = view_rect.top + rheight;
}
else
{
view_rect.top = rect.top;
view_rect.bottom = rect.top + rect.get_height();
}
gc.draw(image->get_surface(), Vector2i(rect.left, rect.top));
gc.draw_rect(view_rect, Color(0, 255, 0));
server->get_world()->draw_smallmap(this);
// Draw Pingus
PinguHolder* pingus = world->get_pingus();
for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
{
int x = static_cast<int>(static_cast<float>(rect.left) + ((*i)->get_x() * static_cast<float>(rect.get_width())
/ static_cast<float>(world->get_width())));
int y = static_cast<int>(static_cast<float>(rect.top) + ((*i)->get_y() * static_cast<float>(rect.get_height())
/ static_cast<float>(world->get_height())));
gc.draw_line(Vector2i(x, y), Vector2i(x, y-2), Color(255, 255, 0));
}
gc_ptr = 0;
}
示例3: Color
void
Playfield::draw(DrawingContext& gc)
{
scene_context->clear();
scene_context->set_cliprect(rect);
//scene_context->light().fill_screen(Color(50, 50, 50));
state.push(*scene_context);
cap.set_pingu(current_pingu);
cap.draw(*scene_context);
world->draw(*scene_context);
// Draw the scrolling band
if (mouse_scrolling && !drag_drop_scrolling)
{
gc.draw_line(mouse_pos.x, mouse_pos.y,
scroll_center.x, scroll_center.y-15,
Color(0, 255, 0));
gc.draw_line(mouse_pos.x, mouse_pos.y,
scroll_center.x, scroll_center.y,
Color(255, 0, 0));
gc.draw_line(mouse_pos.x, mouse_pos.y,
scroll_center.x, scroll_center.y+15,
Color(0, 0, 255));
gc.draw_line(mouse_pos.x, mouse_pos.y,
scroll_center.x + 15, scroll_center.y,
Color(0, 255, 255));
gc.draw_line(mouse_pos.x, mouse_pos.y,
scroll_center.x - 15, scroll_center.y,
Color(255, 255, 0));
}
state.pop(*scene_context);
gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0,0,-10000)));
}
示例4: Rectf
void
EditorInputCenter::draw_tile_grid(DrawingContext& context) {
auto editor = Editor::current();
if ( !editor->layerselect.selected_tilemap ) {
return;
}
auto current_tm = dynamic_cast<TileMap*>(editor->layerselect.selected_tilemap);
if ( current_tm == NULL )
return;
int tm_width = current_tm->get_width();
int tm_height = current_tm->get_height();
Rectf draw_rect = Rectf(editor->currentsector->camera->get_translation(),
editor->currentsector->camera->get_translation() + Vector(SCREEN_WIDTH, SCREEN_HEIGHT));
Vector start = sp_to_tp( Vector(draw_rect.p1.x, draw_rect.p1.y) );
Vector end = sp_to_tp( Vector(draw_rect.p2.x, draw_rect.p2.y) );
start.x = std::max(0.0f, start.x);
start.y = std::max(0.0f, start.y);
end.x = std::min(float(tm_width-1), end.x);
end.y = std::min(float(tm_height-1), end.y);
Vector line_start, line_end;
for (int i = start.x; i <= end.x; i++) {
line_start = tile_screen_pos( Vector(i, 0) );
line_end = tile_screen_pos( Vector(i, tm_height) );
context.draw_line(line_start, line_end, Color(1, 1, 1, 0.7), current_tm->get_layer());
}
for (int i = start.y; i <= end.y; i++) {
line_start = tile_screen_pos( Vector(0, i) );
line_end = tile_screen_pos( Vector(tm_width, i) );
context.draw_line(line_start, line_end, Color(1, 1, 1, 0.7), current_tm->get_layer());
}
start = tile_screen_pos( Vector(0, 0) );
end = tile_screen_pos( Vector(tm_width, tm_height) );
context.draw_line(start, Vector(start.x, end.y), Color(1, 0, 1), current_tm->get_layer());
context.draw_line(start, Vector(end.x, start.y), Color(1, 0, 1), current_tm->get_layer());
context.draw_line(Vector(start.x, end.y), end, Color(1, 0, 1), current_tm->get_layer());
context.draw_line(Vector(end.x, start.y), end, Color(1, 0, 1), current_tm->get_layer());
}
示例5: Color
void
PathDrawable::draw (DrawingContext& gc)
{
Path::iterator prev = path.begin();
for(Path::iterator next = prev + 1; next != path.end(); ++next)
{
gc.draw_line(Vector2i(static_cast<int>(prev->x), static_cast<int>(prev->y)),
Vector2i(static_cast<int>(next->x), static_cast<int>(next->y)),
Color(255, 255, 255));
prev = next;
}
}
示例6: SceneContextDrawingRequest
void
Playfield::draw(DrawingContext& gc)
{
scene_context->clear();
state.push(*scene_context);
capture_rectangle.set_pingu(current_pingu);
capture_rectangle.draw(*scene_context);
server->get_world()->draw(*scene_context);
state.pop(*scene_context);
gc.draw(new SceneContextDrawingRequest(scene_context.get(), Vector2i(0,0), -10000));
gc.push_modelview();
gc.translate(rect.left, rect.top);
// Draw the scrolling band
if (mouse_scrolling && !globals::drag_drop_scrolling)
{
gc.draw_line(mouse_pos, scroll_center - Vector2i(0, 15),
Color(0, 255, 0));
gc.draw_line(mouse_pos, scroll_center + Vector2i(0, 15),
Color(0, 0, 255));
gc.draw_line(mouse_pos, scroll_center + Vector2i(15, 0),
Color(0, 255, 255));
gc.draw_line(mouse_pos, scroll_center - Vector2i(15, 0),
Color(255, 255, 0));
gc.draw_line(mouse_pos, scroll_center,
Color(255, 0, 0));
}
gc.pop_modelview();
}