Trace: » threshold » convolution » edgedetection » notes » notes » notes » color_quick_draw » basics » copying_pixels_between_color_graphics_ports » drawing

Drawing

To create a basic QuickDraw drawing environment, you generally

All graphics operations are performed in graphics ports. Before a basic graphics port can be used, it must be allocated and initialized with the OpenPort procedure. Normally, you don’t call OpenPort yourself. In most cases your application draws into a window you’ve created with the GetNewWindow or NewWindow function (or, for color windows, GetNewCWindow or NewCWindow), or it draws into an offscreen graphics world created with the NewGWorld function.

These Window Manager functions or the NewGWorld function call OpenPort to create a basic graphics port. The GetNewWindow function returns a window pointer, which is defined to be a pointer to graphics port. You can allow GetNewWindow to allocate the memory for your window record and its associated basic graphics port. You can maintain more control over memory use, however, by allocating the memory yourself from a block allocated for such purposes during your own initialization routine, and then passing the pointer to GetNewWindow.

Likewise:

// first creating a rect and then passing its address to the newCWindow function. NewCWindow return a pointer.
SetRect(&windRect,100,100,740,580);
	InitCursor();
 
	ourWindow = NewCWindow( 0L, &windRect,  "\pAdjust Brightness", true, noGrowDocProc,(WindowPtr)-1L, true, 0L ); 
if ( ourWindow == nil )	ExitToShell();
	
	ShowWindow( ourWindow ); // showing our window.
	SetPortWindowPort( ourWindow );
	SetRect(&windRect,0,0,640,480);
	error =NewGWorld(&ourBuffer, 32, &windRect, nil, nil,0 ); // creating our offscreen worlds