kk=0;x2=m_pointX[in][pnt];y2=m_pointY[in][pnt];w2=m_pressure[in][pnt];w2=Max(1,w2);v2=(w2*1732/2000);u2=Max(1,w2/2);dir=0;for(;pnt>0;){x1=m_pointX[in][pnt-1];y1=m_pointY[in][pnt-1];w1=m_pressure[in][pnt-1];w1=Max(1,w1);v1=(w1*1732/2000);u1=Max(1,w1/2);qq=atan2((double)y2-y1,(double)x2-x1);for(;qq<0;)qq+=2*aPI;dir=(int)((qq+pi8)/pi8/2);switch(dir){//no break in following linescase0:asSetPoint(qp,kk,x1,y1+w1);if(++kk==7)break;case1:asSetPoint(qp,kk,x1-u1,y1+v1);if(++kk==7)break;case2:asSetPoint(qp,kk,x1-v1,y1+u1);if(++kk==7)break;case3:asSetPoint(qp,kk,x1-w1,y1);if(++kk==7)break;case4:asSetPoint(qp,kk,x1-v1,y1-u1);if(++kk==7)break;case5:asSetPoint(qp,kk,x1-u1,y1-v1);if(++kk==7)break;case6:asSetPoint(qp,kk,x1,y1-w1);if(++kk==7)break;case7:asSetPoint(qp,kk,x1+u1,y1-v1);if(++kk==7)break;case8:asSetPoint(qp,kk,x1+v1,y1-u1);if(++kk==7)break;case9:asSetPoint(qp,kk,x1+w1,y1);if(++kk==7)break;case10:asSetPoint(qp,kk,x1+v1,y1+u1);if(++kk==7)break;default:asSetPoint(qp,kk,x1+u1,y1+v1);if(++kk==7)break;asSetPoint(qp,kk,x1,y1+w1);if(++kk==7)break;asSetPoint(qp,kk,x1-u1,y1+v1);if(++kk==7)break;asSetPoint(qp,kk,x1-v1,y1+u1);if(++kk==7)break;asSetPoint(qp,kk,x1-w1,y1);if(++kk==7)break;asSetPoint(qp,kk,x1-v1,y1-u1);if(++kk==7)break;asSetPoint(qp,kk,x1-u1,y1-v1);if(++kk==7)break;asSetPoint(qp,kk,x1,y1-w1);if(++kk==7)break;}break;}switch(dir){//no break in following linescase0:asSetPoint(qp,kk,x2,y2-w2);if(++kk==14)break;case1:asSetPoint(qp,kk,x2+u2,y2-v2);if(++kk==14)break;case2:asSetPoint(qp,kk,x2+v2,y2-u2);if(++kk==14)break;case3:asSetPoint(qp,kk,x2+w2,y2);if(++kk==14)break;case4:asSetPoint(qp,kk,x2+v2,y2+u2);if(++kk==14)break;case5:asSetPoint(qp,kk,x2+u2,y2+v2);if(++kk==14)break;case6:asSetPoint(qp,kk,x2,y2+w2);if(++kk==14)break;case7:asSetPoint(qp,kk,x2-u2,y2+v2);if(++kk==14)break;case8:asSetPoint(qp,kk,x2-v2,y2+u2);if(++kk==14)break;case9:asSetPoint(qp,kk,x2-w2,y2);if(++kk==14)break;case10:asSetPoint(qp,kk,x2-v2,y2-u2);if(++kk==14)break;default:asSetPoint(qp,kk,x2-u2,y2-v2);if(++kk==14)break;asSetPoint(qp,kk,x2,y2-w2);if(++kk==14)break;asSetPoint(qp,kk,x2+u2,y2-v2);if(++kk==14)break;asSetPoint(qp,kk,x2+v2,y2-u2);if(++kk==14)break;asSetPoint(qp,kk,x2+w2,y2);if(++kk==14)break;asSetPoint(qp,kk,x2+v2,y2+u2);if(++kk==14)break;asSetPoint(qp,kk,x2+u2,y2+v2);if(++kk==14)break;asSetPoint(qp,kk,x2,y2+w2);if(++kk==14)break;}}

gintcb_button_release_event(GtkWidget*widget,GdkEventMotion*event,gpointeruser_data){isDown=0;{intin,pnt;//Draw line on offscreen cairo_t*qp=cairo_create(offscreen);cairo_set_line_width(qp,0.);cairo_set_source_rgb(qp,0.,1.,0.);cairo_new_path(qp);

kk=0;x2=m_pointX[in][pnt];y2=m_pointY[in][pnt];w2=m_pressure[in][pnt];w2=Max(1,w2);v2=(w2*1732/2000);u2=Max(1,w2/2);dir=0;for(;pnt>0;){x1=m_pointX[in][pnt-1];y1=m_pointY[in][pnt-1];if(Abs(y1-y2)>m_bounds.bottom/2)break;w1=m_pressure[in][pnt-1];w1=Max(1,w1);v1=(w1*1732/2000);u1=Max(1,w1/2);qq=atan2((double)y2-y1,(double)x2-x1);for(;qq<0;)qq+=2*aPI;dir=(int)((qq+pi8)/pi8/2);switch(dir){//no break in following linescase0:asSetPoint(kk,x1,y1+w1);if(++kk==7)break;case1:asSetPoint(kk,x1-u1,y1+v1);if(++kk==7)break;case2:asSetPoint(kk,x1-v1,y1+u1);if(++kk==7)break;case3:asSetPoint(kk,x1-w1,y1);if(++kk==7)break;case4:asSetPoint(kk,x1-v1,y1-u1);if(++kk==7)break;case5:asSetPoint(kk,x1-u1,y1-v1);if(++kk==7)break;case6:asSetPoint(kk,x1,y1-w1);if(++kk==7)break;case7:asSetPoint(kk,x1+u1,y1-v1);if(++kk==7)break;case8:asSetPoint(kk,x1+v1,y1-u1);if(++kk==7)break;case9:asSetPoint(kk,x1+w1,y1);if(++kk==7)break;case10:asSetPoint(kk,x1+v1,y1+u1);if(++kk==7)break;default:asSetPoint(kk,x1+u1,y1+v1);if(++kk==7)break;asSetPoint(kk,x1,y1+w1);if(++kk==7)break;asSetPoint(kk,x1-u1,y1+v1);if(++kk==7)break;asSetPoint(kk,x1-v1,y1+u1);if(++kk==7)break;asSetPoint(kk,x1-w1,y1);if(++kk==7)break;asSetPoint(kk,x1-v1,y1-u1);if(++kk==7)break;asSetPoint(kk,x1-u1,y1-v1);if(++kk==7)break;asSetPoint(kk,x1,y1-w1);if(++kk==7)break;}break;}switch(dir){//no break in following linescase0:asSetPoint(kk,x2,y2-w2);if(++kk==14)break;case1:asSetPoint(kk,x2+u2,y2-v2);if(++kk==14)break;case2:asSetPoint(kk,x2+v2,y2-u2);if(++kk==14)break;case3:asSetPoint(kk,x2+w2,y2);if(++kk==14)break;case4:asSetPoint(kk,x2+v2,y2+u2);if(++kk==14)break;case5:asSetPoint(kk,x2+u2,y2+v2);if(++kk==14)break;case6:asSetPoint(kk,x2,y2+w2);if(++kk==14)break;case7:asSetPoint(kk,x2-u2,y2+v2);if(++kk==14)break;case8:asSetPoint(kk,x2-v2,y2+u2);if(++kk==14)break;case9:asSetPoint(kk,x2-w2,y2);if(++kk==14)break;case10:asSetPoint(kk,x2-v2,y2-u2);if(++kk==14)break;default:asSetPoint(kk,x2-u2,y2-v2);if(++kk==14)break;asSetPoint(kk,x2,y2-w2);if(++kk==14)break;asSetPoint(kk,x2+u2,y2-v2);if(++kk==14)break;asSetPoint(kk,x2+v2,y2-u2);if(++kk==14)break;asSetPoint(kk,x2+w2,y2);if(++kk==14)break;asSetPoint(kk,x2+v2,y2+u2);if(++kk==14)break;asSetPoint(kk,x2+u2,y2+v2);if(++kk==14)break;asSetPoint(kk,x2,y2+w2);if(++kk==14)break;}}

CGContextSaveGState(ctx);// because SetContextStateForDrawObject is doing what it says it willCGContextSetFillColorSpace(ctx,genericColorSpace);CGContextSetStrokeColor(ctx,(CGFloat*)&blackColor);CGContextSetFillColor(ctx,(CGFloat*)&blackColor);CGContextBeginPath(ctx);// reset current path to emptyfor(in=0;in<m_index;in++){m_path=CGPathCreateMutable();for(pnt=0;pnt<m_points[in];pnt++){MakeBrushLine(in,pnt);}CGContextAddPath(ctx,m_path);}CGContextDrawPath(ctx,kCGPathFillStroke);CGContextRestoreGState(ctx);// undo the changes for the specific obj drawing}

// Create a window. "MainWindow" is the name of the window object. This name is set in // InterfaceBuilder when the nib is created.err=CreateWindowFromNib(sNibRef,CFSTR("MainWindow"),&window);require_noerr(err,CantCreateWindow);

// Install a command handler on the window. We don't use this handler yet, but nearly all// Carbon apps will need to handle commands, so this saves everyone a little typing.InstallWindowEventHandler(window,GetWindowEventHandlerUPP(),GetEventTypeCount(kWindowEvents),kWindowEvents,window,NULL);// Position new windows in a staggered arrangement on the main screenRepositionWindow(window,NULL,kWindowCascadeOnMainScreen);GetWindowBounds(window,kWindowContentRgn,&m_bounds);

// Bind it to the window's contentViewHIRectbounds;HIViewFindByID(HIViewGetRoot(window),kHIViewWindowContentID,&contentView);HIViewAddSubview(contentView,theScrollView);HIViewGetBounds(contentView,&bounds);HIViewSetFrame(theScrollView,&bounds);HIViewSetVisible(theScrollView,true);