# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : invisible_lines.py # Author : Stephane Grabli # Date : 04/08/2005 # Purpose : Draws all lines whose Quantitative Invisibility # is different from 0 from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, \ Operators, QuantitativeInvisibilityUP1D, SamplingShader, TrueUP1D from logical_operators import NotUP1D upred = NotUP1D(QuantitativeInvisibilityUP1D(0)) Operators.select(upred) Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred)) shaders_list = [ SamplingShader(5.0), ConstantThicknessShader(3.0), ConstantColorShader(0.7, 0.7, 0.7), ] Operators.create(TrueUP1D(), shaders_list)
thickness += it.object.attribute.thickness #end: while self.output.write('<path d="{0}" fill="none" stroke="{1}" stroke-width="{2:.2f}" />\n'.format( path, "black", (thickness.x + thickness.y) / (2 * nVertices) )) #end: shade from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, \ Operators, PolygonalizationShader, QuantitativeInvisibilityUP1D, SamplingShader, TrueUP1D from logical_operators import NotUP1D Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) shaders_list = [ SamplingShader(2.0), ConstantThicknessShader(3), ConstantColorShader(0.0, 0.0, 0.0), SVGShader(output), ] Operators.create(TrueUP1D(), shaders_list) shaders_list = [ SamplingShader(2.0), ConstantThicknessShader(1), ConstantColorShader(0.0, 0.0, 0.0), PolygonalizationShader(8), SVGShader(output), ] Operators.create(TrueUP1D(), shaders_list) output.write('</svg>');
# along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : blueprint_squares.py # Author : Emmanuel Turquin # Date : 04/08/2005 # Purpose : Produces a blueprint using square contour strokes from freestyle import ChainPredicateIterator, ConstantThicknessShader, ContourUP1D, IncreasingColorShader, \ Operators, QuantitativeInvisibilityUP1D, SameShapeIdBP1D, TextureAssignerShader, TrueUP1D from PredicatesU1D import pyHigherLengthUP1D from logical_operators import AndUP1D, NotUP1D from shaders import pyBluePrintSquaresShader, pyPerlinNoise1DShader upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ContourUP1D()) bpred = SameShapeIdBP1D() Operators.select(upred) Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred), NotUP1D(upred)) Operators.select(pyHigherLengthUP1D(200)) shaders_list = [ ConstantThicknessShader(8), pyBluePrintSquaresShader(2, 20), pyPerlinNoise1DShader(0.07, 10, 8), TextureAssignerShader(4), IncreasingColorShader(0.6, 0.3, 0.3, 0.7, 0.6, 0.3, 0.3, 0.3), ConstantThicknessShader(4), ] Operators.create(TrueUP1D(), shaders_list)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : apriori_and_causal_density.py # Author : Stephane Grabli # Date : 04/08/2005 # Purpose : Selects the lines with high a priori density and # subjects them to the causal density so as to avoid # cluttering from freestyle import ChainPredicateIterator, ConstantColorShader, ConstantThicknessShader, IntegrationType, \ Operators, QuantitativeInvisibilityUP1D, TrueBP1D from PredicatesU1D import pyDensityUP1D, pyHighViewMapDensityUP1D from logical_operators import AndUP1D, NotUP1D upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyHighViewMapDensityUP1D(0.3, IntegrationType.LAST)) Operators.select(upred) bpred = TrueBP1D() Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred), NotUP1D(QuantitativeInvisibilityUP1D(0))) shaders_list = [ ConstantThicknessShader(2), ConstantColorShader(0, 0, 0, 1), ] Operators.create(pyDensityUP1D(1, 0.1, IntegrationType.MEAN), shaders_list)
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : split_at_tvertices.py # Author : Stephane Grabli # Date : 04/08/2005 # Purpose : Draws strokes that starts and stops at Tvertices (visible or not) from freestyle import ChainSilhouetteIterator, ConstantThicknessShader, IncreasingColorShader, \ Nature, Operators, QuantitativeInvisibilityUP1D, TextureAssignerShader, TrueUP1D from PredicatesU0D import pyVertexNatureUP0D from logical_operators import NotUP1D Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) start = pyVertexNatureUP0D(Nature.T_VERTEX) ## use the same predicate to decide where to start and where to stop ## the strokes: Operators.sequential_split(start, start, 10) shaders_list = [ ConstantThicknessShader(5), IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1), TextureAssignerShader(3), ] Operators.create(TrueUP1D(), shaders_list)
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : qi2.py # Author : Stephane Grabli # Date : 04/08/2005 # Purpose : Draws lines hidden by two surfaces. # *** Quantitative Invisibility must have been # enabled in the options dialog to use this style module **** from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, \ Operators, QuantitativeInvisibilityUP1D, SamplingShader, TrueUP1D from logical_operators import NotUP1D Operators.select(QuantitativeInvisibilityUP1D(2)) Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(2))) shaders_list = [ SamplingShader(10), ConstantThicknessShader(1.5), ConstantColorShader(0.7, 0.7, 0.7, 1), ] Operators.create(TrueUP1D(), shaders_list)
# along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : split_at_highest_2d_curvature.py # Author : Stephane Grabli # Date : 04/08/2005 # Purpose : Draws the visible lines (chaining follows same nature lines) # (most basic style module) from freestyle import ChainSilhouetteIterator, ConstantThicknessShader, IncreasingColorShader, \ Operators, QuantitativeInvisibilityUP1D, TextureAssignerShader, TrueUP1D from Functions0D import pyInverseCurvature2DAngleF0D from PredicatesU0D import pyParameterUP0D from PredicatesU1D import pyHigherLengthUP1D from logical_operators import NotUP1D Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) func = pyInverseCurvature2DAngleF0D() Operators.recursive_split(func, pyParameterUP0D(0.4, 0.6), NotUP1D(pyHigherLengthUP1D(100)), 2) shaders_list = [ ConstantThicknessShader(10), IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1), TextureAssignerShader(3), ] Operators.create(TrueUP1D(), shaders_list)
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # Filename : stroke_texture.py # Author : Stephane Grabli # Date : 04/08/2005 # Purpose : Draws textured strokes (illustrate the StrokeTextureShader shader) from freestyle import BezierCurveShader, ChainSilhouetteIterator, ConstantColorShader, \ ConstantThicknessShader, Operators, QuantitativeInvisibilityUP1D, SamplingShader, \ Stroke, StrokeTextureShader, TrueUP1D from logical_operators import NotUP1D Operators.select(QuantitativeInvisibilityUP1D(0)) Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0))) shaders_list = [ SamplingShader(3), BezierCurveShader(4), StrokeTextureShader("washbrushAlpha.bmp", Stroke.DRY_MEDIUM, True), ConstantThicknessShader(40), ConstantColorShader(0, 0, 0, 1), ] Operators.create(TrueUP1D(), shaders_list)