------------------------------------------------------------------------------
| 659 | |
| 660 | //------------------------------------------------------------------------------ |
| 661 | void vtkPDFContextDevice2D::DrawPoly(float* points, int n, unsigned char* colors, int nc_comps) |
| 662 | { |
| 663 | assert(nc_comps == 0 || colors != nullptr); |
| 664 | assert(n > 0); |
| 665 | assert(points != nullptr); |
| 666 | |
| 667 | if (this->Pen->GetLineType() == vtkPen::NO_PEN) |
| 668 | { |
| 669 | return; |
| 670 | } |
| 671 | |
| 672 | if (!colors && this->Pen->GetColorObject().GetAlpha() == 0) |
| 673 | { |
| 674 | return; |
| 675 | } |
| 676 | |
| 677 | this->PushGraphicsState(); |
| 678 | this->ApplyPenState(); |
| 679 | |
| 680 | if (colors == nullptr) |
| 681 | { |
| 682 | HPDF_Page_MoveTo(this->Impl->Page, points[0], points[1]); |
| 683 | for (int i = 1; i < n; ++i) |
| 684 | { |
| 685 | HPDF_Page_LineTo(this->Impl->Page, points[i * 2], points[i * 2 + 1]); |
| 686 | } |
| 687 | this->Stroke(); |
| 688 | } |
| 689 | else |
| 690 | { |
| 691 | vtkVector2f width = this->GetUnscaledPenWidth() * 0.5f; |
| 692 | const float radius = std::max(width[0], width[1]) * 0.5f; |
| 693 | HPDF_REAL bbox[4]; |
| 694 | GetPointBounds(points, n, bbox, radius); |
| 695 | |
| 696 | HPDF_Shading shading = HPDF_Shading_New(this->Impl->Document, |
| 697 | HPDF_SHADING_FREE_FORM_TRIANGLE_MESH, HPDF_CS_DEVICE_RGB, bbox[0], bbox[1], bbox[2], bbox[3]); |
| 698 | PolyLineToShading(points, n, colors, nc_comps, radius, shading); |
| 699 | HPDF_Page_SetShading(this->Impl->Page, shading); |
| 700 | } |
| 701 | |
| 702 | this->PopGraphicsState(); |
| 703 | } |
| 704 | |
| 705 | //------------------------------------------------------------------------------ |
| 706 | void vtkPDFContextDevice2D::DrawLines(float* f, int n, unsigned char* colors, int nc_comps) |