#  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 : tvertex_remover.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Removes TVertices

from freestyle import ChainSilhouetteIterator, ConstantColorShader, IncreasingThicknessShader, \
    Operators, QuantitativeInvisibilityUP1D, SamplingShader, TrueUP1D
from logical_operators import NotUP1D
from shaders import pyTVertexRemoverShader

Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
    IncreasingThicknessShader(3, 5),
    ConstantColorShader(0.2, 0.2, 0.2, 1),
    SamplingShader(10.0),
    pyTVertexRemoverShader(),
    ]
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 : 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)
#  Filename : multiple_parameterization.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : The thickness and the color of the strokes vary continuously
#             independently from occlusions although only
#             visible lines are actually drawn. This is equivalent
#             to assigning the thickness using a parameterization covering
#             the complete silhouette (visible+invisible) and drawing
#             the strokes using a second parameterization that only
#             covers the visible portions.

from freestyle import ChainSilhouetteIterator, ConstantColorShader, IncreasingColorShader, \
    IncreasingThicknessShader, Operators, QuantitativeInvisibilityUP1D, SamplingShader, \
    TextureAssignerShader, TrueUP1D
from shaders import pyHLRShader

Operators.select(QuantitativeInvisibilityUP1D(0))
## Chain following the same nature, but without the restriction
## of staying inside the selection (0).
Operators.bidirectional_chain(ChainSilhouetteIterator(0))
shaders_list = [
    SamplingShader(20),
    IncreasingThicknessShader(1.5, 30),
    ConstantColorShader(0.0, 0.0, 0.0),
    IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1),
    TextureAssignerShader(-1),
    pyHLRShader(),  ## this shader draws only visible portions
]
Operators.create(TrueUP1D(), shaders_list)
Exemple #4
0
#  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 : external_contour_smooth.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws a smooth external contour

from freestyle import ChainPredicateIterator, ExternalContourUP1D, IncreasingColorShader, \
    IncreasingThicknessShader, Operators, QuantitativeInvisibilityUP1D, SamplingShader, \
    SmoothingShader, TrueBP1D, TrueUP1D
from logical_operators import AndUP1D, NotUP1D

upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ExternalContourUP1D())
Operators.select(upred)
bpred = TrueBP1D()
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred),
                              NotUP1D(upred))
shaders_list = [
    SamplingShader(2),
    IncreasingThicknessShader(4, 20),
    IncreasingColorShader(1.0, 0.0, 0.5, 1, 0.5, 1, 0.3, 1),
    SmoothingShader(100, 0.05, 0, 0.2, 0, 0, 0, 1),
]
Operators.create(TrueUP1D(), shaders_list)
Exemple #5
0
# ##### END GPL LICENSE BLOCK #####

#  Filename : haloing.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : This style module selects the lines that
#             are connected (in the image) to a specific
#             object and trims them in order to produce
#             a haloing effect around the target shape

from freestyle import ChainSilhouetteIterator, Id, IncreasingColorShader, IncreasingThicknessShader, \
    Operators, QuantitativeInvisibilityUP1D, SamplingShader, TipRemoverShader, TrueUP1D
from PredicatesU1D import pyIsOccludedByUP1D
from logical_operators import AndUP1D, NotUP1D
from shaders import pyTVertexRemoverShader

# id corresponds to the id of the target object
# (accessed by SHIFT+click)
id = Id(3, 0)
upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyIsOccludedByUP1D(id))
Operators.select(upred)
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
shaders_list = [
    IncreasingThicknessShader(3, 5),
    IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1),
    SamplingShader(1.0),
    pyTVertexRemoverShader(),
    TipRemoverShader(3.0),
]
Operators.create(TrueUP1D(), shaders_list)
            # accumulate attributes
            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)
Exemple #7
0
#  Filename : sketchy_topology_broken.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : The topology of the strokes is, first, built
#             independantly from the 3D topology of objects,
#             and, second, so as to chain several times the same ViewEdge.

from ChainingIterators import pySketchyChainingIterator
from freestyle import IncreasingColorShader, IncreasingThicknessShader, Operators, \
    QuantitativeInvisibilityUP1D, SamplingShader, SmoothingShader, SpatialNoiseShader, \
    TextureAssignerShader, TrueUP1D
from shaders import pyBackboneStretcherNoCuspShader

Operators.select(QuantitativeInvisibilityUP1D(0))
## Chain 3 times each ViewEdge indpendantly from the
## initial objects topology
Operators.bidirectional_chain(pySketchyChainingIterator(3))
shaders_list = [
    SamplingShader(4),
    SpatialNoiseShader(6, 120, 2, True, True),
    IncreasingThicknessShader(4, 10),
    SmoothingShader(100, 0.1, 0, 0.2, 0, 0, 0, 1),
    pyBackboneStretcherNoCuspShader(20),
    #ConstantColorShader(0.0, 0.0, 0.0)
    IncreasingColorShader(0.2, 0.2, 0.2, 1, 0.5, 0.5, 0.5, 1),
    #IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1),
    TextureAssignerShader(4),
]
Operators.create(TrueUP1D(), shaders_list)
from PredicatesU0D import pyParameterUP0D
from PredicatesU1D import pyDensityUP1D, pyHigherLengthUP1D, pyHigherNumberOfTurnsUP1D
from logical_operators import NotUP1D
from shaders import pyNonLinearVaryingThicknessShader, pySamplingShader

Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(),
                              NotUP1D(QuantitativeInvisibilityUP1D(0)))
## Splits strokes at points of highest 2D curavture
## when there are too many abrupt turns in it
func = pyInverseCurvature2DAngleF0D()
Operators.recursive_split(func, pyParameterUP0D(0.2, 0.8),
                          NotUP1D(pyHigherNumberOfTurnsUP1D(3, 0.5)), 2)
## Keeps only long enough strokes
Operators.select(pyHigherLengthUP1D(100))
## Sorts so as to draw the longest strokes first
## (this will be done using the causal density)
Operators.sort(pyLengthBP1D())
shaders_list = [
    pySamplingShader(10),
    BezierCurveShader(30),
    SamplingShader(50),
    ConstantThicknessShader(10),
    pyNonLinearVaryingThicknessShader(4, 25, 0.6),
    TextureAssignerShader(6),
    ConstantColorShader(0.2, 0.2, 0.2, 1.0),
    TipRemoverShader(10),
]
## Use the causal density to avoid cluttering
Operators.create(pyDensityUP1D(8, 0.4, IntegrationType.MEAN), 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)
Exemple #10
0
#
#  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 : tipremover.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Removes strokes extremities

from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, \
    Operators, QuantitativeInvisibilityUP1D, SamplingShader, TipRemoverShader, TrueUP1D
from logical_operators import NotUP1D

Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
    SamplingShader(5),
    ConstantThicknessShader(3),
    ConstantColorShader(0, 0, 0),
    TipRemoverShader(20),
    ]
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 : thickness_fof_depth_discontinuity.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Assigns to strokes a thickness that depends on the depth discontinuity

from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, \
    Operators, QuantitativeInvisibilityUP1D, SamplingShader, TrueUP1D
from logical_operators import NotUP1D
from shaders import pyDepthDiscontinuityThicknessShader

Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(),
                              NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
    SamplingShader(1),
    ConstantThicknessShader(3),
    ConstantColorShader(0.0, 0.0, 0.0),
    pyDepthDiscontinuityThicknessShader(0.8, 6),
]
Operators.create(TrueUP1D(), shaders_list)