Esempio n. 1
0
int main()
{
  Point *p1;
  Point *p2;
  char temp1[15];


  p1 = createPoint (10, 12);
  p2 = createPoint (-5, 12);

  movePoint (p1, 10, 3);

  dilatePoint (p2, 2);

  printf ("Point 1: %s\n", pointToString (p1, temp1));
  printf ("Point 2: %s\n", pointToString (p2, temp1));
  
  free (p1);
  free (p2);
}
Esempio n. 2
0
    /**
     * Saves gradient information into DOM element \a qElement.
     *
     * @param qDoc The DOM document object.
     *
     * @param qElement The DOM element into which the gradient should be
     *                 saved.
     *
     * @param gradient The gradient to be saved.
     */
    void saveGradientToXMI(QDomDocument &qDoc, QDomElement &qElement, const QGradient *gradient)
    {
        QDomElement gradientElement = qDoc.createElement(QLatin1String("gradient"));

        gradientElement.setAttribute(QLatin1String("type"), int(gradient->type()));
        gradientElement.setAttribute(QLatin1String("spread"), int(gradient->spread()));
        gradientElement.setAttribute(QLatin1String("coordinatemode"), int(gradient->coordinateMode()));

        QDomElement stopsElement = qDoc.createElement(QLatin1String("stops"));
        gradientElement.appendChild(stopsElement);

        foreach(const QGradientStop& stop, gradient->stops()) {
            QDomElement ele = qDoc.createElement(QLatin1String("stop"));
            ele.setAttribute(QLatin1String("position"), stop.first);
            ele.setAttribute(QLatin1String("color"), stop.second.name());
            stopsElement.appendChild(ele);
        }

        QGradient::Type type = gradient->type();

        if(type == QGradient::LinearGradient) {
            const QLinearGradient *lg = static_cast<const QLinearGradient*>(gradient);
            gradientElement.setAttribute(QLatin1String("start"), pointToString(lg->start()));
            gradientElement.setAttribute(QLatin1String("finalstop"), pointToString(lg->finalStop()));
        }
        else if(type == QGradient::RadialGradient) {
            const QRadialGradient *rg = static_cast<const QRadialGradient*>(gradient);
            gradientElement.setAttribute(QLatin1String("center"), pointToString(rg->center()));
            gradientElement.setAttribute(QLatin1String("focalpoint"), pointToString(rg->focalPoint()));
            gradientElement.setAttribute(QLatin1String("radius"), rg->radius());
        }
        else { //type == QGradient::ConicalGradient
            const QConicalGradient *cg = static_cast<const QConicalGradient*>(gradient);
            gradientElement.setAttribute(QLatin1String("center"), pointToString(cg->center()));
            gradientElement.setAttribute(QLatin1String("angle"), cg->angle());
        }

        qElement.appendChild(gradientElement);
    }
Esempio n. 3
0
char* WPLSentence::get(char str[], size_t buflen) const {
  if (str == NULL || buflen < MAX_SENTENCE_LENGTH)
    return NULL;
    
  addHead(str);

  strcat(str, ",");

  char* p = strend(str);

  pointToString(waypoint, p);

  strcat(p, ",");

  strcat(p, name);
  
  return addChecksum(str);
}
Esempio n. 4
0
void ofxGuiPoints::draw()
{
	glPushMatrix();

		glTranslatef(mObjX, mObjY, 0.0f);

		if(mParamName != "")
			drawParamString(0.0, 0.0, mParamName + ": " + pointToString(mList.activePoint != -1 ? mOutVal : mValue, mDisplay), false);

		ofxPoint2f	p	= fractionToLocal(valueToFraction(mValue));

		float		x	= mCtrWidth * p.x;
		float		y	= mCtrHeight * p.y;

		float		d	= mGlobals->mPointSize;
		float		r	= d / 2.0;

		ofFill();

		//	background
		glColor4f(mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a);
		ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);

		ofNoFill();

		//	lines
		glColor4f(mGlobals->mCurveColor.r, mGlobals->mCurveColor.g, mGlobals->mCurveColor.b, mGlobals->mCurveColor.a);
		/*
		ofBeginShape();
			for(int i = 0; i < mList.points.size(); i++)
			{
				ofxPoint2f p = fractionToLocal(valueToFraction(mList.points.at(i)));
				ofVertex(p.x, p.y);
			}
		ofEndShape(false);
		*/

			GLfloat* verts = new GLfloat[(int)mMaxVal.x*2];
			for (int i = 0; i < mMaxVal.x; i++)	{
						ofxPoint2f p = fractionToLocal(valueToFraction(bezier(mList.points, mList.points.size()-1, (float) i / (float) mMaxVal.x)));

						verts[i*2  ] = p.x;
						verts[i*2+1] = p.y;
			}

			glEnableClientState(GL_VERTEX_ARRAY);
			glVertexPointer(2, GL_FLOAT, 0, verts );
			glDrawArrays( GL_LINE_STRIP, 0, mMaxVal.x);
			glDisableClientState(GL_VERTEX_ARRAY);

		//	x-bar
		glColor4f(mGlobals->mAxisColor.r, mGlobals->mAxisColor.g, mGlobals->mAxisColor.b, mGlobals->mAxisColor.a);
		ofLine(p.x + 0.5, mCtrY, p.x + 0.5, mCtrBottom);

		if(mList.activePoint != -1)
		{
			//	y-bar
			glColor4f(mGlobals->mAxisColor.r, mGlobals->mAxisColor.g, mGlobals->mAxisColor.b,mGlobals->mAxisColor.a);
			ofLine(mCtrX, p.y + 0.5, mCtrRight, p.y + 0.5);
		}

		//	handles
		for(int i = 0; i < mList.points.size(); i++)
		{
			glColor4f(mGlobals->mHandleColor.r, mGlobals->mHandleColor.g, mGlobals->mHandleColor.b, mGlobals->mHandleColor.a);

			ofxPoint2f p	= fractionToLocal(valueToFraction(mList.points.at(i)));
			ofRect(p.x - r, p.y - r, d, d);
		}

		//	frame
		glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a);
		ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);

	glPopMatrix();
}