Blender V4.3
PSStrokeRenderer.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#include "PSStrokeRenderer.h"
11#include "Canvas.h"
12
13namespace Freestyle {
14
16{
17 if (!iFileName) {
18 iFileName = "freestyle.ps";
19 }
20 // open the stream:
21 _ofstream.open(iFileName, ios::out);
22 if (!_ofstream.is_open()) {
23 cerr << "couldn't open the output file " << iFileName << endl;
24 }
25 _ofstream << "%!PS-Adobe-2.0 EPSF-2.0" << endl;
26 _ofstream << "%%Creator: Freestyle (http://artis.imag.fr/Software/Freestyle)" << endl;
27 _ofstream << "%%BoundingBox: " << 0 << " " << 0 << " " << Canvas::getInstance()->width() << " "
28 << Canvas::getInstance()->height() << endl;
29 _ofstream << "%%EndComments" << endl;
30}
31
33{
34 RenderStrokeRepBasic(iStrokeRep);
35}
36
38{
39 vector<Strip *> &strips = iStrokeRep->getStrips();
40 Strip::vertex_container::iterator v[3];
41 StrokeVertexRep *svRep[3];
42 Vec3r color[3];
43 for (vector<Strip *>::iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
44 Strip::vertex_container &vertices = (*s)->vertices();
45 v[0] = vertices.begin();
46 v[1] = v[0];
47 ++(v[1]);
48 v[2] = v[1];
49 ++(v[2]);
50
51 while (v[2] != vertices.end()) {
52 svRep[0] = *(v[0]);
53 svRep[1] = *(v[1]);
54 svRep[2] = *(v[2]);
55
56 color[0] = svRep[0]->color();
57 // color[1] = svRep[1]->color();
58 // color[2] = svRep[2]->color();
59
60 _ofstream << "newpath" << endl;
61 _ofstream << (color[0])[0] << " " << (color[0])[1] << " " << (color[0])[2] << " setrgbcolor"
62 << endl;
63 _ofstream << svRep[0]->point2d()[0] << " " << svRep[0]->point2d()[1] << " moveto" << endl;
64 _ofstream << svRep[1]->point2d()[0] << " " << svRep[1]->point2d()[1] << " lineto" << endl;
65 _ofstream << svRep[2]->point2d()[0] << " " << svRep[2]->point2d()[1] << " lineto" << endl;
66 _ofstream << "closepath" << endl;
67 _ofstream << "fill" << endl;
68
69 ++v[0];
70 ++v[1];
71 ++v[2];
72 }
73 }
74}
75
76} /* namespace Freestyle */
Class to define a canvas designed to draw style modules.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
Class to define the Postscript rendering of a stroke.
ATTR_WARN_UNUSED_RESULT const BMVert * v
virtual int height() const =0
virtual int width() const =0
static Canvas * getInstance()
Definition Canvas.h:57
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
PSStrokeRenderer(const char *iFileName=nullptr)
vector< Strip * > & getStrips()
Definition StrokeRep.h:221
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
inherits from class Rep
Definition AppCanvas.cpp:20