本文整理汇总了C++中Drawing类的典型用法代码示例。如果您正苦于以下问题:C++ Drawing类的具体用法?C++ Drawing怎么用?C++ Drawing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Drawing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofPoint
//--------------------------------------------------------------
void ofApp::onMessage( ofxLibwebsockets::Event& args ){
cout<<"got message "<<args.message<<endl;
try{
// trace out string messages or JSON messages!
if ( !args.json.isNull() ){
ofPoint point = ofPoint( args.json["point"]["x"].asFloat(), args.json["point"]["y"].asFloat() );
// for some reason these come across as strings via JSON.stringify!
int r = ofToInt(args.json["color"]["r"].asString());
int g = ofToInt(args.json["color"]["g"].asString());
int b = ofToInt(args.json["color"]["b"].asString());
ofColor color = ofColor( r, g, b );
int _id = ofToInt(args.json["id"].asString());
map<int, Drawing*>::const_iterator it = drawings.find(_id);
Drawing * d = it->second;
d->addPoint(point);
} else {
}
// send all that drawing back to everybody except this one
vector<ofxLibwebsockets::Connection *> connections = server.getConnections();
for ( int i=0; i<connections.size(); i++){
if ( (*connections[i]) != args.conn ){
connections[i]->send( args.message );
}
}
}
catch(exception& e){
ofLogError() << e.what();
}
}
示例2: Drawing
//--------------------------------------------------------------
void ofApp::onOpen( ofxLibwebsockets::Event& args ){
cout<<"new connection open"<<endl;
cout<<args.conn.getClientIP()<< endl;
Drawing * d = new Drawing();
d->_id = canvasID++;
d->color.set(ofRandom(255),ofRandom(255),ofRandom(255));;
d->conn = &( args.conn );
drawings.insert( make_pair( d->_id, d ));
// send "setup"
args.conn.send( d->getJSONString("setup") );
// send drawing so far
map<int, Drawing*>::iterator it = drawings.begin();
for (it; it != drawings.end(); ++it){
Drawing * drawing = it->second;
if ( d != drawing ){
for ( int i=0; i<drawing->points.size(); i++){
string x = ofToString(drawing->points[i].x);
string y = ofToString(drawing->points[i].y);
server.send( "{\"id\":"+ ofToString(drawing->_id) + ",\"point\":{\"x\":\""+ x+"\",\"y\":\""+y+"\"}," + drawing->getColorJSON() +"}");
}
}
}
}
示例3: Run
void Run(){
wxGetApp().m_digitizing->digitized_point = DigitizedPoint(line_for_tool->A->m_p, DigitizeInputType);
Drawing *pDrawingMode = dynamic_cast<Drawing *>(wxGetApp().input_mode_object);
if (pDrawingMode != NULL)
{
pDrawingMode->AddPoint();
}
}
示例4: p
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
ofPoint p(x,y);
map<int, Drawing*>::iterator it = drawings.find(0);
Drawing * d = it->second;
d->addPoint(p);
server.send( "{\"id\":-1,\"point\":{\"x\":\""+ ofToString(x)+"\",\"y\":\""+ofToString(y)+"\"}," + d->getColorJSON() +"}");
}
示例5: p
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
ofPoint p(x,y);
map<int, Drawing*>::iterator it = drawings.find(id);
if ( it == drawings.end() ) return;
Drawing * d = it->second;
d->addPoint(p);
client.send( "{\"id\":"+ ofToString(id) + ",\"point\":{\"x\":\""+ ofToString(x)+"\",\"y\":\""+ofToString(y)+"\"}," + d->getColorJSON() +"}");
}
示例6: Drawing
//--------------------------------------------------------------
void ofApp::onMessage( ofxLibwebsockets::Event& args ){
try{
cout<<"got message "<<args.message<<endl;
// trace out string messages or JSON messages!
if ( !args.json.isNull() ){
if (!args.json["setup"].isNull()){
Drawing * d = new Drawing();
d->_id = args.json["setup"]["id"].asInt();
// for some reason these come across as strings via JSON.stringify!
int r = ofToInt(args.json["setup"]["color"]["r"].asString());
int g = ofToInt(args.json["setup"]["color"]["g"].asString());
int b = ofToInt(args.json["setup"]["color"]["b"].asString());
d->color.set(r, g, b);
drawings.insert( make_pair( d->_id, d ));
id = d->_id;
color.set(r, g, b);
cout << "setup with id:" << id << endl;
}
else if (args.json["id"].asInt() != id){
cout << "received point" << endl;
ofPoint point = ofPoint( args.json["point"]["x"].asFloat(), args.json["point"]["y"].asFloat() );
// for some reason these come across as strings via JSON.stringify!
int r = ofToInt(args.json["color"]["r"].asString());
int g = ofToInt(args.json["color"]["g"].asString());
int b = ofToInt(args.json["color"]["b"].asString());
ofColor color = ofColor( r, g, b );
int _id = args.json["id"].asInt();
map<int, Drawing*>::const_iterator it = drawings.find(_id);
Drawing * d;
if (it!=drawings.end()){
d = it->second;
}
else {
d = new Drawing();
d->_id = _id;
// for some reason these come across as strings via JSON.stringify!
int r = ofToInt(args.json["color"]["r"].asString());
int g = ofToInt(args.json["color"]["g"].asString());
int b = ofToInt(args.json["color"]["b"].asString());
d->color.set(r, g, b);
drawings.insert( make_pair( d->_id, d ));
cout << "new drawing with id:" << _id << endl;
}
d->addPoint(point);
}
} else {
}
}
catch(exception& e){
ofLogError() << e.what();
}
}
示例7: test_lake
void test_lake() {
sf::RenderWindow window(sf::VideoMode(200, 200), "Map Test");
Random r;
window.clear(sf::Color(128, 128, 128));
Drawing * lake = Drawing::new_lake(r, 100);
lake->draw(window, 100, 100);
window_loop(window);
}
示例8: main
int main(){
Trigtable::generate();
Drawing *s;
SimCtrl sc;
stringstream evt;
string resp;
SockServ socket;
int cliTmp;
//espera um socket se conectar (espera ocupada)
while (!socket.acceptClient() && sc.isRunning()){
SDL_Delay(200);
evt << KbdDecoder::decodeKbdEvent();
EventManager::runEvent(evt, sc);
evt.clear();
}
//espera definir dimensoes do mundo
while (!sc.isStarted() && sc.isRunning()){
SDL_Delay(200);
evt << KbdDecoder::decodeKbdEvent();
EventManager::runEvent(evt, sc);
evt.clear();
socket.recvStart();
while (socket.hasNext()){
evt << socket.recvNext(&cliTmp);
s = EventManager::startSim(evt, sc);
if (s != NULL)
break;
}
evt.clear();
}
//inicia laco de simulacao
while (sc.isRunning()){
socket.acceptClient();
s->clearScr();
evt.clear();
evt << KbdDecoder::decodeKbdEvent();
EventManager::runEvent(evt, sc);
socket.recvStart();
while (socket.hasNext()){
evt.clear();
evt << socket.recvNext(&cliTmp);
resp = EventManager::runEvent(evt, sc, cliTmp);
if (resp.size())
socket.sends(resp,cliTmp);
}
sc.sendEvents(socket);
sc.sendTimeAlert(socket);
sc.runStep(*s);
sc.draw(*s);
s->updateScr();
}
}
示例9: test_shield
void test_shield() {
sf::RenderWindow window(sf::VideoMode(200, 200), "Wave Test");
Random r;
window.clear(sf::Color(128, 128, 128));
Drawing *shield = Drawing::new_shield(r, 100);
shield->draw(window, 100, 100);
window.display();
window_loop(window);
}
示例10: reallocScreenWidgets
// Refresh the screen widgets pool, depending on stored drawings
void ScreenBoard::reallocScreenWidgets() {
QDesktopWidget *desktop = QApplication::desktop();
int i, screensCount = desktop->numScreens();
// Delete exceeding screens and resize to screensCount
for (i = screensCount; i < m_screenWidgets.size(); ++i) {
m_screenWidgets[i]->hide();
m_screenWidgets[i]->deleteLater(); // Ensures no event about it is pending.
// Note that updates may be invoked in event handlers.
}
m_screenWidgets.resize(desktop->numScreens());
// Re-initialize the screen widgets list
for (i = 0; i < screensCount; ++i) {
ScreenWidget *screenWidget = m_screenWidgets[i];
if (screenWidget) screenWidget->drawings().clear();
}
// Turn on a ScreenWidget for each screen crossed by any drawing
int j, drawingsCount = m_drawings.size();
for (i = 0; i < screensCount; ++i) {
ScreenWidget *screenWidget = m_screenWidgets[i];
const QRect &screenGeom = desktop->screenGeometry(i);
for (j = 0; j < drawingsCount; ++j) {
Drawing *drawing = m_drawings[j];
if (drawing->acceptScreenEvents(screenGeom)) {
// Allocate the associated screen widget if necessary
if (!screenWidget) {
m_screenWidgets[i] = screenWidget = new ScreenWidget(0, m_grabbing);
if (m_grabbing) screenWidget->setCursor(m_cursor);
screenWidget->setGeometry(screenGeom);
screenWidget->show();
}
// Add the drawing to the widget
screenWidget->drawings().push_back(drawing);
}
}
}
// Remove screens without drawings
for (i = 0; i < screensCount; ++i) {
ScreenWidget *screenWidget = m_screenWidgets[i];
if (screenWidget && screenWidget->drawings().empty()) {
screenWidget->hide();
screenWidget->deleteLater();
m_screenWidgets[i] = 0;
}
}
}
示例11: foreach
// Refresh the pixmap of the displayed screenshot by redraw everything
void EditWindow::refreshScreenshotToShow()
{
// Take the screenshot without any drawings
QPixmap screenshotPixmap = screenshot->getImage();
painterScreenshot->drawPixmap(screenshotPixmap.rect(), screenshotPixmap);
// Draw every drawing one by one on the clean screenshot
Drawing* drawing;
foreach(drawing, newDrawingsList)
{
drawing->draw(painterScreenshot);
}
示例12: Run
void Run()
{
CBox box;
sketch_for_tools->GetBox(box);
double centre[3];
box.Centre(centre);
wxGetApp().m_digitizing->digitized_point = DigitizedPoint(gp_Pnt(box.MinX(), centre[1], centre[2]), DigitizeInputType);
Drawing *pDrawingMode = dynamic_cast<Drawing *>(wxGetApp().input_mode_object);
if (pDrawingMode != NULL)
{
pDrawingMode->AddPoint();
}
}
示例13: RenderAtomBG
void TileRenderer::RenderAtomBG(Drawing & drawing,
SPoint& offset,
SPoint& atomLoc,
u32 color)
{
SPoint ulpt(m_windowTL.GetX() + offset.GetY() + atomLoc.GetX() *
m_atomDrawSize,
m_windowTL.GetY() + offset.GetY() + atomLoc.GetY() *
m_atomDrawSize);
SPoint brpt(ulpt.GetX() + m_atomDrawSize, ulpt.GetY() + m_atomDrawSize);
if(brpt.GetX() > (s32)m_dimensions.GetX())
{
brpt.SetX(m_dimensions.GetX());
}
if(brpt.GetY() > (s32)m_dimensions.GetY())
{
brpt.SetY(m_dimensions.GetY());
}
drawing.FillRect(ulpt.GetX(),ulpt.GetY(),
brpt.GetX()-ulpt.GetX(),brpt.GetY()-ulpt.GetY(),
color);
}
示例14: simple_render
void simple_render(const Drawing& shape, graphics::raster& raster)
{
for (size_t y = 0; y < raster.height(); ++y) {
for (size_t x = 0; x < raster.width(); ++x) {
raster.at(x, y) = shape.color_at({x + .5, y + .5});
}
}
}
示例15: test_drawing2
void test_drawing2() {
sf::RenderWindow window(sf::VideoMode(200, 200), "Drawing Test");
Random r;
// Drawing *d = Drawing::new_mountain(r, 100);
// Drawing *d = Drawing::new_tree(r, 100);
// Drawing *d = Drawing::new_wave(r, 100);
// Drawing *d = Drawing::new_hill(r, 100);
Drawing *d = Drawing::new_person(r, 100);
window.clear(sf::Color(128, 128, 128));
d->draw(window, 100, 120);
sf::CircleShape cs(2, 4);
cs.setPosition(100, 120);
window.draw(cs);
window_loop(window);
}