OLD | NEW |
(Empty) | |
| 1 # ##### BEGIN GPL LICENSE BLOCK ##### |
| 2 # |
| 3 # This program is free software; you can redistribute it and/or |
| 4 # modify it under the terms of the GNU General Public License |
| 5 # as published by the Free Software Foundation; either version 2 |
| 6 # of the License, or (at your option) any later version. |
| 7 # |
| 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. |
| 12 # |
| 13 # You should have received a copy of the GNU General Public License |
| 14 # along with this program; if not, write to the Free Software Foundation, |
| 15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 # |
| 17 # ##### END GPL LICENSE BLOCK ##### |
| 18 |
| 19 # Filename : japanese_bigbrush.py |
| 20 # Author : Stephane Grabli |
| 21 # Date : 04/08/2005 |
| 22 # Purpose : Simulates a big brush fr oriental painting |
| 23 |
| 24 from Freestyle import BezierCurveShader, ChainSilhouetteIterator, ConstantColorS
hader, \ |
| 25 ConstantThicknessShader, IntegrationType, Operators, QuantitativeInvisibilit
yUP1D, \ |
| 26 SamplingShader, TextureAssignerShader, TipRemoverShader |
| 27 from Functions0D import pyInverseCurvature2DAngleF0D |
| 28 from PredicatesB1D import pyLengthBP1D |
| 29 from PredicatesU0D import pyParameterUP0D |
| 30 from PredicatesU1D import pyDensityUP1D, pyHigherLengthUP1D, pyHigherNumberOfTur
nsUP1D |
| 31 from logical_operators import NotUP1D |
| 32 from shaders import pyNonLinearVaryingThicknessShader, pySamplingShader |
| 33 |
| 34 Operators.select(QuantitativeInvisibilityUP1D(0)) |
| 35 Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInv
isibilityUP1D(0))) |
| 36 ## Splits strokes at points of highest 2D curavture· |
| 37 ## when there are too many abrupt turns in it |
| 38 func = pyInverseCurvature2DAngleF0D() |
| 39 Operators.recursive_split(func, pyParameterUP0D(0.2, 0.8), NotUP1D(pyHigherNumbe
rOfTurnsUP1D(3, 0.5)), 2) |
| 40 ## Keeps only long enough strokes |
| 41 Operators.select(pyHigherLengthUP1D(100)) |
| 42 ## Sorts so as to draw the longest strokes first |
| 43 ## (this will be done using the causal density) |
| 44 Operators.sort(pyLengthBP1D()) |
| 45 shaders_list = [ |
| 46 pySamplingShader(10), |
| 47 BezierCurveShader(30), |
| 48 SamplingShader(50), |
| 49 ConstantThicknessShader(10), |
| 50 pyNonLinearVaryingThicknessShader(4, 25, 0.6), |
| 51 TextureAssignerShader(6), |
| 52 ConstantColorShader(0.2, 0.2, 0.2,1.0), |
| 53 TipRemoverShader(10), |
| 54 ] |
| 55 ## Use the causal density to avoid cluttering |
| 56 Operators.create(pyDensityUP1D(8, 0.4, IntegrationType.MEAN), shaders_list) |
OLD | NEW |