U e5d @sDdZddlTddZddZddZed kr@eZeeed S) a turtle-example-suite: xtx_lindenmayer_indian.py Each morning women in Tamil Nadu, in southern India, place designs, created by using rice flour and known as kolam on the thresholds of their homes. These can be described by Lindenmayer systems, which can easily be implemented with turtle graphics and Python. Two examples are shown here: (1) the snake kolam (2) anklets of Krishna Taken from Marcia Ascher: Mathematics Elsewhere, An Exploration of Ideas Across Cultures )*cCs4t|D]&}d}|D]}||||}q|}q|S)N)rangeget)seqZreplacementRulesniZnewseqZelementr ./usr/lib64/python3.8/turtledemo/lindenmayer.pyreplaces  r c CsR|D]H}z||Wqtk rJzt|||Wn YnXYqXqdS)N) TypeErrordraw)ZcommandsZrulesbr r r r &sr cCsdd}dd}dd}|||dd}d d i}d }t||d }ttd td dtttdtt||ddl m }|d dd}dd} dd} || | d} ddd} d} ttdtd dtt dt| | d }t|| td dS)NcSs tddSN-)rightr r r r r7szmain..rcSs tddSr)leftr r r r l:szmain..lcSs tddS)Ng@)forwardr r r r f=szmain..fzf+f+f--f--f+f+f)-+rrrzb+f+b--f--b+f+bz b--f--b--fr)sleepcSstdtdddS)NZred Z)colorcircler r r r AVszmain..AcSs>ddlm}tdd|d}t|t|dt|dS)Nr)sqrtZblacki)Zmathr"rrr )r"rr r r BZs    zmain..BcSstdtddS)NZgreenr)rrr r r r Fbszmain..F)arrZafbfaZ afbfbfbfa)r'rZfbfbfbfbrzDone!) r resetZspeedZtracerZhtZupZbackwardZdownr timerr)rrrZ snake_rulesZsnake_replacementRulesZ snake_startZdrawingrr!r%r&Z krishna_rulesZkrishna_replacementRulesZ krishna_startr r r main1s@         r*__main__N) __doc__Zturtler r r*__name__msgprintZmainloopr r r r s C