本文整理汇总了C++中Graphic类的典型用法代码示例。如果您正苦于以下问题:C++ Graphic类的具体用法?C++ Graphic怎么用?C++ Graphic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Graphic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tileGraphic
void VRAMEditorLayeredGraphicScene::renderTiles(
Graphic& g,
int tileIndex,
GGTileSet& tiles,
GGPalette& palette,
Graphic::TileTransferTransOption tileTransOption) {
// Render each tile and blit to Graphic
for (int j = 0; j < tiles.numTiles(); j++) {
// Render tile
Graphic tileGraphic(tiles[j],
palette,
tileTransOption);
// Calculate position in Graphic
int xPos = tileIndexToXPos(tileIndex);
int yPos = tileIndexToYPos(tileIndex);
// Blit if transparency is enabled; copy otherwise
if (tileTransOption == Graphic::tileTrans) {
g.blit(tileGraphic,
Box(xPos, yPos, 0, 0),
Graphic::noTransUpdate);
}
else {
g.copy(tileGraphic,
Box(xPos, yPos, 0, 0),
Graphic::noTransUpdate);
}
// Move to next tile position
++tileIndex;
}
}
示例2: while
void
Scene::Collect()
{
ListIter<Graphic> iter = graphics;
while (++iter) {
Graphic* g = iter.value();
if (g->Life() == 0) {
delete iter.removeItem();
}
}
iter.attach(sprites);
while (++iter) {
Graphic* g = iter.value();
if (g->Life() == 0) {
delete iter.removeItem();
}
}
ListIter<Light> iter1 = lights;
while (++iter1) {
Light* l = iter1.value();
if (l->Life() == 0) {
delete iter1.removeItem();
}
}
}
示例3: tileIndexToXPos
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);
}
}
示例4: pick
//-----------------------------------------------------------------------------
// Mouse motion (with either key pressed) event handler
//-----------------------------------------------------------------------------
void GlutDisplay::mouseMotionEvent(const int x, const int y)
{
if (isMessageEnabled(MSG_DEBUG)) {
std::cout << "GlutDisplay::mouseEvent(): " << std::endl;
}
if (picked != nullptr) {
Graphic* selected = pick();
if (selected != nullptr) {
if (selected != picked) {
picked->event(ON_CANCEL);
picked->unref();
picked = nullptr;
}
selected->event(ON_MOTION);
}
else {
if (picked != nullptr) {
picked->event(ON_CANCEL);
picked->unref();
picked = nullptr;
}
}
}
setMouse(x,y);
}
示例5: objv
void TransformerFunc::execute() {
ComValue objv(stack_arg(0));
ComValue transv(stack_arg(0));
reset_stack();
if (objv.object_compview()) {
ComponentView* compview = (ComponentView*)objv.obj_val();
if (compview && compview->GetSubject()) {
OverlayComp* comp = (OverlayComp*)compview->GetSubject();
Graphic* gr = comp->GetGraphic();
if (gr) {
Transformer* trans = gr->GetTransformer();
if (transv.is_unknown() || !transv.is_array() || transv.array_val()->Number()!=6) {
AttributeValueList* avl = new AttributeValueList();
float a00, a01, a10, a11, a20, a21;
trans->matrix(a00, a01, a10, a11, a20, a21);
avl->Append(new AttributeValue(a00));
avl->Append(new AttributeValue(a01));
avl->Append(new AttributeValue(a10));
avl->Append(new AttributeValue(a11));
avl->Append(new AttributeValue(a20));
avl->Append(new AttributeValue(a21));
ComValue retval(avl);
push_stack(retval);
} else {
float a00, a01, a10, a11, a20, a21;
AttributeValueList* avl = transv.array_val();
Iterator it;
AttributeValue* av;
avl->First(it);
av = avl->GetAttrVal(it);
a00 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a01 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a10 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a11 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a20 = av->float_val();
avl->Next(it);
av = avl->GetAttrVal(it);
a21 = av->float_val();
Transformer t(a00, a01, a10, a11, a20, a21);
*gr->GetTransformer()=t;
ComValue compval(new OverlayViewRef(comp), comp->class_symid());
push_stack(compval);
}
}
}
}
}
示例6: GetGraphicBox
void Viewer::SetOrientation (Orientation o) {
if (_orientation != o) {
_orientation = o;
Coord l, b, r, t;
GetGraphicBox(l, b, r, t);
Graphic* g = GraphicBlock::GetGraphic();
if (
_orientation == Normal ||
_orientation == Portrait ||
_orientation == Vertical
) {
g->Rotate(90., l, b);
g->Translate(t-b, 0.);
} else if (
_orientation == Rotated ||
_orientation == Landscape ||
_orientation == Horizontal
) {
g->Rotate(-90., l, b);
g->Translate(0., r-l);
}
GraphicBlock::Update();
}
}
示例7: draw
void TextField::draw(const Graphic& graphic, double deltaTime) {
Component::draw(graphic, deltaTime);
Dimension dim = getSize();
float x = 0.0;
// Text should
switch (alignment_) {
case Alignment::LEFT:
x = 2;
break;
case Alignment::CENTER:
x = dim.width_ * 0.5f - (text_.getWidth() - 2) * 0.5f;
break;
case Alignment::RIGHT:
x = dim.width_ - text_.getWidth() - 2;
break;
}
graphic.setColor(textColor_);
graphic.drawText(text_, x, 0);
if (editable_) {
if (hasFocus()) {
markerDeltaTime_ += deltaTime;
if (markerDeltaTime_ < 0.5) {
graphic.drawSquare(markerWidth_ + x, 1, 1, text_.getCharacterSize());
} else if (markerDeltaTime_ > 1.0) {
markerDeltaTime_ = 0;
}
} else {
markerDeltaTime_ = 0;
}
}
}
示例8: effect
boolean GraphicMaster::effect (const Event& e, Tool& tool) {
boolean flag = true;
Window* w = e.window();
if (w != nil) {
w->cursor(window_cursor);
Canvas* c = w->canvas();
long count = _gr_list->count();
Coord l, b, r, t;
for (long i = 0; i < count && flag; i++) {
Graphic* target = _gr_list->item(i);
target->getbounds(l, b, r, t);
c->damage(l, b, r, t);
flag = target->effect(e, tool);
if (flag) {
target->getbounds(l, b, r, t);
c->damage(l, b, r, t);
}
target->flush();
CanvasRep& rep = *c->rep();
CanvasDamage& cd = rep.damage_;
rep.start_repair();
drawclipped(c, cd.left, cd.bottom, cd.right, cd.top);
rep.finish_repair();
}
_gr_list->remove_all();
}
return flag;
}
示例9: Sim_Press
void VMouse::Sim_Press(Graphic* orig, Graphic* porig, Event& e) {
Canvas* screen = _myglass->GetCanvas();
Graphic* parent;
if (e.eventType == DownEvent) {
parent = orig->Parent();
if (parent != nil) {
orig->Erase(screen);
parent->Remove(orig);
parent->Append(porig);
porig->Draw(screen);
if (e.leftmouse) {
_vwriter->Request(1);
} else if (e.middlemouse) {
_vwriter->Request(2);
} else if (e.rightmouse) {
_vwriter->Request(3);
}
}
} else if (e.eventType == UpEvent) {
parent = porig->Parent();
if (parent != nil) {
porig->Erase(screen);
parent->Remove(porig);
parent->Append(orig);
orig->Draw(screen);
}
}
}
示例10: Recall
void AlignToGridCmd::Align (GraphicView* gv, float refx, float refy) {
MoveData* md = (MoveData*) Recall(gv->GetGraphicComp());
if (md == nil) {
Viewer* v = gv->GetViewer();
Grid* grid = (v == nil) ? nil : v->GetGrid();
if (grid == nil) {
return;
}
Graphic* g = gv->GetGraphic();
Transformer t;
g->Parent()->TotalTransformation(t);
t.Invert();
Coord cx = iv26_round(refx);
Coord cy = iv26_round(refy);
grid->Constrain(cx, cy);
float dx, dy, trefx, trefy;
t.Transform(float(cx), float(cy), dx, dy);
t.Transform(refx, refy, trefx, trefy);
dx -= trefx;
dy -= trefy;
Store(gv->GetGraphicComp(), new MoveData(dx, dy));
}
Move(gv->GetGraphicComp());
}
示例11: GetSubject
boolean PSLink::Definition (ostream& out) {
LinkComp* comp = (LinkComp*) GetSubject();
Graphic* link = comp->GetGraphic();
Line* line = comp->GetLine();
Transformer* link_t = link->GetTransformer();
Transformer* line_t = line->GetTransformer();
Transformer* temp_t = new Transformer(line_t);
Resource::ref(link_t);
temp_t->postmultiply(*link_t);
link->SetTransformer(temp_t);
Coord x0, y0, x1, y1;
line->GetOriginal(x0, y0, x1, y1);
out << "Begin " << MARK << " Line\n";
MinGS(out);
out << MARK << "\n";
out << x0 << " " << y0 << " " << x1 << " " << y1 << " Line\n";
out << "End\n\n";
link->SetTransformer(link_t);
Resource::unref(link_t);
Resource::unref(temp_t);
return out.good();
}
示例12: remove_
void PolyGraphic::remove_ (GlyphIndex i) {
Graphic* gr = (Graphic*)_body->component(i);
if (gr != nil) {
gr->parent(nil);
}
_body->remove(i);
}
示例13: Picture
LinkComp::LinkComp (Line* line) {
if (line != nil) {
Coord x0, y0, x1, y1;
float fx0, fy0, fx1, fy1;
line->GetOriginal(x0, y0, x1, y1);
Transformer* t = line->GetTransformer();
Graphic* parent = new Picture(line);
parent->SetTransformer(nil);
if (t == nil) {
fx0 = x0; fy0 = y0; fx1 = x1; fy1 = y1;
} else {
t->Transform(float(x0), float(y0), fx0, fy0);
t->Transform(float(x1), float(y1), fx1, fy1);
}
delete line;
line = new Line(0, 0, 1, 1);
InitLine(line, fx0, fy0, fx1, fy1);
PinGraphic* pg1 = new PinGraphic;
PinGraphic* pg2 = new PinGraphic;
pg1->SetBrush(psnonebr);
pg2->SetBrush(psnonebr);
pg1->Translate(fx0, fy0);
pg2->Translate(fx1, fy1);
_conn1 = new PinComp(pg1);
_conn2 = new PinComp(pg2);
parent->Append(line, pg1, pg2);
SetGraphic(parent);
}
}
示例14: GetGraphic
Line* LinkView::GetLine () {
Iterator i;
Graphic* gr = GetGraphic();
gr->First(i);
return (Line*) gr->GetGraphic(i);
}
示例15: cvCreateMat
void Morphining::DoAffineTrsform(IplImage *src,IplImage *dst,vector<Coordinate> coord1,vector<Coordinate> coord2,double T,int type,bool debug)//T:Threshold of SSD's error;
{
CvMat* Matrix = cvCreateMat(3,3,CV_32FC1);
Matrix = GetAffineMatrix(coord1,coord2,debug);
//if(SSD(coord1,coord2,Matrix,100))
//{
Vertex = new Coordinate [m_numFeature];
for(int i = 0;i < m_numFeature;i++)
{
Vertex[i] = coord1[i];
}
Graphic FindLine;
FindLine.CuttingRegion(coord1,m_numFeature,m,b);
AffineTrsform(src,dst,Matrix,type,debug);
if(debug)
{
cvNamedWindow("dst",0);
cvShowImage("dst",dst);
cvWaitKey(0);
}
//}
cvReleaseMat(&Matrix);
}