当前位置: 首页>>代码示例>>C++>>正文


C++ Pattern::init方法代码示例

本文整理汇总了C++中Pattern::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::init方法的具体用法?C++ Pattern::init怎么用?C++ Pattern::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pattern的用法示例。


在下文中一共展示了Pattern::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Pattern

Pattern *Pattern::create(string pLineFrameFile){
    Pattern *ret = new Pattern();
    if(ret && ret->init(pLineFrameFile)){
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);
    return nullptr;
}
开发者ID:BerwinGitHub,项目名称:GLDemo,代码行数:9,代码来源:Pattern.cpp

示例2: initX

void initX(int argc, char* argv[], XInfo& xinfo) {
    XSizeHints hints;
    unsigned long background, foreground;
    
    /*
     * Display opening uses the DISPLAY  environment variable.
     * It can go wrong if DISPLAY isn't set, or you don't have permission.
     */
    xinfo.display = XOpenDisplay( "" );
    if ( !xinfo.display ) {
        error( "Can't open display." );
    }
    
    /*
     * Find out some things about the display you're using.
     */
    xinfo.screen = DefaultScreen( xinfo.display );
    foreground = WhitePixel( xinfo.display, xinfo.screen );
    background = BlackPixel( xinfo.display, xinfo.screen );
    
    /*
     * Set up hints and properties for the window manager, and open a window.
     * Arguments to XCreateSimpleWindow :
     *                 display - the display on which the window is opened
     *                 parent - the parent of the window in the window tree
     *                 x,y - the position of the upper left corner
     *                 width, height - the size of the window
     *                 Border - the width of the window border
     *                 foreground - the colour of the window border
     *                 background - the colour of the window background.
     * Arguments to XSetStandardProperties :
     *                 display - the display on which the window exists
     *                 window - the window whose properties are set
     *                 Hello1 - the title of the window
     *                 Hello2 - the title of the icon
     *                 none - a pixmap for the icon
     *                 argv, argc - a comand to run in the window
     *                 hints - sizes to use for the window.
     */
    hints.x = 100;
    hints.y = 100;
    hints.width = 800;
    hints.height = 600;
    hints.flags = PPosition | PSize;
    xinfo.window = XCreateSimpleWindow( xinfo.display, DefaultRootWindow( xinfo.display ),
                                       hints.x, hints.y, hints.width, hints.height,
                                       Border, foreground, background );
    XSetStandardProperties( xinfo.display, xinfo.window, "Lunar Landing", "Lunar Landing", None,
                           argv, argc, &hints );
    //initiate all the terrain and pattern.
    pattern.init(3, (int)hints.width, (int)hints.height,4);
    /*
     * Get a graphics context and set the drawing colours.
     * Arguments to XCreateGC
     *           display - which uses this GC
     *           window - which uses this GC
     *           GCflags - flags which determine which parts of the GC are used
     *           GCdata - a struct that fills in GC data at initialization.
     */
    int i = 0;
    xinfo.gc[i] = XCreateGC(xinfo.display, xinfo.window, 0, 0);
    XSetForeground(xinfo.display, xinfo.gc[i], BlackPixel(xinfo.display, xinfo.screen));
    XSetBackground(xinfo.display, xinfo.gc[i], WhitePixel(xinfo.display, xinfo.screen));
    XSetFillStyle(xinfo.display, xinfo.gc[i], FillSolid);
    XSetLineAttributes(xinfo.display, xinfo.gc[i],
                       1, LineSolid, CapButt, JoinRound);
    
    // Reverse Video
    i = 1;
    xinfo.gc[i] = XCreateGC(xinfo.display, xinfo.window, 0, 0);
    XSetForeground(xinfo.display, xinfo.gc[i], WhitePixel(xinfo.display, xinfo.screen));
    XSetBackground(xinfo.display, xinfo.gc[i], BlackPixel(xinfo.display, xinfo.screen));
    XSetFillStyle(xinfo.display, xinfo.gc[i], FillSolid);
    XSetLineAttributes(xinfo.display, xinfo.gc[i],
                       1, LineSolid, CapButt, JoinRound);
    
    int depth = DefaultDepth(xinfo.display, DefaultScreen(xinfo.display));
    xinfo.pixmap = XCreatePixmap(xinfo.display, xinfo.window, hints.width, hints.height, depth);
    xinfo.width = hints.width;
    xinfo.height = hints.height;

    // Tell the window manager what input events you want.
    // XSelectInput( xinfo.display, xinfo.window, KeyPressMask);
    
    /*
     * Put the window on the screen.
     */
    XMapRaised( xinfo.display, xinfo.window );
    
    XFlush(xinfo.display);
    sleep(2);   // let server get set up before sending drawing commands
}
开发者ID:y88huang,项目名称:Game-of-lunar-landing,代码行数:92,代码来源:main.cpp

示例3: main

int main (void)
{
#ifndef ONLINE_JUDGE
	freopen ("T1257.in", "r", stdin);
	freopen ("T1257.out", "w", stdout);
#endif

	scanf ("%d", &n);
	getline (cin, line);
	solve.init(n);

	for (int i=0; i<n; ++i){
		getline (cin, line);
		solve.addPattern(line);
	}

	while (getline (cin, line)){
		ans.clear();
		ans.reserve(2*line.size());

		int beg_line=0;
		int beg_word=-1;
		bool inword=false;

		for (int i=0; i<line.size(); ++i){
			if (!inword && isalpha(line[i])){
				inword=true;
				beg_word=i;
			}
			else if (inword && !isalpha(line[i])){
				inword=false;
				beg_word=-1;
			}

			if (i-beg_line==39){
				// work
				if(!inword){
					ans+=line.substr(beg_line, 40)+"\n";
					beg_line=i+1;
				}
				else{
					int end_word=i;
					while (end_word<line.size() && isalpha(line[end_word]))
						++end_word;
					if (i==end_word-1){
						ans+=line.substr(beg_line, end_word-beg_line);
						beg_line=end_word;
						if (end_word<line.size())
							ans+="\n";
					}
					else{
						int len=i-beg_word;
						i=end_word-1;
						ans+=line.substr(beg_line, beg_word-beg_line);

						string word = line.substr(beg_word, end_word-beg_word);
						int w = solve.find (word, len);
						
						if (w==-1){
							ans+="\n"/*+word*/;
							beg_line=beg_word;
						}
						else{
							ans+=word.substr(0, w)+"-\n"/*+word.substr(w)*/;
							beg_line=beg_word+w;
						}
					}

					inword=false;
					beg_word=-1;

				}
			}

			// end for
		}

		if (beg_line<line.size()){
			ans+=line.substr(beg_line);
		}

		cout << ans << "\n";

		// end while
	}

	return 0;
}
开发者ID:DrhF,项目名称:ACM,代码行数:88,代码来源:T1257.cpp


注:本文中的Pattern::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。