bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style) { #ifdef PDF_DEBUG NSLOG(netsurf, INFO, "."); #endif if (style->fill_type != PLOT_OP_TYPE_NONE) { apply_clip_and_mode(false, style->fill_colour, NS_TRANSPARENT, 1., DashPattern_eNone); HPDF_Page_Circle(pdf_page, x, page_height - y, radius); HPDF_Page_Fill(pdf_page); } if (style->stroke_type != PLOT_OP_TYPE_NONE) { /* FIXME: line width 1 is ok ? */ apply_clip_and_mode(false, NS_TRANSPARENT, style->stroke_colour, 1., DashPattern_eNone); HPDF_Page_Circle(pdf_page, x, page_height - y, radius); HPDF_Page_Stroke(pdf_page); } return true; }
/* * Class: org_libharu_PdfPage * Method: fill * Signature: ()V */ JNIEXPORT void JNICALL Java_org_libharu_PdfPage_fill(JNIEnv *env, jobject obj) { jint page; /* Get mHPDFPagePointer */ page = (*env)->GetIntField(env, obj, mHPDFPagePointer); HPDF_Page_Fill((HPDF_Page) page); }
bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) { unsigned int i; #ifdef PDF_DEBUG int pmaxx = p[0], pmaxy = p[1]; int pminx = p[0], pminy = p[1]; NSLOG(netsurf, INFO, "."); #endif if (n == 0) return true; apply_clip_and_mode(false, style->fill_colour, NS_TRANSPARENT, 0., DashPattern_eNone); HPDF_Page_MoveTo(pdf_page, p[0], page_height - p[1]); for (i = 1 ; i<n ; i++) { HPDF_Page_LineTo(pdf_page, p[i*2], page_height - p[i*2+1]); #ifdef PDF_DEBUG pmaxx = max(pmaxx, p[i*2]); pmaxy = max(pmaxy, p[i*2+1]); pminx = min(pminx, p[i*2]); pminy = min(pminy, p[i*2+1]); #endif } #ifdef PDF_DEBUG NSLOG(netsurf, INFO, "%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, page_height - pminy); #endif HPDF_Page_Fill(pdf_page); return true; }
JNIEXPORT void JNICALL Java_org_libharu_Page_fill (JNIEnv *env, jobject obj) { haru_setup_error_handler(env, __func__); HPDF_Page page = get_HPDF_Page(env, obj); HPDF_Page_Fill(page); haru_clear_error_handler(); }
bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *pstyle) { DashPattern_e dash; #ifdef PDF_DEBUG NSLOG(netsurf, INFO, "%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, pstyle->fill_colour); #endif if (pstyle->fill_type != PLOT_OP_TYPE_NONE) { apply_clip_and_mode(false, pstyle->fill_colour, NS_TRANSPARENT, 0., DashPattern_eNone); /* Normalize boundaries of the area - to prevent overflows. It is needed only in a few functions, where integers are subtracted. When the whole browser window is meant min and max int values are used what must be handled in paged output. */ x0 = min(max(x0, 0), page_width); y0 = min(max(y0, 0), page_height); x1 = min(max(x1, 0), page_width); y1 = min(max(y1, 0), page_height); HPDF_Page_Rectangle(pdf_page, x0, page_height - y1, x1 - x0, y1 - y0); HPDF_Page_Fill(pdf_page); } if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) { switch (pstyle->stroke_type) { case PLOT_OP_TYPE_DOT: dash = DashPattern_eDotted; break; case PLOT_OP_TYPE_DASH: dash = DashPattern_eDash; break; default: dash = DashPattern_eNone; break; } apply_clip_and_mode(false, NS_TRANSPARENT, pstyle->stroke_colour, plot_style_int_to_fixed(pstyle->stroke_width), dash); HPDF_Page_Rectangle(pdf_page, x0, page_height - y0, x1 - x0, -(y1 - y0)); HPDF_Page_Stroke(pdf_page); } return true; }
void WPdfImage::paintPath() { if (painter()->pen().style() != PenStyle::None) if (painter()->brush().style() != BrushStyle::None) HPDF_Page_FillStroke(page_); else HPDF_Page_Stroke(page_); else if (painter()->brush().style() != BrushStyle::None) HPDF_Page_Fill(page_); else HPDF_Page_EndPath(page_); }
void hpdf_doc::polygon(HPDF_Point pt[], int count) { if (count <= 0) return; HPDF_Page_MoveTo(h_current_page, pt[0].x, pt[0].y); for (int i = 1; i < count; i++) { HPDF_Page_LineTo(h_current_page, pt[i].x, pt[i].y); } HPDF_Page_LineTo(h_current_page, pt[0].x, pt[0].y); HPDF_Page_Fill(h_current_page); }
void WPdfImage::paintPath() { if (painter()->pen().style() != NoPen) if (painter()->brush().style() != NoBrush) HPDF_Page_FillStroke(page_); else HPDF_Page_Stroke(page_); else if (painter()->brush().style() != NoBrush) HPDF_Page_Fill(page_); else HPDF_Page_EndPath(page_); }
bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width, colour c, const float transform[6]) { unsigned int i; bool empty_path; #ifdef PDF_DEBUG NSLOG(netsurf, INFO, "."); #endif if (n == 0) return true; if (c == NS_TRANSPARENT && fill == NS_TRANSPARENT) return true; if (p[0] != PLOTTER_PATH_MOVE) return false; apply_clip_and_mode(false, fill, c, width, DashPattern_eNone); empty_path = true; for (i = 0 ; i < n ; ) { if (p[i] == PLOTTER_PATH_MOVE) { HPDF_Page_MoveTo(pdf_page, transform_x(transform, p[i+1], p[i+2]), transform_y(transform, p[i+1], p[i+2])); i+= 3; } else if (p[i] == PLOTTER_PATH_CLOSE) { if (!empty_path) HPDF_Page_ClosePath(pdf_page); i++; } else if (p[i] == PLOTTER_PATH_LINE) { HPDF_Page_LineTo(pdf_page, transform_x(transform, p[i+1], p[i+2]), transform_y(transform, p[i+1], p[i+2])); i+=3; empty_path = false; } else if (p[i] == PLOTTER_PATH_BEZIER) { HPDF_Page_CurveTo(pdf_page, transform_x(transform, p[i+1], p[i+2]), transform_y(transform, p[i+1], p[i+2]), transform_x(transform, p[i+3], p[i+4]), transform_y(transform, p[i+3], p[i+4]), transform_x(transform, p[i+5], p[i+6]), transform_y(transform, p[i+5], p[i+6])); i += 7; empty_path = false; } else { NSLOG(netsurf, INFO, "bad path command %f", p[i]); return false; } } if (empty_path) { HPDF_Page_EndPath(pdf_page); return true; } if (fill != NS_TRANSPARENT) { if (c != NS_TRANSPARENT) HPDF_Page_FillStroke(pdf_page); else HPDF_Page_Fill(pdf_page); } else HPDF_Page_Stroke(pdf_page); return true; }