ntnuno v10 from 20130409 The calligraphy TikZ libraryis designedto enable calligraphic style drawings inTikZTheideaistobeabletostrokealinewithapen Asasimpleexample compare the two lines in the following picture begin center begin t i k z p i c t ID: 20832
Download Pdf The PPT/PDF document "The calligraphy Package Documentation An..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
ThecalligraphyPackage:DocumentationAndrewStaceystacey@math.ntnu.nov1.1from2016/02/19ThecalligraphyTikZlibraryisdesignedtoenablecalligraphicstyledrawingsinTikZ.Theideaistobeabletostrokealinewithapen.Asasimpleexample,comparethetwolinesinthefollowingpicture.\begin{center}\begin{tikzpicture}\pen(135:.25)(45:.25);\draw[linewidth=.5cm](0,0)..controls+(45:1)and+(135:1)..++(3,0);\calligraphy(0,1)..controls+(45:1)and+(135:1)..++(3,0);\end{tikzpicture}\end{center} ThepathsareidenticalindenitionbuttherstisdrawnusingthestandardTikZpathwithalinewidthof.5cm.Thesecondisstrokedwithacalligraphicpenofwidth.5cmangledat45degrees.1HowItWorksToknowhowtousethislibrary,itisworthknowingalittleabouthowitworks.Apenisapath,asisthelinethatisthetemplateforthepenstroke.Thetwopathsarejoinedtogethertoformaregionwhichislled.Thusinconstructingtheexamplegivenintheintroduction,thefollowingpathisbuilt.1 originalpath penpath originalpathreversed penpathreversed Whatisimportanttonoteaboutthisisthatthepenisn'tactuallydraggedalongthepath,itismerelyasimulation.Thiscanbeshownwiththefollowingsimpleexample.Therstisacontinuouspaththatgoespasttheangleofthepenandthustheupstrokewouldinvolvepushingthepen.Thesecondishowitismeanttobedone,thesecondlineisdrawnfromtoptobottom.However,asthedirectionofthepathisn'timportant,thesameeectcanbeobtainedbyliftingthenibbetweenthelines.\begin{center}\begin{tikzpicture}\pen(135:.125)(45:.125);\calligraphy(0,0)(1,0)(1,1);\calligraphy(2,0)(3,0)(3,1)(3,0);\calligraphy(4,0)(5,0)+(0,0)(5,1);\end{tikzpicture}\end{center} Itshouldworkasexpectedprovidingthefollowinggoldenruleisnotviolated:Neverpushacalligraphicpen.Thisisgoodadviceforordinarycalligraphyaswell,soapaththatisrealisableasanhonestcalligraphicpathshouldbenewiththislibrary.Actuallysince,asremarkedabove,thedirectionofthepathisn'timportant,amoreaccurategoldenrulewouldbethatoneshouldneverswapfrompushingtopullingorviceversawithoutliftingthepenothepaper;butthatisn'tassuccinct.Thepathsforbothpensandtemplatescanbereasonablycomplicated.Theycancontaingaps,butshouldnotcontainclosedpaths,norrectangles.Theimplementationworksbybreakingapathintoitsconstituentpieces(brokenupbymovetos)andworkingbitbybit.2 \begin{center}\begin{tikzpicture}\pen(135:.25)(135:.125)(45:.125)(45:.25);\calligraphy(0,0)..controls+(45:1)and+(135:1)..+(3,0)++(1.5,0)..controls+(135:2)and+(45:2)..+(0,4)(0,4)..controls+(45:1)and+(135:1)..+(3,0);\end{tikzpicture}\end{center} 2CopperplateCopperplatepensaresomewhatspecial.Theyarethinsodon'tneedthesametreatmentasathickpen,butoneshouldbeabletovarythepressurewithacopperplatepentogetavariationofthickness.Specifyingacopperplatepenisstraightforward:itisapenwithnothickness.\begin{center}\begin{tikzpicture}[linewidth=2pt]\pen(0,0);\calligraphy[heavy](0,0)..controls+(45:1)and+(135:1)..+(3,0)++(1.5,0)..controls+(135:2)and+(45:2)..+(0,3)(0,3)..controls+(45:1)and+(135:1)..+(3,0);\calligraphy[light](4,0)..controls+(45:1)and+(135:1)..+(3,0)++(1.5,0)..controls+(135:2)and+(45:2)..+(0,3)(4,3)..controls+(45:1)and+(135:1)..+(3,0);\end{tikzpicture}\end{center} 3 Withacopperplatepen,thesegmentsofapatharetapered.Copperplateandnormalpenscanbemixed.Anypartofthepenspecicationthathasnolengthistreatedasacopperplatepen.\begin{center}\begin{tikzpicture}[linewidth=1pt]\pen(135:.125)(0,0)(45:.125);\calligraphy(0,0)..controls+(45:1)and+(135:1)..+(3,0)++(1.5,0)..controls+(135:2)and+(45:2)..+(0,3)(0,3)..controls+(45:1)and+(135:1)..+(3,0);\end{tikzpicture}\end{center} 3StyleOptionsThereareplentyofoptionsforstylingthepathsandpens.3.1DenitionOptionsInternally,makingapenisatwo-stepprocess.Firstapenhastobedenedandthenprocessed.Todeneapen,theuserhastospecifyapath.Thatpathisstored4 inaglobalmacroandsocanbeaccessedinthroughoutthedocument.However,beforebeingused,thepenhastobeprocessed.Atthisstage,thepenisconvertedfromamacrointoaspecialobject.Thesespecialobjectsarelocalandcannot(atpresent)bemadeglobal.Thuswhilstapencanbedenedinsideagroup,theprocessingstagehastohappenintheoutermostgroupinwhichthepenisgoingtobeused.Thereisashortcutcommandthat(viaabitofsuspicioushackery)doesallthiswithinatikzpicturegroup.However,ifapenistobeusedinseveraldierentpictures,itmustbeprocessedoutsidethegroupinwhichitisdened.Thefollowingmacrosandkeysareusedtosetupanduseapen.Ifthedefinepenkeyisspeciedonapaththenthatpathwillbeuseddefinepentodeneapen.Itcantakeoneoptionwhichwillbethepenname,ifnotspeciedthendefaultisassumed.Theresultingpathwillnotbecountedforboundingboxconsiderations.Whenthepenisused,theoriginwillcorrespondtothepathalongwhichitisdragged.Thekeypenname=namesetsthenameforthecurrentpen.Thiscanbeusedpennameeitherwhendeningorusingapen.Themacros\penand\definepenareanalogoustotheTikZcommands\pen\definepen\drawor\fillinthattheyactlikeapathcommandbutstorethepathasapen.Thedierencebetweenthemisthat\definepenistobeusedoutsideaTikZpicture(itcontainsitsown\tikzcommand)and\peninside.Thekeyusepen=nameonapathmeansthatthatpathshouldbestrokedusepenwiththepen(defaultifnonameisgiven,ornonespeciedviathepennamekey).3.2StyleOptionsTherearevariousoptionsavailableforstylingthecalligraphicpaths.Thestyleoptionsareasfollows.Thepencolourstyledenesthedefaultcolourtobeused.Sincecalli-pencolourgraphicpathsaresometimeslledandsometimesstroked,thisensuresthatthecolourisusedcorrectly.Itispossibletostyleparticularnibs(i.e.,segmentsofthepenpath)sepa-nibstylerately.Thisisthenibstyleoption,whichtakestwoarguments.Therstistheindexofthepartofthenibandthesecondisthestyleoptionstobeapplied.Itisalsopossibletostyleparticularpartsofthetemplatepath.Onewaystrokestyletodothisistousethestrokestylekey,whichtakestwoarguments.Therstistheindexofthepartofthestrokeandthesecondisthestyleoptionstobeapplied.Itisalsopossibletostyleparticularpartsofthetemplatepathasthepaththisstrokestyleisconstructed.Thisisdonebyputting[thisstrokestyle={}]inthe5 templatepathattherelevantpart.Thestyleissavedandappliedtothatsegmentofthetemplatepath.Thetaperingofcopperplatepathscanbecontroledbythetaperoption.Ittapertakesargumentsnone,both,start,andend.Copperplatepathscomeintwoweights:heavyandlight.Theweightalsoweightheavylightaectsthetapering:bydefaultalightpathistaperedtonothingwhilstaheavypathistaperedtothewidthofalightpath.Weightscanbespeciedbyeitherweight=weightorjustheavyandlight.Itispos-sibletochangetheweightfordierentcomponentsofapathusingthestrokestylekey.Withtapering,thismeansthatonecaneasilyvaryfromalightstroketoaheavyone.Therelevantwidthsarecontrolledbythekeysheavylinewidthandthelightlinewidth.Thetaperlinewidth,heavylinewidthlightlinewidthtaperlinewidthissetautomaticallybytheweightbutcanbealteredafterwardsusingthetaperlinewidthkey.\begin{center}\begin{tikzpicture}\calligraphy[pencolour=green,nibstyle={2}{color=red}](0,0)..controls+(45:1)and+(135:1)..+(3,0)++(1.5,0)..controls+(135:2)and+(45:2)..+(0,3)(0,3)..controls+(45:1)and+(135:1)..+(3,0);\calligraphy[linewidth=1pt](0,4)..controls+(45:1)and+(135:1)..+(3,0)++(1.5,0)..controls+(135:2)and+(45:2)..+(0,3)(0,7)..controls+(45:1)and+(135:1)..+(3,0);\end{tikzpicture}\end{center} 6 4DecorationsIfaTikZ/PGFdecorationslibraryisloadedpriortothislibrary,thenthecalligraphylibrarydenessomedecorationsthatusethecalligraphicpaths,specicallywiththecopperplatenib.Thecurrentdecorationsare:calligraphicbraceforabrace.calligraphicbracecalligraphicstraightparenthesisforaparenthesiswithstraightmid-calligraphicstraightparenthesisdlecomponent.calligraphiccurvedparenthesisforaparenthesiswithacurvedmiddlecalligraphiccurvedparenthesiscomponent.Alltheaboveusetheamplitudeoptiontospecifytheirsize.Thefollowingisanexampleoftheiruse,togetherwiththestandardbraceandthedelimiterkeyfromthematrixlibraryforcomparison.7 \begin{center}\begin{tikzpicture}\draw[decorate,decoration={calligraphicbrace,amplitude=4mm},ultrathick](0,0)(0,8);\draw[linewidth=2pt,decorate,decoration={brace,amplitude=10},linecap=round](1,0)++(0,8);\node[anchor=southwest,minimumheight=8cm,outersep=0pt,leftdelimiter=\{](a)at(2,0){};\draw[decorate,decoration={calligraphicstraightparenthesis,amplitude=4mm},ultrathick](3,0)++(0,8);\draw[decorate,decoration={calligraphiccurvedparenthesis,amplitude=4mm},ultrathick](4,0)++(0,8);\node[anchor=southwest,minimumheight=8cm,outersep=0pt,leftdelimiter=(](a)at(5,0){};\end{tikzpicture}\end{center} 8]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;]TJ ; -1;.93; Td; [00;: 0BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB@ 5Pre-DenedPensThefollowingpensarepredened:copperplate:copperplate8 \begin{center}\tikz\calligraphy[copperplate](0,0)..controls+(1,1)and+(1,1)..++(3,0)[thisstrokestyle={light,taper=start}]+(0,0)..controls+(1,1)and+(1,1)..++(3,0)[thisstrokestyle={heavy}]+(0,0)..controls+(1,1)and+(1,1)..++(3,0)[thisstrokestyle={light,taper=end}];\end{center} 9