Exemple #1
0
void MWcanvas16::curve_to(
    Coord x,
    Coord y,
    Coord x1,
    Coord y1,
    Coord x2,
    Coord y2)
{
    PathRenderInfo* p = &MWcanvas16::path_;
    Coord px = p->curx_;
    Coord py = p->cury_;

    if (straight(matrix(), px, py, x1, y1, x2, y2, x, y))
    {
        line_to(x, y);
    }
    else
    {
        Coord xx = mid(x1, x2);
        Coord yy = mid(y1, y2);
        Coord x11 = mid(px, x1);
        Coord y11 = mid(py, y1);
        Coord x22 = mid(x2, x);
        Coord y22 = mid(y2, y);
        Coord x12 = mid(x11, xx);
        Coord y12 = mid(y11, yy);
        Coord x21 = mid(xx, x22);
        Coord y21 = mid(yy, y22);
        Coord cx = mid(x12, x21);
        Coord cy = mid(y12, y21);

        curve_to(cx, cy, x11, y11, x12, y12);
        curve_to(x, y, x21, y21, x22, y22);
    }
}
Exemple #2
0
void cairo_paths_c::arc_segment( double xc, double yc, float th0, float th1, double rx, double ry, double x_axis_rotation)
{
    double x1, y1, x2, y2, x3, y3;
    double t;
    double th_half;
    double sinf, cosf;

    ts::sincos((float)(x_axis_rotation * M_PI / 180.0), sinf, cosf);

    double sin_th0, cos_th0;
    ts::sincos(th0, sin_th0, cos_th0);

    double sin_th1, cos_th1;
    ts::sincos(th1, sin_th1, cos_th1);

    th_half = 0.5 * (th1 - th0);
    double sin_temp1 = sin(th_half * 0.5);

    t = (8.0 / 3.0) * sin_temp1 * sin_temp1 / sin(th_half);
    x1 = rx*(cos_th0 - t * sin_th0);
    y1 = ry*(sin_th0 + t * cos_th0);
    x3 = rx*cos_th1;
    y3 = ry*sin_th1;
    x2 = x3 + rx*(t * sin_th1);
    y2 = y3 + ry*(-t * cos_th1);

    curve_to(   xc + cosf*x1 - sinf*y1,
                yc + sinf*x1 + cosf*y1,
                xc + cosf*x2 - sinf*y2,
                yc + sinf*x2 + cosf*y2,
                xc + cosf*x3 - sinf*y3,
                yc + sinf*x3 + cosf*y3  );

}
Exemple #3
0
void spc_curve_to(snap_path_closure_t& spc, double x1, double y1_,
																			double x2, double y2,
																			double x3, double y3) {
	spc_new_path_perhaps(spc);
	snap_point(spc, x1, y1_);
	snap_point(spc, x2, y2);
	snap_point(spc, x3, y3);
	curve_to(spc.cr, POINT{ x1, y1_ }, POINT{ x2, y2 }, POINT{ x3, y3 });
}
Exemple #4
0
int main(int argc, char *argv[]) {     
    int fd;                      /* fd to Erlang node */
    unsigned char buf[BUFSIZE];  /* Buffer for incoming message */
    ErlMessage emsg;             /* Incoming message */
    int c_node;                   /* C-Node number */
    char cookie[EI_MAX_COOKIE_SIZE+1];  /* Shared cookie */
    short creation;              /* ?? */
    char *erlang_node;           /* Erlang node to connect to */
	 char *cookie_opt;				/* Where to source our cookie */
	 char *cookie_data;				/* Either the filename or literal cookie */
    ETERM *fromp, *msgp, *fnp, *argp, *resp;
    int received, loop = 1;
    
    if (argc < 5) {
        quit_with_error("invalid_args");
    }
    
    c_node = atoi(argv[1]);
    cookie_opt = argv[2];
	 cookie_data = argv[3];
    creation = 0;
    erlang_node = argv[4];
    
    erl_init(NULL, 0);

	 get_cookie(cookie_opt, cookie_data, cookie);
    
    if (!erl_connect_init(c_node, cookie, creation)) {
        quit_with_error("erl_connect_init");
    }
    
    if ((fd = erl_connect(erlang_node)) < 0) {
        quit_with_error("erl_connect"); 
    }
       
    while (loop) {
        received = erl_receive_msg(fd, buf, BUFSIZE, &emsg);

    if (received == ERL_TICK) {
        /* ignore */    
    } else if (received == ERL_ERROR) {
        loop = 0;
    } else {
        if (emsg.type == ERL_REG_SEND) {          
            fromp = erl_element(2, emsg.msg);
            msgp = erl_element(3, emsg.msg);
            fnp = erl_element(1, msgp);
            argp = erl_element(2, msgp);  
            
            if (is_function(fnp, "stop")) {
                loop = 0;
                resp = erl_format("{c_node, ~i, ok}", c_node);
            } else if (is_function(fnp, "new_image_blank")) { 
                resp = new_image_blank(argp, c_node); 
            } else if (is_function(fnp, "write_to_png")) {
                resp = write_to_png(argp, c_node);
            } else if (is_function(fnp, "close_image")) {
                resp = close_image(argp, c_node);
            } else if (is_function(fnp, "save")) {
                resp = save(argp, c_node);
            } else if (is_function(fnp, "restore")) {
                resp = restore(argp, c_node);
            } else if (is_function(fnp, "set_line_width")) {
                resp = set_line_width(argp, c_node);
            } else if (is_function(fnp, "set_source_rgba")) {
                resp = set_source_rgba(argp, c_node);	
	        } else if (is_function(fnp, "set_operator")) {
                resp = set_operator(argp, c_node);
            } else if (is_function(fnp, "move_to")) {
                resp = move_to(argp, c_node);
            } else if (is_function(fnp, "line_to")) {
                resp = line_to(argp, c_node);
            } else if (is_function(fnp, "curve_to")) {
                resp = curve_to(argp, c_node);
            } else if (is_function(fnp, "rel_move_to")) {
                resp = rel_move_to(argp, c_node);
            } else if (is_function(fnp, "rel_line_to")) {
                resp = rel_line_to(argp, c_node);
            } else if (is_function(fnp, "rel_curve_to")) {
                resp = rel_curve_to(argp, c_node);
            } else if (is_function(fnp, "rectangle")) {
                resp = rectangle(argp, c_node);
            } else if (is_function(fnp, "arc")) {
                resp = arc(argp, c_node);
            } else if (is_function(fnp, "arc_negative")) {
                resp = arc_negative(argp, c_node);
            } else if (is_function(fnp, "close_path")) {
                resp = close_path(argp, c_node);
            } else if (is_function(fnp, "paint")) {
                resp = paint(argp, c_node);
            } else if (is_function(fnp, "fill")) {
                resp = fill(argp, c_node);
            } else if (is_function(fnp, "fill_preserve")) {
                resp = fill_preserve(argp, c_node);
            } else if (is_function(fnp, "stroke")) {
                resp = stroke(argp, c_node);
            } else if (is_function(fnp, "stroke_preserve")) {
                resp = stroke_preserve(argp, c_node);
            } else if (is_function(fnp, "translate")) {
                resp = translate(argp, c_node);
            } else if (is_function(fnp, "scale")) {
                resp = scale(argp, c_node);
            } else if (is_function(fnp, "rotate")) {
                resp = rotate(argp, c_node);
            } else if (is_function(fnp, "select_font")) {
                resp = select_font_face(argp, c_node);
            } else if (is_function(fnp, "set_font_size")) {
                resp = set_font_size(argp, c_node);
            } else if (is_function(fnp, "show_text")) {
                resp = show_text(argp, c_node);
            } else if (is_function(fnp, "text_extents")) {
                resp = text_extents(argp, c_node);          
            } else if (is_function(fnp, "surface_create_from_png")) {
                resp = surface_create_from_png(argp, c_node);
            } else if (is_function(fnp, "surface_create_from_png_stream")) {
                resp = surface_create_from_png_stream(argp, c_node);
            } else if (is_function(fnp, "surface_get_width")) {
                resp = surface_get_width(argp, c_node);          
            } else if (is_function(fnp, "surface_get_height")) {
                resp = surface_get_height(argp, c_node);          
            } else if (is_function(fnp, "surface_destroy")) {
                resp = surface_destroy(argp, c_node);          
            } else if (is_function(fnp, "set_source_surface")) {
                resp = set_source_surface(argp, c_node);          
            } else if (is_function(fnp, "write_to_png_stream")) {
                resp = write_to_png_stream(argp, c_node);          
            } else {
                resp = erl_format("{c_node, ~i, {error, '~s'}}", c_node, "unknown command");
            }         
            erl_send(fd, fromp, resp);           
            erl_free_term(emsg.from); 
            erl_free_term(emsg.msg);
            erl_free_term(fromp); 
            erl_free_term(msgp);
            erl_free_term(fnp); 
            erl_free_term(argp);
            erl_free_term(resp);
      }
    }
  }
  exit(EXIT_SUCCESS);
}