//--------------------------------------------------
ofBuffer::Line ofBuffer::Lines::begin(){
	return Line(_begin,_end);
}
//--------------------------------------------------
ofBuffer::Line ofBuffer::Lines::end(){
	return Line(_end,_end);
}
Exemple #3
0
void
whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_FREESEL:
            if (ptSP == 0)
                newReversible();
            ptSP++;
            if (ptSP % 1024 == 0)
                ptStack = HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, ptStack, sizeof(POINT) * (ptSP + 1024));
            ptStack[ptSP].x = max(0, min(x, imgXRes));
            ptStack[ptSP].y = max(0, min(y, imgYRes));
            resetToU1();
            Poly(hdc, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE);
            break;
        case TOOL_RECTSEL:
        {
            POINT temp;
            resetToU1();
            temp.x = max(0, min(x, imgXRes));
            temp.y = max(0, min(y, imgYRes));
            rectSel_dest[0] = rectSel_src[0] = min(start.x, temp.x);
            rectSel_dest[1] = rectSel_src[1] = min(start.y, temp.y);
            rectSel_dest[2] = rectSel_src[2] = max(start.x, temp.x) - min(start.x, temp.x);
            rectSel_dest[3] = rectSel_src[3] = max(start.y, temp.y) - min(start.y, temp.y);
            RectSel(hdc, start.x, start.y, temp.x, temp.y);
            break;
        }
        case TOOL_RUBBER:
            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, fg, 1);
            break;
        case TOOL_BRUSH:
            Brush(hdc, last.x, last.y, x, y, fg, brushStyle);
            break;
        case TOOL_AIRBRUSH:
            Airbrush(hdc, x, y, fg, airBrushWidth);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
            break;
        case TOOL_BEZIER:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            switch (pointSP)
            {
                case 1:
                    Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg,
                         lineWidth);
                    break;
                case 2:
                    Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], fg, lineWidth);
                    break;
                case 3:
                    Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], fg, lineWidth);
                    break;
            }
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            if (pointSP + 1 >= 2)
                Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE);
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
    }

    last.x = x;
    last.y = y;
}
Exemple #4
0
void
whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_RUBBER:
            Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, bg, 1);
            break;
        case TOOL_BRUSH:
            Brush(hdc, last.x, last.y, x, y, bg, brushStyle);
            break;
        case TOOL_AIRBRUSH:
            Airbrush(hdc, x, y, bg, airBrushWidth);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, bg, lineWidth);
            break;
        case TOOL_BEZIER:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            switch (pointSP)
            {
                case 1:
                    Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, bg,
                         lineWidth);
                    break;
                case 2:
                    Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], bg, lineWidth);
                    break;
                case 3:
                    Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], bg, lineWidth);
                    break;
            }
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            if (pointSP + 1 >= 2)
                Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE);
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
            break;
    }

    last.x = x;
    last.y = y;
}
Exemple #5
0
void CRenderer::Line(int startx, int starty, int endx, int endy, int color){
	Vector start(startx,starty);
	Vector end(endx,endy);
	Line(start,end,color);
}
Exemple #6
0
void MDrawContextR2::HLine(int x, int y, int len)
{
	Line(x, y, x+len, y);
}
Exemple #7
0
void GlyphPainter::LineOp(const Pointf& p, bool)
{
	Line(p);
}
Exemple #8
0
void CSlider::Draw(HDC dc)
{
	CWnd::Draw(dc);

	activated&=focused;
	MouseButtonDown&=focused;

	int h2=h/2;

	// Hintergrund
	{
		HBRUSH brush=CreateSolidBrush(focused?RGB(0,64,92):(canfocus?RGB(0,0,0):RGB(64,64,64)))
			,oldbrush=(HBRUSH)SelectObject(dc,brush);
		SelectObject(dc,GetStockObject(NULL_PEN));

		Rectangle(dc,0,0,w,h2+1);

		SelectObject(dc,oldbrush);
		DeleteObject(brush);


		HPEN pen=CreatePen(PS_SOLID,1,RGB(64,64,64)),oldpen=(HPEN)SelectObject(dc,pen);

		Line(dc,0,0,w-1,0);
		Line(dc,0,0,0,h2-1);

		SelectObject(dc,oldpen);
		DeleteObject(pen);

		pen=CreatePen(PS_SOLID,1,RGB(192,192,192));
		SelectObject(dc,pen);

		Line(dc,w-1,0,w-1,h2-1);
		Line(dc,0,h2-1,w-1,h2-1);

		SelectObject(dc,oldpen);
		DeleteObject(pen);
	}


	// Beschriftung
	{
		HFONT font=CreateFont(h-h2-2,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,"MS SansSerif"),oldfont=(HFONT)SelectObject(dc,font);
		
		SetTextColor(dc,focused?RGB(255,255,255):RGB(192,192,192));
		RECT r={0,0+h2-1,w-1,h-1};

		SetBkMode(dc,TRANSPARENT);

		CHAR c[10];
		sprintf(&c[0],"%.2f",iLeft);
		DrawText(dc,&c[0],strlen(&c[0]),&r,DT_LEFT);

		sprintf(&c[0],"%.2f",iRight);
		DrawText(dc,&c[0],strlen(&c[0]),&r,DT_RIGHT);

		SetTextColor(dc,focused?RGB(64,192,255):RGB(192,192,192));
		sprintf(&c[0],"%.2f",Position);
		DrawText(dc,&c[0],strlen(&c[0]),&r,DT_CENTER|DT_SINGLELINE);

		SelectObject(dc,oldfont);
		DeleteObject(font);
	}

	// Knopf
	{
		HPEN pen=CreatePen(PS_SOLID,1,focused?RGB(255,255,255):canfocus?RGB(0,192,255):RGB(160,160,160)),oldpen=(HPEN)SelectObject(dc,pen);
		HBRUSH brush=CreateSolidBrush(canfocus?focused?activated?RGB(0,255,192):RGB(0,192,255):RGB(0,128,192):RGB(192,192,192)),oldbrush=(HBRUSH)SelectObject(dc,brush);

		const int breite=h2-2;
		const int hoehe=h2-2;

		int links=int(2+((w-2-breite)*(Position-iLeft))/(iRight-iLeft));

		Rectangle(dc,links-1,1,links+breite-1,hoehe+1);

		if (activated)
		{
			const int x1=links+1;
			const int x2=links+breite-4;
			const int xm=(x2-x1)/2+x1;
			const int y1=3+1;
			const int y2=hoehe-2-1;
			const int ym=(y2-y1)/2+y1;
			HPEN pen=CreatePen(PS_SOLID,2,RGB(255,0,0)),oldpen=(HPEN)SelectObject(dc,pen);

			Line(dc,xm-1,y1,x1,ym);
			Line(dc,x1,ym,xm-1,y2);

			Line(dc,xm+1,y1,x2,ym);
			Line(dc,x2,ym,xm+1,y2);

			SelectObject(dc,oldpen);
			DeleteObject(pen);
		}

		SelectObject(dc,oldbrush);
		SelectObject(dc,oldpen);
		DeleteObject(brush);
		DeleteObject(pen);
	}
}
Exemple #9
0
// Will draw in center of view rectangle in the current QD graphics context;
// modeled after fps display.
// It won't try to clip the ends of the lines.
bool Crosshairs_Render(Rect &ViewRect)
{
  if (!_Crosshairs_IsActive) {
    return _Crosshairs_IsActive;
  }

  // Get the crosshair data
  CrosshairData &Crosshairs = GetCrosshairData();

  // Push previous state
  PenState OldPen;
  RGBColor OldBackColor, OldForeColor;

  GetPenState(&OldPen);
  GetBackColor(&OldBackColor);
  GetForeColor(&OldForeColor);

  // Get ready to draw the crosshairs
  PenNormal();

  // Drawing color
  RGBForeColor(&Crosshairs.Color);

  // Get the center location from the view rectangle
  // Shift it down one, so that even line widths can come out right.
  short XCen = ((ViewRect.left + ViewRect.right) >> 1) - 1;
  short YCen = ((ViewRect.top + ViewRect.bottom) >> 1) - 1;

  // Separate for X and Y; the points are three on top/left and three on top/right:
  // Line-split position
  // Octagon vertex (half-way)
  // Farthest extent
  short OctaPoints[2][6];
  short Len;

  switch(Crosshairs.Shape)
  {
  case CHShape_RealCrosshairs:

    PenSize(1,Crosshairs.Thickness);

    // Left
    MoveTo(XCen-Crosshairs.FromCenter+Crosshairs.Thickness-1,YCen);
    Line(-Crosshairs.Length,0);

    // Right
    MoveTo(XCen+Crosshairs.FromCenter,YCen);
    Line(Crosshairs.Length,0);

    PenSize(Crosshairs.Thickness,1);

    // Top
    MoveTo(XCen,YCen-Crosshairs.FromCenter+Crosshairs.Thickness-1);
    Line(0,-Crosshairs.Length);

    // Bottom
    MoveTo(XCen,YCen+Crosshairs.FromCenter);
    Line(0,Crosshairs.Length);

    break;

  case CHShape_Circle:
    // This will really be an octagon, for OpenGL-rendering convenience

    // Precalculate the line endpoints, for convenience

    Len = Crosshairs.Length;
    OctaPoints[0][0] = XCen - Len;
    OctaPoints[0][5] = XCen + Len;
    OctaPoints[1][0] = YCen - Len;
    OctaPoints[1][5] = YCen + Len;

    Len = Len/2;
    OctaPoints[0][1] = XCen - Len;
    OctaPoints[0][4] = XCen + Len;
    OctaPoints[1][1] = YCen - Len;
    OctaPoints[1][4] = YCen + Len;

    Len = MIN(Len,Crosshairs.FromCenter);
    OctaPoints[0][2] = XCen - Len;
    OctaPoints[0][3] = XCen + Len;
    OctaPoints[1][2] = YCen - Len;
    OctaPoints[1][3] = YCen + Len;

    // We need to do 12 line segments, so we do them in 2*2*3 fashion

    for (int ix=0; ix<2; ix++)
    {
      int ixi = (ix > 0) ? 5 : 0;
      int ixid = (ix > 0) ? -1 : 1;
      for (int iy=0; iy<2; iy++)
      {
        int iyi = (iy > 0) ? 5 : 0;
        int iyid = (iy > 0) ? -1 : 1;

        // Vertical
        PenSize(Crosshairs.Thickness,1);
        MoveTo(OctaPoints[0][ixi],OctaPoints[1][iyi+2*iyid]);
        LineTo(OctaPoints[0][ixi],OctaPoints[1][iyi+iyid]);

        // Diagonal
        PenSize(Crosshairs.Thickness,Crosshairs.Thickness);
        LineTo(OctaPoints[0][ixi+ixid],OctaPoints[1][iyi]);

        // Horizontal
        PenSize(1,Crosshairs.Thickness);
        LineTo(OctaPoints[0][ixi+2*ixid],OctaPoints[1][iyi]);
      }
    }

    break;
  }

  // Pop previous state
  SetPenState(&OldPen);
  RGBBackColor(&OldBackColor);
  RGBForeColor(&OldForeColor);

  return _Crosshairs_IsActive;
}
Exemple #10
0
void GlyphPainter::Move(const Pointf& p)
{
	glyph.Add((float)1e31);
	Line(p);
	move = pos;
}
Exemple #11
0
		Lines() : space_advance(0), lines(1, Line()) {}
Exemple #12
0
void CrossFadeAnimation::addLine(Part was, Part now) {
	_lines.push_back(Line(std::move(was), std::move(now)));
}
Exemple #13
0
void Tracker::append_to_db(int last_block, unsigned int time_len) {
	
	*db << Line(first_block, last_block, reboot_id, time_len) << flush;
}
Line Line::operator/(float factor)
{
	return Line(axisProjections / factor);
}
Exemple #15
0
void GlyphPainter::CloseOp()
{
	if(move != pos && !IsNull(move))
		Line(move);
}
Exemple #16
0
void CList::Draw(HDC dc)
{
	activated&=focused;
	{	// Rahmen malen
		HPEN pen=CreatePen(PS_SOLID,1,focused?RGB(255,255,255):RGB(128,128,128)),oldpen;
		oldpen=(HPEN)SelectObject(dc,pen);

		HBRUSH brush=CreateSolidBrush(focused?RGB(32,32+12,32+24):RGB(8,16,32)),oldbrush;

		oldbrush=(HBRUSH)SelectObject(dc,brush);
	
		Rectangle(dc,0,0,w,h);

		SelectObject(dc,GetStockObject(BLACK_BRUSH));
		Rectangle(dc,w-listscrollbar_width,0,w,h);
		Line(dc,w-listscrollbar_width,0,w-listscrollbar_width,h);

		SelectObject(dc,oldpen);
		DeleteObject(pen);
		SelectObject(dc,oldbrush);
		DeleteObject(brush);
	}
	if (numstrings>0)
	{	// Scrollbar malen
		SelectObject(dc,GetStockObject(WHITE_PEN));
		HBRUSH brush=CreateSolidBrush((activated||scrolling)?RGB(64,192,214):RGB(64,92,128)),oldbrush;
		oldbrush=(HBRUSH)SelectObject(dc,brush);

		float hoehe=(h-2.0f)*(float)VisibleLines()/(float)numstrings;
		if (VisibleLines()>numstrings)
			hoehe=(h-2.0f);

		float y=1.0f;
		if (numstrings!=VisibleLines()+1)y=1.0f+starty*(float(h-hoehe-2.0f)/float(numstrings-VisibleLines()-1));


		Rectangle(dc,w-listscrollbar_width+1,(int)y,w-1,int(y+hoehe));

		SelectObject(dc,oldbrush);
		DeleteObject(brush);
	}

	if (strings)
	{	// Listenelemente anzeigen
		int y=5;

		HFONT font=CreateFont(listitem_height-1,0,0,0,FW_THIN,0,0,0,0,0,0,0,0,"Arial"),oldfont;

		oldfont=(HFONT)SelectObject(dc,font);
		SetBkMode(dc,TRANSPARENT);

		HBRUSH brush=CreateSolidBrush(activated?RGB(64,192,214):RGB(64,92,128));
		SelectObject(dc,GetStockObject(NULL_PEN));

		SetTextColor(dc,RGB(0,192,255));

		for (int i=starty;i<numstrings;i++)
		{
			RECT r={1,y,w-listscrollbar_width,y+listitem_height};
			if (i==selected)
			{	// Aktueller Eintrag ist der Auserwählte
				SetTextColor(dc,RGB(255,255,255));
				FillRect(dc,&r,brush);
				Sleep(1);
			}
			r.left+=5;

			DrawText(dc,strings[i],strlen(strings[i]),&r,DT_VCENTER);

			if (i==selected)
			{
				SetTextColor(dc,RGB(0,192,255));
			}

			y+=listitem_height;
			if (i>=starty+VisibleLines())break;
		}

		SelectObject(dc,oldfont);
		DeleteObject(brush);
		DeleteObject(font);
	}
}
Exemple #17
0
Polyline::operator Line() const
{
    if (this->points.size() > 2) CONFESS("Can't convert polyline with more than two points to a line");
    return Line(this->points.front(), this->points.back());
}
Exemple #18
0
int main(int argc,char **argv) {
	if(argc<2) return 0;
	count=atoi(argv[1]);

Line("template <class AccStruct> template <class Output>");
Line("void BIHTree<AccStruct>:: TraverseQuad@(const Vec3q *rOrigin,const Vec3q *tDir,floatq *out,i32x4 *object,TreeStats *tstats,int dirMask) const {");
List("	floatq maxD[@]={#};","out[#]");
Line(" ");
Line("		TreeStats stats;");
Line("		");
Line("		stats.TracingPacket(4*@);");
Line("");
Line("		Vec3q invDir[@]={");
Blck("			VInv(Vec3q(tDir[#].x+0.000000000001f,tDir[#].y+0.000000000001f,tDir[#].z+0.000000000001f)),");
Line("		};");
Line("		floatq tinv[3][@]={");
List("			{#},","invDir[#].x");
List("			{#},","invDir[#].y");
List("			{#} };","invDir[#].z");
Line("		floatq torig[3][@]={");
List("			{#},",  "rOrigin[#].x");
List("			{#},",  "rOrigin[#].y");
List("			{#} };","rOrigin[#].z");
Line("");
Line("		int dSign[3]; FillDSignArray(dirMask,dSign);");
List("		floatq minRet[@]={#},tMin[@],tMax[@];","maxD[#]");
Blck("		tMin[#]=ConstEpsilon<floatq>(); tMax[#]=Min(maxD[#],minRet[#]);");
Line("");
Line("		floatq fStackBegin[@*2*(maxLevel+2)],*fStack=fStackBegin;");
Line("		u32 nStackBegin[maxLevel+2],*nStack=nStackBegin;");
Line("");
Line("		{");
List("			Vec3q ttMin[@]={#};","(Vec3q(pMin)-rOrigin[#])*invDir[#]");
List("			Vec3q ttMax[@]={#};","(Vec3q(pMax)-rOrigin[#])*invDir[#]");
Line("");
List("			if(dSign[0]) {#;}","Swap(ttMin[#].x,ttMax[#].x)");
List("			if(dSign[1]) {#;}","Swap(ttMin[#].y,ttMax[#].y)");
List("			if(dSign[2]) {#;}","Swap(ttMin[#].z,ttMax[#].z)");
Line("");
Blck("			tMax[#]=Min(Min(ttMax[#].x,ttMax[#].y),tMax[#]);");
Blck("			tMax[#]=Min(ttMax[#].z,tMax[#]);");
Line("			");
Blck("			tMin[#]=Max(Max(ttMin[#].x,ttMin[#].y),tMin[#]);");
Blck("			tMin[#]=Max(ttMin[#].z,tMin[#]);");
Line("		}");
Line("		ObjectIdxBuffer<4> mailbox;");
Line("");
Line("		const BIHNode *node0=&nodes[0];");
Line("		int idx=0;");
Line("");
Line("		while(true) {");
Line("			stats.LoopIteration();");
Line("");
Line("			if(idx&BIHNode::leafMask) {");
Line("				idx&=BIHNode::idxMask;");
Line("");
Line("				if(!mailbox.Find(idx)) {");
Line("					mailbox.Insert(idx);");
Line("					stats.Intersection(@);");
Line("");
Line("					const Element &obj=objects[idx];");
Line("");
Line("					Vec3q tvec[@]; {");
Line("						Vec3q a(obj.a.x,obj.a.y,obj.a.z);");
Blck("						tvec[#]=rOrigin[#]-a;");
Line("					}");
Line("					floatq u[@],v[@]; {");
Line("						Vec3q ba(obj.ba.x,obj.ba.y,obj.ba.z),ca(obj.ca.x,obj.ca.y,obj.ca.z);");
Blck("						u[#]=tDir[#]|(ba^tvec[#]); v[#]=tDir[#]|(tvec[#]^ca);");
Line("					}");
Line("");
Line("					Vec3p nrm=obj.Nrm();");
Line("					floatq nrmLen=floatq( ((float*)&obj.ca)[3] );");

{ int tCount=count; for(count=0;count<tCount;count++) {
Line("					{");
Line("						floatq det=tDir[@]|nrm;");
Line("						f32x4b mask=Min(u[@],v[@])>=0.0f&&u[@]+v[@]<=det*nrmLen;");
Line("						if(ForAny(mask)) {");
Line("							floatq dist=Condition(mask,-(tvec[@]|nrm)/det,minRet[@]);");
Line("							mask=dist<minRet[@]&&dist>0.0f;");
Line("							minRet[@]=Condition(mask,Output::type==otShadow?0.00001f:dist,minRet[@]);");
Line("							if(Output::objectIndexes) {");
Line("								object[@]=Condition(i32x4b(mask),i32x4(objectId),object[@]);");
Line("								element[@]=Condition(i32x4b(mask),i32x4(idx),element[@]);");
Line("							}");
Line("							stats.IntersectPass();");
Line("						} else stats.IntersectFail();");
Line("					}");
 } }

Line("				}");
Line("");
Line("			POP_STACK:");
Line("				if(fStack==fStackBegin) break;");
Line("");
Line("				fStack-=2*@;");
Blck("				tMin[#]=fStack[#];");
Blck("				tMax[#]=Min(fStack[@+#],minRet[#]);");
Line("				--nStack;");
Line("				idx=*nStack;");
Line("				continue;");
Line("			}");
Line("");
Line("			const BIHNode *node=node0+(idx&BIHNode::idxMask);");
Line("			int axis=node->Axis();");
Line("			int nidx=dSign[axis];");
Line("			floatq near[@],far[@]; {");
Line("				floatq *start=torig[axis],*inv=tinv[axis];");
Line("");
Line("				float tnear=node->ClipLeft(),tfar=node->ClipRight();");
Line("				if(nidx) Swap(tnear,tfar);");
Line("");
Blck("				near[#]=Min( (floatq(tnear)-start[#])*inv[#], tMax[#]);");
Blck("				far [#]=Max( (floatq(tfar) -start[#])*inv[#], tMin[#]);");
Line("			}");
Line("");
List("			f32x4b test1=#;","tMin[#]>near[#]","&&");
List("			f32x4b test2=#;","tMax[#]<far [#]","&&");
Line("");
Line("			if(ForAll(test1)) {");
Line("				if(ForAll(test2)) goto POP_STACK;");
Line("");
Blck("				tMin[#]=far[#];");
Line("				idx=node->val[nidx^1];");
Line("				continue;");
Line("			}");
Line("			if(ForAll(test2)) {");
Line("				if(ForAll(test1)) goto POP_STACK;");
Line("");
Blck("				tMax[#]=near[#];");
Line("				idx=node->val[nidx];");
Line("				continue;");
Line("			}");
Line("");
Blck("			fStack[#]=far[#];");
Blck("			fStack[@+#]=tMax[#];");
Line("			fStack+=@*2;");
Line("");
Line("			*nStack=node->val[nidx^1];");
Line("			nStack++;");
Line("");
Blck("			tMax[#]=near[#];");
Line("			");
Line("			idx=node->val[nidx];");
Line("		}");
Line("");
Line("		if(tstats) tstats->Update(stats);");
Blck("		out[#]=minRet[#];");
Line("}");


	return 0;
}
void CMainWnd::OnPaint()
{

	Object A{ 2.680795435464e+20, -1.531367579292792e+12, 0.0, 0.0, -1.923828617202e+3 * M_PI / 1.581035760 * sqrtl(5.1/19.9), 0.0, 0.0, 1.40491e+9 };
	Object B{ 1.2979296712296e+20, 3.19134145606896e+12, 0.0, 0.0, 4.009222934760e+3 * M_PI / 1.581035760 * sqrtl(5.1 / 19.9), 0.0, 0.0, 5.8422e+7 };
	CPaintDC dc(this);
	RECT rect;
	GetClientRect(&rect);
	long double x = rect.right; //Ширина окна
	long double y = rect.bottom; //Высота окна
	dc.FillSolidRect(0, 0, lrintl(x), lrintl(y), RGB(0, 0, 0));
	CPen Line(PS_SOLID, 1, RGB(255, 255, 255));
	CBrush Star1(RGB(255,255,255));
	CBrush Star2(RGB(0, 0, 0));
	CBrush BPlanetoid(RGB(0, 127, 127));
	CPen Planetoid(PS_SOLID, 1, RGB(0, 127, 127));
	CPen Background(PS_SOLID, 1, RGB(0, 0, 0));
	dc.SetTextColor(RGB(255, 255, 255));
	dc.TextOutW(5, 5, "Координаты планеты, а.е.");
	dc.TextOutW(5, 65, "Скорость планеты, км/с");
	long double h = 5.0e+4;
	long double max = 3.2e+12;

	dc.MoveTo(lrintl(x / 2 + y / 2.0*A.x / max), lrintl(y / 2.0*(1.0 - A.y / max)));
	for (long double t = 0; t < T; t += h){
		long double dx = B.x - A.x, dy = B.y - A.y;
		long double R = hypotl(dx, dy);
		long double cosinus = dx / R, sinus = dy / R;
		R *= R;
		// Сириус А
		A.ax = B.GM / R * cosinus;
		A.ay = B.GM / R * sinus;
		A.vx += h*A.ax;
		A.vy += h*A.ay;

		// Сириус Б
		B.ax = -A.GM / R * cosinus;
		B.ay = -A.GM / R * sinus;
		B.vx += h*B.ax;
		B.vy += h*B.ay;

		dx = Planet.x - A.x, dy = Planet.y - A.y;
		R = hypotl(dx, dy);
		cosinus = dx / R; sinus = dy / R;
		R *= R;
		Planet.ax = -A.GM / R * cosinus;
		Planet.ay = -A.GM / R * sinus;
		dx = Planet.x - B.x; dy = Planet.y - B.y;
		R = hypotl(dx, dy);
		cosinus = dx / R; sinus = dy / R;
		R *= R;
		Planet.ax += -B.GM / R * cosinus;
		Planet.ay += -B.GM / R * sinus;
		Planet.vx += h*Planet.ax;
		Planet.vy += h*Planet.ay;
		bool k = (llrintl(t) % 1000 == 0);

		if (k){
			dc.SelectObject(Line);
			dc.MoveTo(0, lrintl(y / 2));
			dc.LineTo(lrintl(x), lrintl(y / 2));
			dc.MoveTo(lrintl(x / 2), 0);
			dc.LineTo(lrintl(x / 2), lrintl(y));
		};
		if (k){
			dc.SelectObject(Background);
			dc.SelectObject(Star2);
			dc.Ellipse(lrintl(x / 2 + y / 2.0*A.x / max) - 7, lrintl(y / 2.0*(1.0 - A.y / max)) - 7, lrintl(x / 2 + y / 2.0*A.x / max) + 7, lrintl(y / 2.0*(1.0 - A.y / max)) + 7);
		};
		A.x += h*A.vx;
		A.y += h*A.vy;
		if (k){
			dc.SelectObject(Star1);
			dc.Ellipse(lrintl(x / 2 + y / 2.0*A.x / max) - 7, lrintl(y / 2.0*(1.0 - A.y / max)) - 7, lrintl(x / 2 + y / 2.0*A.x / max) + 7, lrintl(y / 2.0*(1.0 - A.y / max)) + 7);
		};
		//dc.LineTo(lrintl(x / 2 + y / 2.0*A.x / max), lrintl(y / 2.0*(1.0 - A.y / max)));
		//dc.MoveTo(lrintl(x / 2 + y / 2.0*B.x / max), lrintl(y / 2.0*(1.0 - B.y / max)));
		
		if (k){
			dc.SelectObject(Background);
			dc.SelectObject(Star2);
			dc.Ellipse(lrintl(x / 2 + y / 2.0*B.x / max) - 5, lrintl(y / 2.0*(1.0 - B.y / max)) - 5, lrintl(x / 2 + y / 2.0*B.x / max) + 5, lrintl(y / 2.0*(1.0 - B.y / max)) + 5);
		};
		B.x += h*B.vx;
		B.y += h*B.vy;
		if (k){
			dc.SelectObject(Star1);
			dc.Ellipse(lrintl(x / 2 + y / 2.0*B.x / max) - 5, lrintl(y / 2.0*(1.0 - B.y / max)) - 5, lrintl(x / 2 + y / 2.0*B.x / max) + 5, lrintl(y / 2.0*(1.0 - B.y / max)) + 5);
		};

		if (k){
			dc.SelectObject(Background);
			dc.SelectObject(Star2);
			dc.Ellipse(lrintl(x / 2 + y / 2.0*Planet.x / max) - 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) - 3, lrintl(x / 2 + y / 2.0*Planet.x / max) + 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) + 3);
		};
		Planet.x += h*Planet.vx;
		Planet.y += h*Planet.vy;
		if (k){
			dc.SelectObject(BPlanetoid);
			dc.Ellipse(lrintl(x / 2 + y / 2.0*Planet.x / max) - 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) - 3, lrintl(x / 2 + y / 2.0*Planet.x / max) + 3, lrintl(y / 2.0*(1.0 - Planet.y / max)) + 3);
		};
		if ((hypotl(Planet.x - A.x, Planet.y - A.y) < A.R + Planet.R) || (hypotl(Planet.x - B.x, Planet.y - B.y) < B.R + Planet.R) || (fabsl(x/2.0*Planet.x / max)>x) || (fabsl(y/2.0*Planet.y / max)>y))
			break;
		/*
		//dc.LineTo(lrintl(x / 2 + y / 2.0*B.x / max), lrintl(y / 2.0*(1.0 - B.y / max)));
		dc.SelectObject(Planetoid);
		dc.MoveTo(lrintl(x / 2 + y / 2.0*Planet.x / max), lrintl(y / 2.0*(1.0 - Planet.y / max)));
		Planet.x += h*Planet.vx;
		Planet.y += h*Planet.vy;		
		dc.LineTo(lrintl(x / 2 + y / 2.0*Planet.x / max), lrintl(y / 2.0*(1.0 - Planet.y / max)));
		//dc.MoveTo(lrintl(x / 2 + y / 2.0*A.x / max), lrintl(y / 2.0*(1.0 - A.y / max)));
		*/
	}
}
/*!
  \param points Series of data points
  \return Curve points
*/
QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const
{
    QStack<Line> stack;
    stack.reserve( 500 );

    const QPointF *p = points.data();
    const int nPoints = points.size();

    QVector<bool> usePoint( nPoints, false );

    double distToSegment;

    stack.push( Line( 0, nPoints - 1 ) );

    while ( !stack.isEmpty() )
    {
        const Line r = stack.pop();

        // initialize line segment
        const double vecX = p[r.to].x() - p[r.from].x();
        const double vecY = p[r.to].y() - p[r.from].y();

        const double vecLength = qSqrt( vecX * vecX + vecY * vecY );

        const double unitVecX = ( vecLength != 0.0 ) ? vecX / vecLength : 0.0;
        const double unitVecY = ( vecLength != 0.0 ) ? vecY / vecLength : 0.0;

        double maxDist = 0.0;
        int nVertexIndexMaxDistance = r.from + 1;
        for ( int i = r.from + 1; i < r.to; i++ )
        {
            //compare to anchor
            const double fromVecX = p[i].x() - p[r.from].x();
            const double fromVecY = p[i].y() - p[r.from].y();
            const double fromVecLength =
                qSqrt( fromVecX * fromVecX + fromVecY * fromVecY );

            if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 )
            {
                distToSegment = fromVecLength;
            }
            if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 )
            {
                distToSegment = fromVecLength;
            }
            else
            {
                const double toVecX = p[i].x() - p[r.to].x();
                const double toVecY = p[i].y() - p[r.to].y();
                const double toVecLength = qSqrt( toVecX * toVecX + toVecY * toVecY );
                const double s = toVecX * ( -unitVecX ) + toVecY * ( -unitVecY );
                if ( s < 0.0 )
                    distToSegment = toVecLength;
                else
                {
                    distToSegment = qSqrt( qFabs( toVecLength * toVecLength - s * s ) );
                }
            }

            if ( maxDist < distToSegment )
            {
                maxDist = distToSegment;
                nVertexIndexMaxDistance = i;
            }
        }
        if ( maxDist <= d_data->tolerance )
        {
            usePoint[r.from] = true;
            usePoint[r.to] = true;
        }
        else
        {
            stack.push( Line( r.from, nVertexIndexMaxDistance ) );
            stack.push( Line( nVertexIndexMaxDistance, r.to ) );
        }
    }

    int cnt = 0;

    QPolygonF stripped( nPoints );
    for ( int i = 0; i < nPoints; i++ )
    {
        if ( usePoint[i] )
            stripped[cnt++] = p[i];
    }
    stripped.resize( cnt );
    return stripped;
}
void cHpiSubProviderWatchdog::GetInfo( std::deque<HpiInfo>& info ) const
{
    info.clear();

    SaErrorT rv;
    SaHpiRdrT rdr;
    rv = saHpiRdrGetByInstrumentId( m_ctx.session_id,
                                    m_ctx.resource_id,
                                    SAHPI_WATCHDOG_RDR,
                                    m_ctx.instrument_id,
                                    &rdr );
    if ( rv != SA_OK ) {
        Line( info, L"saHpiRdrGetByInstrumentId failed", rv, I32_SaError );
        return;
    }

    Line( info, L"Resource Id", m_ctx.resource_id, UI32_SaHpiResourceId );
    Line( info, L"Entity", rdr.Entity );
    Line( info, L"IsFru", rdr.IsFru, UI8_SaHpiBool );

    const SaHpiWatchdogRecT& wr = rdr.RdrTypeUnion.WatchdogRec;

    Line( info, L"Watchdog Num", wr.WatchdogNum, UI32_SaHpiWatchdogNum );
    Line( info, L"OEM", wr.Oem );
    Line( info, L"IdString", rdr.IdString );

    SaHpiWatchdogT w;
    rv = saHpiWatchdogTimerGet( m_ctx.session_id,
                                m_ctx.resource_id,
                                m_ctx.instrument_id,
                                &w );
    if ( rv != SA_OK ) {
        Line( info, L"saHpiWatchdogTimerGet failed", rv, I32_SaError );
        return;
    }

    Line( info, L"Current Settings and Configuration", L"" );
    Line( info, L"  Log", w.Log, UI8_SaHpiBool );
    Line( info, L"  Running", w.Running, UI8_SaHpiBool );
    Line( info, L"  Timer Use", w.TimerUse );
    Line( info, L"  Timer Action", w.TimerAction );
    Line( info, L"  Pre-Timer Interrupt", w.PretimerInterrupt );
    Line( info, L"  Pre-Timeout Interval, ms", w.PreTimeoutInterval );
    Line( info, L"  Timer Use Expiration Flags",
          w.TimerUseExpFlags,
          UI8_SaHpiWatchdogExpFlags );
    Line( info, L"  Initial Count", w.InitialCount );
    Line( info, L"  Present Count", w.PresentCount );
}
Exemple #22
0
void MDrawContextR2::VLine(int x, int y, int len)
{
	Line(x, y, x, y+len);
}
//--------------------------------------------------
ofBuffer::Line & ofBuffer::Line::operator++(){
	*this = Line(_current,_end);
	return *this;
}
Exemple #24
0
void
endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_FREESEL:
        {
            POINT *ptStackCopy;
            int i;
            rectSel_src[0] = rectSel_src[1] = 0x7fffffff;
            rectSel_src[2] = rectSel_src[3] = 0;
            for (i = 0; i <= ptSP; i++)
            {
                if (ptStack[i].x < rectSel_src[0])
                    rectSel_src[0] = ptStack[i].x;
                if (ptStack[i].y < rectSel_src[1])
                    rectSel_src[1] = ptStack[i].y;
                if (ptStack[i].x > rectSel_src[2])
                    rectSel_src[2] = ptStack[i].x;
                if (ptStack[i].y > rectSel_src[3])
                    rectSel_src[3] = ptStack[i].y;
            }
            rectSel_src[2] += 1 - rectSel_src[0];
            rectSel_src[3] += 1 - rectSel_src[1];
            rectSel_dest[0] = rectSel_src[0];
            rectSel_dest[1] = rectSel_src[1];
            rectSel_dest[2] = rectSel_src[2];
            rectSel_dest[3] = rectSel_src[3];
            if (ptSP != 0)
            {
                DeleteObject(hSelMask);
                hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL);
                DeleteObject(SelectObject(hSelDC, hSelMask));
                ptStackCopy = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * (ptSP + 1));
                for (i = 0; i <= ptSP; i++)
                {
                    ptStackCopy[i].x = ptStack[i].x - rectSel_src[0];
                    ptStackCopy[i].y = ptStack[i].y - rectSel_src[1];
                }
                Poly(hSelDC, ptStackCopy, ptSP + 1, 0x00ffffff, 0x00ffffff, 1, 2, TRUE);
                HeapFree(GetProcessHeap(), 0, ptStackCopy);
                SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]));
                resetToU1();
                MaskBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0],
                        rectSel_src[1], hSelMask, 0, 0, MAKEROP4(SRCCOPY, WHITENESS));
                Poly(hdc, ptStack, ptSP + 1, bg, bg, 1, 2, TRUE);
                newReversible();

                MaskBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0,
                        0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));

                placeSelWin();
                ShowWindow(hSelection, SW_SHOW);
                /* force refresh of selection contents */
                SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
                SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
                SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
            }
            HeapFree(GetProcessHeap(), 0, ptStack);
            ptStack = NULL;
            break;
        }
        case TOOL_RECTSEL:
            resetToU1();
            if ((rectSel_src[2] != 0) && (rectSel_src[3] != 0))
            {
                DeleteObject(hSelMask);
                hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL);
                DeleteObject(SelectObject(hSelDC, hSelMask));
                Rect(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], 0x00ffffff, 0x00ffffff, 1, 2);
                SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]));
                resetToU1();
                BitBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0],
                       rectSel_src[1], SRCCOPY);
                Rect(hdc, rectSel_src[0], rectSel_src[1], rectSel_src[0] + rectSel_src[2],
                     rectSel_src[1] + rectSel_src[3], bgColor, bgColor, 0, TRUE);
                newReversible();

                BitBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0,
                       0, SRCCOPY);

                placeSelWin();
                ShowWindow(hSelection, SW_SHOW);
                /* force refresh of selection contents */
                SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
                SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
                SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
            }
            break;
        case TOOL_RUBBER:
            Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, fg, 1);
            SetPixel(hdc, x, y, fg);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, fg, lineWidth);
            break;
        case TOOL_BEZIER:
            pointSP++;
            if (pointSP == 4)
                pointSP = 0;
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            pointSP++;
            if (pointSP >= 2)
            {
                if ((pointStack[0].x - x) * (pointStack[0].x - x) +
                    (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1)
                {
                    Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE);
                    pointSP = 0;
                }
                else
                {
                    Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE);
                }
            }
            if (pointSP == 255)
                pointSP--;
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
            break;
    }
}
Exemple #25
0
void ScreenSaver(void)
{
  randomize();
  int gDriver=DETECT, gMode,errorcode;
  initgraph(&gDriver,&gMode,"");
  errorcode=graphresult();
  if(errorcode!=grOk)
  {
    printf("ERROR: %s\nPress any key to EXIT\n",grapherrormsg(errorcode));
    getch();
    exit(1);
  }
//******START***********
  int x=1,y=1,i=0,j=0,intsymbol,bkColor=0,Color=2;
  char *symbol;
  setbkcolor(bkColor);
  setcolor(Color);
  unsigned int A_Size=imagesize(553,390,625,467);
  void *bigTemp=malloc(A_Size);

  memset(bigTemp,0,sizeof(bigTemp));

  getimage(25,10,85,90,bigTemp);
  setcolor(15);
  Rect(1,1,100);
  T(50,15,14);
  setcolor(15);
  Line(50,101,266,"v");
  Rect(1,370,100);
  E(50,390,14);
  setcolor(15);
  Line(100,420,430,"h");
  Rect(530,370,100);
  A(580,390,2);
  setcolor(15);
  Line2(101,50,580,369);
  Rect(530,1,100);
  M(580,30,14);
  setcolor(15);
  Paraleli(100,100,100,370,"h");
  Paraleli(100,100,530,100,"v");
  settextstyle(0,0,2);
  unsigned int T_Size=imagesize(25,10,85,90);
  unsigned int E_Size=imagesize(25,390,85,465);
  unsigned int M_Size=imagesize(545,10,625,90);
  unsigned int temp_Size=imagesize(220,250,281,252);
  void *T_Array=malloc(T_Size);
  void *E_Array=malloc(E_Size);
  void *A_Array=malloc(A_Size);
  void *M_Array=malloc(M_Size);
  void *temp_Array=malloc(temp_Size);
  void *temp_A=malloc(A_Size);

  memset(T_Array,0,sizeof(T_Array));
  memset(E_Array,0,sizeof(E_Array));
  memset(A_Array,0,sizeof(A_Array));
  memset(M_Array,0,sizeof(M_Array));
  memset(temp_Array,0,sizeof(temp_Array));
  memset(temp_A,0,sizeof(temp_A));

  getimage(25,10,85,90,T_Array);
  getimage(25,390,85,465,E_Array);
  getimage(553,390,625,467,A_Array);
  getimage(545,10,625,90,M_Array);
  getimage(220,250,281,252,temp_Array);
  ///*****WORK WITH BITMAPS************
  int i_E,j_E,i_A,j_A,i_M,j_M;
  putimage(380,120,M_Array,COPY_PUT);
  putimage(380,260,A_Array,COPY_PUT);
  for(i=150,j=110,i_E=110,j_E=290,i_A=380,j_A=260,i_M=400,j_M=120;(j<220)&&(i_A>280)&&(i_E<220);j++,i_E++,i_A--)
  {
    putimage(i,j,T_Array,COPY_PUT);
    putimage(i_E,j_E,E_Array,COPY_PUT);
    delay(LETTERSPEED);
      while((j_E>253)&&(i_M>330))
      {
	putimage(i_E,j_E,E_Array,COPY_PUT);
	j_E--;
	putimage(i_M,j_M,M_Array,COPY_PUT);
	i_M--;
      }
    putimage(i_A,j_A,A_Array,COPY_PUT);
  }
  while(j_M<240)
  {
    putimage(i_M,j_M,M_Array,COPY_PUT);
    j_M++;
    if((j_M>200)&&(j_M<220))
    i_M--;
  }
  for(;j_E>120;j_A--,j_E--,j_M--)
  {

    putimage(i_E,j_E,E_Array,COPY_PUT);
    putimage(i_A+random(2),j_A,A_Array,COPY_PUT);
    putimage(i_M,j_M,M_Array,COPY_PUT);
  }
  setcolor(14);
  for(;j_E<215;j_E++,j_M++)
  {
    putimage(i_E,j_E-1,temp_Array,COPY_PUT);
    putimage(i_E,j_E,E_Array,COPY_PUT);
    putimage(i_M+5,j_M,M_Array,COPY_PUT);
    delay(random(LETTERSPEED*2));
  }
  for(;j_A<270;j_A++)
  {
    putimage(i_A,j_A+70,temp_Array,COPY_PUT);
    putimage(i_A,j_A,A_Array,COPY_PUT);
    putimage(i_A,j_A-1,temp_Array,COPY_PUT);
  }
  for(i=0;i<15;i++)
  {
    putimage(i_A,j_A+=5,temp_Array,COPY_PUT);
  }
  getimage(280,270,350,350,temp_A);
  putimage(280,270,bigTemp,COPY_PUT);
  putimage(280,250,bigTemp,COPY_PUT);
  putimage(290,245,bigTemp,COPY_PUT);
  putimage(280,210,temp_A,COPY_PUT);
  x=(getmaxx()/2)-70,y=getmaxy()-50;
  //***************************
  outtextxy(x,y,"Made by");
  outtextxy(x-70,y+20,"Serhiy Radkivskiy");
  setcolor(14);
//*****CLOSE************
 getch();
// free(symbol);
  memset(T_Array,0,sizeof(T_Array));
  memset(E_Array,0,sizeof(E_Array));
  memset(A_Array,0,sizeof(A_Array));
  memset(M_Array,0,sizeof(M_Array));
  memset(temp_Array,0,sizeof(temp_Array));
  memset(temp_A,0,sizeof(temp_A));

 free(T_Array);
 free(E_Array);
 free(A_Array);
 free(M_Array);
 free(temp_Array);
 free(bigTemp);
 free(temp_A);
 cleardevice();
 closegraph();
}
Exemple #26
0
int main ()
{
    freopen("milk2.in", "r", stdin);
    freopen("milk2.out", "w", stdout);
    
    int N = 0;
    scanf("%d",&N);
    
    int left;
    int right;
    for (int i = 0; i < N; i++) {
        scanf("%d",&left);
        scanf("%d",&right);
        lines[i] = Line(left,right);
        points[2*i] = Point(left,1);
        points[2*i+1] = Point(right,-1);
    }
    
    int total = 2*N;
    for(int i = 1; i < total; i++){
        for(int j = 0; j < total-i; j++){
            if (points[j].loc > points[j+1].loc) {
                int tempLoc = points[j+1].loc;
                int tempType= points[j+1].type;
                points[j+1].loc = points[j].loc;
                points[j+1].type= points[j].type;
                points[j].loc = tempLoc;
                points[j].type= tempType;
            }
        }
    }
    
//    for (int i = 0; i < total; i++) {
//        printf("%d %d \n", points[i].loc, points[i].type);
//    }
    
    int len[MAXN] = {0};
    int type[MAXN]= {0};
    for (int i = 0; i < total-1; i++) {
        len[i] = points[i+1].loc - points[i].loc;
        bool IN = false;
        for(int j = 0; j < N; j++){
            if (points[i].loc >= lines[j].left && points[i+1].loc <= lines[j].right) {
                IN = true;
                break;
            }
        }
        if (IN)
            type[i] = 1;
        else
            type[i] = -1;
//        printf("%d %d\n",len[i],type[i]);
    }
    
    int max1 = 0;
    int max2 = 0;
    int current = type[0];
    int sum = len[0];
    if (type[0] == 1)
        max1 = len[0];
    else
        max2 = len[0];
    for(int i = 1; i < total; i++){
//        printf("sum %d\n",sum);
        if (current == type[i]) {
            sum += len[i];
        }
        else{
            sum = len[i];
            current = type[i];
        }
        if (current == 1 && max1 < sum)
            max1 = sum;
        else if(current == -1 && max2 < sum)
            max2 = sum;
    }
    
    printf("%d %d\n",max1,max2);
    
    return 0;
}
Exemple #27
0
/*--------------------------------------------------------------------------*/
void PegTextButton::Draw(void)
{
    BeginDraw();
    PegButton::Draw();
    PegColor Color;

   #if defined(ACTIVE_BUTTON_COLOR_CHANGE)
    if (StatusIs(PSF_CURRENT))
    {
        Color.Set(muColors[PCI_STEXT], muColors[PCI_SELECTED], CF_NONE);
    }
    else
    {
        Color.Set(muColors[PCI_NTEXT], muColors[PCI_NORMAL], CF_NONE);
    }
   #else
        Color.Set(muColors[PCI_NTEXT], muColors[PCI_NORMAL], CF_NONE);
   #endif

    if (NumColors() < 4)
    {
        Color.uFlags = CF_FILL;
    }

    if (!(Style() & AF_ENABLED))
    {
        Color.uForeground = PCLR_LOWLIGHT;
    }

    // now draw the text:

    PegPoint Put;
    SIGNED iSize;

    if (Style() & TJ_LEFT)
    {
       #ifdef PEG_DRAW_FOCUS
        Put.x = mClient.wLeft + 3;
       #else
        Put.x = mClient.wLeft + 1;
       #endif
    }
    else
    {
        iSize = TextWidth(mpText, mpFont);

        if (Style() & TJ_RIGHT)
        {
           #ifdef PEG_DRAW_FOCUS
            Put.x = mClient.wRight - iSize - 3;
           #else
            Put.x = mClient.wRight - iSize - 1;
           #endif
        }
        else
        {
            Put.x = mClient.wLeft + (mClient.Width() - iSize) / 2;
        }
    }

    iSize = TextHeight(mpText, mpFont);
    if (iSize <= mClient.Height())
    {
        Put.y = mClient.wTop + (mClient.Height() - iSize) / 2;
    }
    else
    {
        Put.y = mClient.wTop;
    }

    DrawText(Put, mpText, Color, mpFont);

    if (NumColors() < 4)
    {
        if (!(Style() & AF_ENABLED))
        {
            SIGNED yCenter = (mClient.wTop + mClient.wBottom) / 2;
            Line(Put.x, yCenter, Put.x + TextWidth(mpText, mpFont), yCenter, Color);
        }
    }

    if (First())
    {
        DrawChildren();
    }
    EndDraw();
}
void dxRenderAABB(AABB* box, const Color* color, Matrix* ltm)
{
    Vector vertex[8];
    for( int i=0; i<8; i++ ) vertex[i] = Vector(
        i & 1 ? box->sup.x : box->inf.x,
        i & 2 ? box->sup.y : box->inf.y,
        i & 4 ? box->sup.z : box->inf.z
    );
    
    Line lines[12];
    lines[0]  = Line( vertex[0], vertex[1] );
    lines[1]  = Line( vertex[1], vertex[3] );
    lines[2]  = Line( vertex[3], vertex[2] );
    lines[3]  = Line( vertex[2], vertex[0] );
    lines[4]  = Line( vertex[4], vertex[5] );
    lines[5]  = Line( vertex[5], vertex[7] );
    lines[6]  = Line( vertex[7], vertex[6] );
    lines[7]  = Line( vertex[6], vertex[4] );
    lines[8]  = Line( vertex[0], vertex[4] );
    lines[9]  = Line( vertex[1], vertex[5] );
    lines[10] = Line( vertex[2], vertex[6] );
    lines[11] = Line( vertex[3], vertex[7] );

    dxRenderLines( 12, lines, color, ltm );
}
Exemple #29
0
bool Collision::AABB_vs_Line(const AABB& a, const Line& b, Vector *v)
{
    // Fast AABB check first
    if(!AABB_vs_AABB(a, b.getAABB(), v))
        return false;

    /*       (u)
          +-------+
          |       |
       (l)|       |(r)
          |       |
          +-------+
             (d)
    */

    const Vector bstart = b.startpos();
    const Vector pos(a.getPosition());
    const Vector upleftr(a.upleftRel());
    const Vector downrightr(a.downrightRel());

    const Vector uprightr(downrightr.x, upleftr.y);
    const Vector downleftr(upleftr.x, downrightr.y);

    Vector vtmp;
    Vector *vp = v ? &vtmp : NULL;
    float mindiff = b.lenSq();
    float diff = mindiff;
    bool hit = false;

    // (u)
    if(Line_vs_Line(b, Line(pos, upleftr, uprightr), vp))
    {
        if(v)
        {
            diff = (vtmp - bstart).getLength2DSq();
            if(diff < mindiff)
            {
                mindiff = diff;
                *v = vtmp;
            }
        }
        hit = true;
    }

    // (l)
    if(Line_vs_Line(b, Line(pos, upleftr, downleftr), vp))
    {
        if(v)
        {
            diff = (vtmp - bstart).getLength2DSq();
            if(diff < mindiff)
            {
                mindiff = diff;
                *v = vtmp;
            }
        }
        hit = true;
    }

    // (r)
    if(Line_vs_Line(b, Line(pos, uprightr, downrightr), vp))
    {
        if(v)
        {
            diff = (vtmp - bstart).getLength2DSq();
            if(diff < mindiff)
            {
                mindiff = diff;
                *v = vtmp;
            }
        }
        hit = true;
    }

    // (d)
    if(Line_vs_Line(b, Line(pos, downleftr, downrightr), vp))
    {
        if(v)
        {
            diff = (vtmp - bstart).getLength2DSq();
            if(diff < mindiff)
            {
                mindiff = diff;
                *v = vtmp;
            }
        }
        hit = true;
    }

    return hit;
}
Exemple #30
-1
void
endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
    switch (activeTool)
    {
        case TOOL_RUBBER:
            Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
            break;
        case TOOL_PEN:
            Line(hdc, last.x, last.y, x, y, bg, 1);
            SetPixel(hdc, x, y, bg);
            break;
        case TOOL_LINE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                roundTo8Directions(start.x, start.y, &x, &y);
            Line(hdc, start.x, start.y, x, y, bg, lineWidth);
            break;
        case TOOL_BEZIER:
            pointSP++;
            if (pointSP == 4)
                pointSP = 0;
            break;
        case TOOL_RECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
            break;
        case TOOL_SHAPE:
            resetToU1();
            pointStack[pointSP].x = x;
            pointStack[pointSP].y = y;
            if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
                roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
                                   &pointStack[pointSP].x, &pointStack[pointSP].y);
            pointSP++;
            if (pointSP >= 2)
            {
                if ((pointStack[0].x - x) * (pointStack[0].x - x) +
                    (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1)
                {
                    Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, TRUE);
                    pointSP = 0;
                }
                else
                {
                    Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, FALSE);
                }
            }
            if (pointSP == 255)
                pointSP--;
            break;
        case TOOL_ELLIPSE:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
            break;
        case TOOL_RRECT:
            resetToU1();
            if (GetAsyncKeyState(VK_SHIFT) < 0)
                regularize(start.x, start.y, &x, &y);
            RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
            break;
    }
}