/* - currentpoint <x> <y> */ static int zcurrentpoint(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_point pt; int code = gs_currentpoint(igs, &pt); if (code < 0) return code; push(2); make_real(op - 1, pt.x); make_real(op, pt.y); return 0; }
static int vu_begin_image(px_state_t * pxs) { px_vendor_state_t *v_state = pxs->vendor_state; gs_image_t image = v_state->image; px_bitmap_params_t params; gs_point origin; int code; if (v_state->color_space == eGraySub) params.color_space = eGray; else params.color_space = eSRGB; params.width = params.dest_width = v_state->SourceWidth; params.height = params.dest_height = v_state->BlockHeight; params.depth = 8; params.indexed = false; code = px_image_color_space(&image, ¶ms, (const gs_string *)&pxs->pxgs->palette, pxs->pgs); if (code < 0) { return code; } /* Set up the image parameters. */ if (gs_currentpoint(pxs->pgs, &origin) < 0) return_error(errorCurrentCursorUndefined); image.Width = v_state->SourceWidth; image.Height = v_state->BlockHeight; { gs_matrix imat, dmat; gs_make_scaling(image.Width, image.Height, &imat); gs_make_translation(origin.x, origin.y + v_state->StartLine, &dmat); gs_matrix_scale(&dmat, image.Width, image.Height, &dmat); /* The ImageMatrix is dmat' * imat. */ gs_matrix_invert(&dmat, &dmat); gs_matrix_multiply(&dmat, &imat, &image.ImageMatrix); } image.CombineWithColor = true; image.Interpolate = pxs->interpolate; code = pl_begin_image(pxs->pgs, &image, &v_state->info); if (code < 0) return code; return 0; }
/* set variables other than setting the page device that do not default to pcl reset values */ void pxPassthrough_pcl_state_nonpage_exceptions(px_state_t * pxs) { /* xl cursor -> pcl cursor position */ gs_point xlcp, pclcp, dp; /* make the pcl ctm active, after resets the hpgl/2 ctm is active. */ pcl_set_graphics_state(global_pcs); /* xl current point -> device point -> pcl current point. If anything fails we assume the current point is not valid and use the cap from the pcl state initialization - pcl's origin */ if (gs_currentpoint(pxs->pgs, &xlcp) || gs_transform(pxs->pgs, xlcp.x, xlcp.y, &dp) || gs_itransform(global_pcs->pgs, dp.x, dp.y, &pclcp)) { global_pcs->cap.x = 0; global_pcs->cap.y = inch2coord(2.0 / 6.0); /* 1/6" off by 2x in resolution. */ if (gs_debug_c('i')) dmprintf2(pxs->memory, "passthrough: changing cap NO currentpoint (%d, %d) \n", global_pcs->cap.x, global_pcs->cap.y); } else { if (gs_debug_c('i')) dmprintf8(pxs->memory, "passthrough: changing cap from (%d,%d) (%d,%d) (%d, %d) (%d, %d) \n", global_pcs->cap.x, global_pcs->cap.y, (coord) xlcp.x, (coord) xlcp.y, (coord) dp.x, (coord) dp.y, (coord) pclcp.x, (coord) pclcp.y); global_pcs->cap.x = (coord) pclcp.x; global_pcs->cap.y = (coord) pclcp.y; } if (global_pcs->underline_enabled) global_pcs->underline_start = global_pcs->cap; global_char_angle = pxs->pxgs->char_angle; global_char_shear.x = pxs->pxgs->char_shear.x; global_char_shear.y = pxs->pxgs->char_shear.y; global_char_scale.x = pxs->pxgs->char_scale.x; global_char_scale.y = pxs->pxgs->char_scale.y; global_char_bold_value = pxs->pxgs->char_bold_value; }
void pcl_mark_page_for_current_pos(pcl_state_t *pcs) { /* nothing to do */ if ( pcs->page_marked ) return; /* convert current point to device space and check if it is inside device rectangle for the page */ { gs_fixed_rect page_bbox_fixed = pcs->xfm_state.dev_print_rect; gs_rect page_bbox_float; gs_point current_pt, dev_pt; page_bbox_float.p.x = fixed2float(page_bbox_fixed.p.x); page_bbox_float.p.y = fixed2float(page_bbox_fixed.p.y); page_bbox_float.q.x = fixed2float(page_bbox_fixed.q.x); page_bbox_float.q.y = fixed2float(page_bbox_fixed.q.y); if ( gs_currentpoint(pcs->pgs, ¤t_pt) < 0 ) { dprintf("Not expected to fail\n" ); return; } if ( gs_transform(pcs->pgs, current_pt.x, current_pt.y, &dev_pt) ) { dprintf("Not expected to fail\n" ); return; } /* half-open lower - not sure this is correct */ if ( dev_pt.x >= page_bbox_float.p.x && dev_pt.y >= page_bbox_float.p.y && dev_pt.x < page_bbox_float.q.x && dev_pt.y < page_bbox_float.q.y ) pcs->page_marked = true; } }
int gs_arcto(gs_state * pgs, floatp ax1, floatp ay1, floatp ax2, floatp ay2, floatp arad, float retxy[4]) { double xt0, yt0, xt2, yt2; gs_point up0; #define ax0 up0.x #define ay0 up0.y /* Transform the current point back into user coordinates. */ int code = gs_currentpoint(pgs, &up0); if (code < 0) return code; { double dx0, dy0, dx2, dy2, sql0, sql2; /* Now we have to compute the tangent points. */ /* Basically, the idea is to compute the tangent */ /* of the bisector by using tan(x+y) and tan(z/2) */ /* formulas, without ever using any trig. */ dx0 = ax0 - ax1; dy0 = ay0 - ay1; dx2 = ax2 - ax1; dy2 = ay2 - ay1; /* Compute the squared lengths from p1 to p0 and p2. */ sql0 = dx0 * dx0 + dy0 * dy0; sql2 = dx2 * dx2 + dy2 * dy2; if (sql0 == 0. || sql2 == 0.) return_error(gs_error_undefinedresult); /* for CET 11-04 */ /* Check for collinear points. */ if (dx0*dy2 == dy0*dx2) { code = gs_lineto(pgs, ax1, ay1); xt0 = xt2 = ax1; yt0 = yt2 = ay1; } else { /* not collinear */ /* Compute the distance from p1 to the tangent points. */ /* This is the only messy part. */ double num = dy0 * dx2 - dy2 * dx0; double denom = sqrt(sql0 * sql2) - (dx0 * dx2 + dy0 * dy2); double dist = fabs(arad * num / denom); double l0 = dist / sqrt(sql0), l2 = dist / sqrt(sql2); arc_curve_params_t arc; arc.ppath = pgs->path; arc.pis = (gs_imager_state *) pgs; arc.radius = arad; arc.action = arc_lineto; arc.notes = sn_none; if (arad < 0) l0 = -l0, l2 = -l2; arc.p0.x = xt0 = ax1 + dx0 * l0; arc.p0.y = yt0 = ay1 + dy0 * l0; arc.p3.x = xt2 = ax1 + dx2 * l2; arc.p3.y = yt2 = ay1 + dy2 * l2; arc.pt.x = ax1; arc.pt.y = ay1; code = arc_add(&arc, false); if (code == 0) code = gx_setcurrentpoint_from_path((gs_imager_state *)pgs, pgs->path); } } if (retxy != 0) { retxy[0] = xt0; retxy[1] = yt0; retxy[2] = xt2; retxy[3] = yt2; } return code; }