コード例 #1
0
ファイル: GScurves.cpp プロジェクト: Heathtech/enigma-dev
void draw_bezier_quadratic_color(gs_scalar x1, gs_scalar y1, gs_scalar x2, gs_scalar y2, gs_scalar x3, gs_scalar y3, int c1, int c2, gs_scalar al1, gs_scalar al2)
{
    int col;
    gs_scalar x, y, al, a2, b2;
    float a = 1.0, b = 0.0, det = 1.0/(gs_scalar)pr_curve_detail;
    draw_primitive_begin(pr_curve_mode);
    for(int i = 0; i <= pr_curve_detail; ++i)
    {
        a2 = a*a; b2 = b*b;
        x = x1*a2 + x2*2*a*b + x3*b2;
        y = y1*a2 + y2*2*a*b + y3*b2;
        al = al1 + (al2-al1)*b;
        col = merge_color(c1, c2, b);
        draw_vertex_color(x, y,col,al);

        a -= det;
        b = 1.0 - a;
    }
    draw_primitive_end();
}
コード例 #2
0
ファイル: GLEScurves.cpp プロジェクト: DarkAceZ/enigma-dev
//The following function is used in other drawing functions for all splines
//it takes 4 points. Two control points which are at the beggining and the end, and the two points which it actually draws through
//in the middle
void draw_spline_part(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int c1, int c2, float a1, float a2)
{
    int col;
    float x, y, al, t = 0, det = 1/(float)pr_curve_detail;
    for (int i=0; i<=pr_curve_detail; i++){

        al = a1 + (a2-a1)*t;

        col = merge_color(c1, c2, t);

        float t2 = t * t, t3 = t2 * t;
        x = 0.5 * ( ( 2.0 * x2 ) + ( -x1 + x3 ) * t + ( 2.0 * x1 - 5.0 * x2 + 4 * x3 - x4 ) * t2 +
        ( -x1 + 3.0 * x2 - 3.0 * x3 + x4 ) * t3 );
        y = 0.5 * ( ( 2.0 * y2 ) + ( -y1 + y3 ) * t + ( 2.0 * y1 - 5.0 * y2 + 4 * y3 - y4 ) * t2 +
        ( -y1 + 3.0 * y2 - 3.0 * y3 + y4 ) * t3 );
        glColor4f(__GETR(col),__GETG(col),__GETB(col),al);
     //   glVertex2f(x, y);
        t += det;
    }
}