38 float defCoeff = 1 / 255.0;
39 for (
int i = 0; i < 4; i++)
56 void moP5::triangle(
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
60 glBegin(GL_TRIANGLES);
72 glEnable( GL_TEXTURE_2D );
73 glBindTexture(GL_TEXTURE_2D,0);
85 void moP5::line(
float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
87 glEnable( GL_TEXTURE_2D );
88 glBindTexture(GL_TEXTURE_2D,0);
92 glVertex3f(x1, y1, z1);
93 glVertex3f(x2, y2, z2);
100 void moP5::arc(
float x,
float y,
float width,
float height,
float start,
float stop,
int slices,
float band )
103 glEnable( GL_TEXTURE_2D );
104 glBindTexture(GL_TEXTURE_2D,0);
116 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
118 glBegin(GL_LINE_LOOP);
126 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
130 glBegin(GL_TRIANGLE_STRIP);
131 }
else glBegin(GL_TRIANGLE_FAN);
146 glVertex2f( (
float)x, (
float)y);
149 for(
float t = start; t <= stop; t += Nstep ) {
152 glVertex2f( (width-band)* cos(t) + (
float)x, (height-band) * sin(t) + (
float)y);
155 glVertex2f(width* cos(t) + (
float)x, height * sin(t) + (
float)y);
188 void moP5::quad(
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x4,
float y4)
202 void moP5::ellipse(
float x,
float y,
float width,
float height,
int slices )
206 glEnable( GL_TEXTURE_2D );
207 glBindTexture(GL_TEXTURE_2D,0);
216 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
218 glBegin(GL_LINE_LOOP);
220 glVertex2f(width* cos(t) + (
float)x, height * sin(t) + (
float)y);
225 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
229 glVertex2f(width * cos(t) + (
float)x, height * sin(t) + (
float)y);
248 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
249 glBindTexture(GL_TEXTURE_2D,0);
254 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
255 glBindTexture(GL_TEXTURE_2D,0);
260 glRectf(x, y, x + width, y + height);
301 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
308 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
315 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
322 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
334 float coeff = 1 / 255.0;
335 if ((0 < range) && (range <= 255.0)) coeff = 1 / range;
351 float coeff1 = 1 / 255.0;
352 float coeff2 = 1 / 255.0;
353 float coeff3 = 1 / 255.0;
354 if ((0 < range1) && (range1 <= 255.0)) coeff1 = 1 / range1;
355 if ((0 < range2) && (range2 <= 255.0)) coeff2 = 1 / range2;
356 if ((0 < range3) && (range3 <= 255.0)) coeff3 = 1 / range3;
372 void moP5::colorMode(
int mode,
float range1,
float range2,
float range3,
float range4)
376 float coeff1 = 1 / 255.0;
377 float coeff2 = 1 / 255.0;
378 float coeff3 = 1 / 255.0;
379 float coeff4 = 1 / 255.0;
380 if ((0 < range1) && (range1 <= 255.0)) coeff1 = 1 / range1;
381 if ((0 < range2) && (range2 <= 255.0)) coeff2 = 1 / range2;
382 if ((0 < range3) && (range3 <= 255.0)) coeff3 = 1 / range3;
383 if ((0 < range4) && (range4 <= 255.0)) coeff4 = 1 / range4;
423 void moP5::stroke(
float value1,
float value2,
float value3,
float alpha)
435 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
451 fill( gray, gray, gray , 1.0 );
456 fill( gray, gray, gray , alpha );
461 fill( value1, value2, value3 , 1.0 );
464 void moP5::fill(
float value1,
float value2,
float value3,
float alpha)
468 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
481 glMatrixMode(GL_MODELVIEW);
491 glMatrixMode(GL_MODELVIEW);
501 glMatrixMode(GL_MODELVIEW);
511 glScalef(size, size, size);
529 glTranslatef(x, y, z);
556 tmpColor[1] = comp2 * colorRGBCoeff[1];
557 tmpColor[2] = comp3 * colorRGBCoeff[2];
558 tmpColor[3] = comp4 * colorRGBCoeff[3];
566 float s = comp2 * colorHSBCoeff[1];
567 float l = comp3 * colorHSBCoeff[2];
576 tmpColor[3] = comp4 * colorHSBCoeff[3];
592 if (l <= 0.5) m2 = l * (1.0 + s);
593 else m2 = l + s - (l * s);
595 r =
HuetoRGB(m1, m2, h + 1.0 / 3.0);
597 b =
HuetoRGB(m1, m2, h - 1.0 / 3.0);
603 if (h < 0) h = h + 1.0;
604 if (h > 1) h = h - 1.0;
605 if (6.0 * h < 1)
return (m1 + (m2 - m1) * h * 6.0);
608 if (2.0 * h < 1)
return m2;
610 if (3.0 * h < 2.0)
return (m1 + (m2 - m1) * ((2.0 / 3.0) - h) * 6.0);
static const float MO_P5_PI
void arc(float x, float y, float width, float height, float start, float stop, int slices=24, float band=0.0)
void translate(float x, float y, float z=0.0f)
void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
static const float MO_P5_HALF_PI
static const float MO_P5_TWO_PI
void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
void generateTmpColor(float comp1, float comp2, float comp3)
void background(float gray)
void ellipse(float x, float y, float width, float height, int slices=24)
void rotate(float angle, float x=0.0f, float y=0.0f, float z=1.0f)
void strokeWeight(float width)
void rect(float x, float y, float width, float height)
void point(float x, float y)
float HuetoRGB(float m1, float m2, float h)
void line(float x1, float y1, float x2, float y2)
void convertHSLtoRGB(float h, float s, float l, float &r, float &g, float &b)