Beispiel #1
0
#  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 : nature.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Uses the NatureUP1D predicate to select the lines
#             of a given type (among Nature.SILHOUETTE, Nature.CREASE, Nature.SUGGESTIVE_CONTOURS,
#             Nature.BORDERS).
#             The suggestive contours must have been enabled in the 
#             options dialog to appear in the View Map.

from freestyle import ChainSilhouetteIterator, IncreasingColorShader, \
    IncreasingThicknessShader, Nature, Operators, TrueUP1D
from PredicatesU1D import pyNatureUP1D
from logical_operators import NotUP1D

Operators.select(pyNatureUP1D(Nature.SILHOUETTE))
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(pyNatureUP1D(Nature.SILHOUETTE)))
shaders_list = [
    IncreasingThicknessShader(3, 10),
    IncreasingColorShader(0.0, 0.0, 0.0, 1, 0.8, 0, 0, 1),
    ]
Operators.create(TrueUP1D(), shaders_list)
# ##### END GPL LICENSE BLOCK #####

#  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)
#  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 : 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)
#  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)
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

#  Filename : sequentialsplit_sketchy.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Use the sequential split with two different
#             predicates to specify respectively the starting and
#             the stopping extremities for strokes

from freestyle import ChainSilhouetteIterator, ConstantColorShader, IncreasingThicknessShader, Nature, \
    Operators, QuantitativeInvisibilityUP1D, SpatialNoiseShader, TextureAssignerShader, TrueUP1D
from PredicatesU0D import pyBackTVertexUP0D, pyVertexNatureUP0D
from logical_operators import NotUP1D

upred = QuantitativeInvisibilityUP1D(0)
Operators.select(upred)
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
## starting and stopping predicates:
start = pyVertexNatureUP0D(Nature.NON_T_VERTEX)
stop = pyBackTVertexUP0D()
Operators.sequential_split(start, stop, 10)
shaders_list = [
    SpatialNoiseShader(7, 120, 2, True, True),
    IncreasingThicknessShader(5, 8),
    ConstantColorShader(0.2, 0.2, 0.2, 1),
    TextureAssignerShader(4),
]
Operators.create(TrueUP1D(), shaders_list)
Beispiel #6
0
#  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 : near_lines.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws the lines that are "closer" than a threshold 
#             (between 0 and 1)

from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, \
    IntegrationType, Operators, QuantitativeInvisibilityUP1D, TextureAssignerShader, TrueUP1D
from PredicatesU1D import pyZSmallerUP1D
from logical_operators import AndUP1D, NotUP1D

upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyZSmallerUP1D(0.5, IntegrationType.MEAN))
Operators.select(upred)
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
shaders_list = [
    TextureAssignerShader(-1),
    ConstantThicknessShader(5),
    ConstantColorShader(0.0, 0.0, 0.0),
    ]
Operators.create(TrueUP1D(), shaders_list)
    def __init__(self, wsize, threshold, integration=IntegrationType.MEAN, sampling=2.0):
        UnaryPredicate1D.__init__(self)
        self._wsize = wsize
        self._threshold = threshold
        self._integration = integration
        self._func = DensityF1D(self._wsize, self._integration, sampling)
        self._func2 = DensityF1D(self._wsize, IntegrationType.MAX, sampling)
    def __call__(self, inter):
        c = self._func(inter)
        m = self._func2(inter)
        if c < self._threshold:
            return 1
        if m > 4*c:
            if c < 1.5*self._threshold:
                return 1
        return 0

Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(),NotUP1D(QuantitativeInvisibilityUP1D(0)))
Operators.select(pyHigherLengthUP1D(40))
## selects lines having a high anisotropic a priori density
Operators.select(pyHighDensityAnisotropyUP1D(0.3,4))
Operators.sort(pyLengthBP1D())
shaders_list = [
    SamplingShader(2.0),
    ConstantThicknessShader(2),
    ConstantColorShader(0.2,0.2,0.25,1), 
    ]
## uniform culling
Operators.create(pyDensityUP1D(3.0,2.0e-2, IntegrationType.MEAN, 0.1), shaders_list)
Beispiel #8
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 : contour.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws each object's visible contour

from freestyle import ChainPredicateIterator, ConstantThicknessShader, ContourUP1D, IncreasingColorShader, \
    Operators, QuantitativeInvisibilityUP1D, SameShapeIdBP1D, TrueUP1D
from logical_operators import AndUP1D, NotUP1D

Operators.select(AndUP1D(QuantitativeInvisibilityUP1D(0), ContourUP1D()))
bpred = SameShapeIdBP1D()
upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ContourUP1D())
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred), NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
    ConstantThicknessShader(5.0),
    IncreasingColorShader(0.8,0,0,1,0.1,0,0,1),
    ]
Operators.create(TrueUP1D(), shaders_list)
#  Date     : 04/08/2005
#  Purpose  : The topology of the strokes is built
#             so as to chain several times the same ViewEdge.
#             The topology of the objects is preserved

from ChainingIterators import pySketchyChainSilhouetteIterator
from freestyle import (
    ConstantColorShader,
    IncreasingThicknessShader,
    Operators,
    QuantitativeInvisibilityUP1D,
    SamplingShader,
    SmoothingShader,
    SpatialNoiseShader,
    TextureAssignerShader,
    TrueUP1D,
)

upred = QuantitativeInvisibilityUP1D(0)
Operators.select(upred)
Operators.bidirectional_chain(pySketchyChainSilhouetteIterator(3, True))
shaders_list = [
    SamplingShader(4),
    SpatialNoiseShader(20, 220, 2, True, True),
    IncreasingThicknessShader(4, 8),
    SmoothingShader(300, 0.05, 0, 0.2, 0, 0, 0, 0.5),
    ConstantColorShader(0.6, 0.2, 0.0),
    TextureAssignerShader(4),
]
Operators.create(TrueUP1D(), shaders_list)
Beispiel #10
0
#  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_sketchy.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws the external contour of the scene using a sketchy 
#             chaining iterator (in particular each ViewEdge can be drawn 
#             several times

from ChainingIterators import pySketchyChainingIterator
from freestyle import ExternalContourUP1D, IncreasingColorShader, IncreasingThicknessShader, \
    Operators, QuantitativeInvisibilityUP1D, SamplingShader, SmoothingShader, SpatialNoiseShader, \
    TextureAssignerShader, TrueUP1D
from logical_operators import AndUP1D, NotUP1D

upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ExternalContourUP1D()) 
Operators.select(upred)
Operators.bidirectional_chain(pySketchyChainingIterator(), NotUP1D(upred))
shaders_list = [
    SamplingShader(4),
    SpatialNoiseShader(10, 150, 2, 1, 1),
    IncreasingThicknessShader(4, 10),
    SmoothingShader(400, 0.1, 0, 0.2, 0, 0, 0, 1),
    IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1),
    TextureAssignerShader(4),
    ]
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 : apriori_density.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws lines having a high a priori density

from freestyle import ChainPredicateIterator, ConstantColorShader, ConstantThicknessShader, Operators, \
    QuantitativeInvisibilityUP1D, TrueBP1D, TrueUP1D
from PredicatesU1D import pyHighViewMapDensityUP1D
from logical_operators import AndUP1D, NotUP1D

Operators.select(AndUP1D(QuantitativeInvisibilityUP1D(0), pyHighViewMapDensityUP1D(0.1,5)))
bpred = TrueBP1D()
upred = AndUP1D(QuantitativeInvisibilityUP1D(0), pyHighViewMapDensityUP1D(0.0007,5))
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred), NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = 	[
		ConstantThicknessShader(2), 
		ConstantColorShader(0.0, 0.0, 0.0,1)
		]
Operators.create(TrueUP1D(), 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 : sketchy_topology_preserved.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : The topology of the strokes is built
#             so as to chain several times the same ViewEdge.
#             The topology of the objects is preserved

from ChainingIterators import pySketchyChainSilhouetteIterator
from freestyle import ConstantColorShader, IncreasingThicknessShader, Operators, \
    QuantitativeInvisibilityUP1D, SamplingShader, SmoothingShader, SpatialNoiseShader, \
    TextureAssignerShader, TrueUP1D

upred = QuantitativeInvisibilityUP1D(0)
Operators.select(upred)
Operators.bidirectional_chain(pySketchyChainSilhouetteIterator(3, True))
shaders_list = [
    SamplingShader(4),
    SpatialNoiseShader(20, 220, 2, True, True),
    IncreasingThicknessShader(4, 8),
    SmoothingShader(300, 0.05, 0, 0.2, 0, 0, 0, 0.5),
    ConstantColorShader(0.6, 0.2, 0.0),
    TextureAssignerShader(4),
]
Operators.create(TrueUP1D(), shaders_list)
Beispiel #13
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 : contour.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws each object's visible contour

from freestyle import ChainPredicateIterator, ConstantThicknessShader, ContourUP1D, IncreasingColorShader, \
    Operators, QuantitativeInvisibilityUP1D, SameShapeIdBP1D, TrueUP1D
from logical_operators import AndUP1D, NotUP1D

Operators.select(AndUP1D(QuantitativeInvisibilityUP1D(0), ContourUP1D()))
bpred = SameShapeIdBP1D()
upred = AndUP1D(QuantitativeInvisibilityUP1D(0), ContourUP1D())
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred),
                              NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
    ConstantThicknessShader(5.0),
    IncreasingColorShader(0.8, 0, 0, 1, 0.1, 0, 0, 1),
]
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 : ignore_small_oclusions.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : The strokes are drawn through small occlusions

from ChainingIterators import pyFillOcclusionsAbsoluteChainingIterator
from freestyle import (
    ConstantColorShader,
    ConstantThicknessShader,
    Operators,
    QuantitativeInvisibilityUP1D,
    SamplingShader,
    TrueUP1D,
)

Operators.select(QuantitativeInvisibilityUP1D(0))
# Operators.bidirectional_chain(pyFillOcclusionsChainingIterator(0.1))
Operators.bidirectional_chain(pyFillOcclusionsAbsoluteChainingIterator(12))
shaders_list = [SamplingShader(5.0), ConstantThicknessShader(3), ConstantColorShader(0.0, 0.0, 0.0)]
Operators.create(TrueUP1D(), shaders_list)
        self._integration = integration
        self._func = DensityF1D(self._wsize, self._integration, sampling)
        self._func2 = DensityF1D(self._wsize, IntegrationType.MAX, sampling)

    def __call__(self, inter):
        c = self._func(inter)
        m = self._func2(inter)
        if c < self._threshold:
            return 1
        if m > 4 * c:
            if c < 1.5 * self._threshold:
                return 1
        return 0


Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(),
                              NotUP1D(QuantitativeInvisibilityUP1D(0)))
Operators.select(pyHigherLengthUP1D(40))
## selects lines having a high anisotropic a priori density
Operators.select(pyHighDensityAnisotropyUP1D(0.3, 4))
Operators.sort(pyLengthBP1D())
shaders_list = [
    SamplingShader(2.0),
    ConstantThicknessShader(2),
    ConstantColorShader(0.2, 0.2, 0.25, 1),
]
## uniform culling
Operators.create(pyDensityUP1D(3.0, 2.0e-2, IntegrationType.MEAN, 0.1),
                 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_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)
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

#  Filename : sequentialsplit_sketchy.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Use the sequential split with two different
#             predicates to specify respectively the starting and
#             the stopping extremities for strokes 

from freestyle import ChainSilhouetteIterator, ConstantColorShader, IncreasingThicknessShader, Nature, \
    Operators, QuantitativeInvisibilityUP1D, SpatialNoiseShader, TextureAssignerShader, TrueUP1D
from PredicatesU0D import pyBackTVertexUP0D, pyVertexNatureUP0D
from logical_operators import NotUP1D

upred = QuantitativeInvisibilityUP1D(0)
Operators.select(upred)
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
## starting and stopping predicates:
start = pyVertexNatureUP0D(Nature.NON_T_VERTEX)
stop = pyBackTVertexUP0D()
Operators.sequential_split(start, stop, 10)
shaders_list = [
    SpatialNoiseShader(7, 120, 2, True, True),
    IncreasingThicknessShader(5, 8),
    ConstantColorShader(0.2, 0.2, 0.2, 1),
    TextureAssignerShader(4),
    ]
Operators.create(TrueUP1D(), shaders_list)
Beispiel #18
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 : apriori_density.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws lines having a high a priori density

from freestyle import ChainPredicateIterator, ConstantColorShader, ConstantThicknessShader, Operators, \
    QuantitativeInvisibilityUP1D, TrueBP1D, TrueUP1D
from PredicatesU1D import pyHighViewMapDensityUP1D
from logical_operators import AndUP1D, NotUP1D

Operators.select(
    AndUP1D(QuantitativeInvisibilityUP1D(0), pyHighViewMapDensityUP1D(0.1, 5)))
bpred = TrueBP1D()
upred = AndUP1D(QuantitativeInvisibilityUP1D(0),
                pyHighViewMapDensityUP1D(0.0007, 5))
Operators.bidirectional_chain(ChainPredicateIterator(upred, bpred),
                              NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
    ConstantThicknessShader(2),
    ConstantColorShader(0.0, 0.0, 0.0, 1)
]
Operators.create(TrueUP1D(), shaders_list)
#  Filename : japanese_bigbrush.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Simulates a big brush fr oriental painting

from freestyle import BezierCurveShader, ChainSilhouetteIterator, ConstantColorShader, \
    ConstantThicknessShader, IntegrationType, Operators, QuantitativeInvisibilityUP1D, \
    SamplingShader, TextureAssignerShader, TipRemoverShader
from Functions0D import pyInverseCurvature2DAngleF0D
from PredicatesB1D import pyLengthBP1D
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),
Beispiel #20
0
#  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)
Beispiel #21
0
#  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 : uniformpruning_zsort.py
#  Authors  : Fredo Durand, Stephane Grabli, Francois Sillion, Emmanuel Turquin 
#  Date     : 08/04/2005

from freestyle import ChainSilhouetteIterator, ConstantColorShader, ConstantThicknessShader, IntegrationType, \
    Operators, QuantitativeInvisibilityUP1D, SamplingShader, Stroke, StrokeTextureShader
from PredicatesB1D import pyZBP1D
from PredicatesU1D import pyDensityUP1D

Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator())
#Operators.sequential_split(pyVertexNatureUP0D(Nature.VIEW_VERTEX), 2)
Operators.sort(pyZBP1D())
shaders_list = [
    StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False),
    ConstantThicknessShader(3),
    SamplingShader(5.0),
    ConstantColorShader(0, 0, 0, 1),
    ]
Operators.create(pyDensityUP1D(2, 0.05, IntegrationType.MEAN, 4), shaders_list)
#Operators.create(pyDensityFunctorUP1D(8, 0.03, pyGetInverseProjectedZF1D(), 0, 1, IntegrationType.MEAN), shaders_list)
Beispiel #22
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 : nature.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Uses the NatureUP1D predicate to select the lines
#             of a given type (among Nature.SILHOUETTE, Nature.CREASE, Nature.SUGGESTIVE_CONTOURS,
#             Nature.BORDERS).
#             The suggestive contours must have been enabled in the
#             options dialog to appear in the View Map.

from freestyle import ChainSilhouetteIterator, IncreasingColorShader, \
    IncreasingThicknessShader, Nature, Operators, TrueUP1D
from PredicatesU1D import pyNatureUP1D
from logical_operators import NotUP1D

Operators.select(pyNatureUP1D(Nature.SILHOUETTE))
Operators.bidirectional_chain(ChainSilhouetteIterator(),
                              NotUP1D(pyNatureUP1D(Nature.SILHOUETTE)))
shaders_list = [
    IncreasingThicknessShader(3, 10),
    IncreasingColorShader(0.0, 0.0, 0.0, 1, 0.8, 0, 0, 1),
]
Operators.create(TrueUP1D(), shaders_list)
Beispiel #23
0
# ##### END GPL LICENSE BLOCK #####

#  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)
Beispiel #24
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)
Beispiel #25
0
#  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)
#  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)
#
#  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 : ignore_small_oclusions.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : The strokes are drawn through small occlusions

from ChainingIterators import pyFillOcclusionsAbsoluteChainingIterator
from freestyle import ConstantColorShader, ConstantThicknessShader, Operators, \
    QuantitativeInvisibilityUP1D, SamplingShader, TrueUP1D

Operators.select(QuantitativeInvisibilityUP1D(0))
#Operators.bidirectional_chain(pyFillOcclusionsChainingIterator(0.1))
Operators.bidirectional_chain(pyFillOcclusionsAbsoluteChainingIterator(12))
shaders_list = [
    SamplingShader(5.0),
    ConstantThicknessShader(3),
    ConstantColorShader(0.0, 0.0, 0.0),
]
Operators.create(TrueUP1D(), shaders_list)