Comments (3)
Ah, there could be a mistake ... _count_strokes doesn't work after the path-elements were removed ... So, remove_strokes should be done after coloring the kanji
from kanji-colorize.
Thanks! This is something I'd considered but never got around to so I'm really happy to get this patch.
On Dec 19, 2012, at 5:10 AM, shufps [email protected] wrote:
Hi,
Following a patch for coloring kanji-groups instead of coloring every stroke with a different color.
Example:
http://shufps.files.wordpress.com/2012/12/anki2.pngkanjicolorizer/colorizer.py
97a98,101
self._parser.add_argument('--group-mode', default='off', choices=['off', 'on'], help='Color kanji groups instead of stroke by stroke ' '(default: %(default)s)')
234a239,241
if self.settings.group_mode == 'on':
svg = self._remove_strokes(svg)239a247,249
def _remove_strokes(self, svg):
return re.sub("<text.*?", "", svg)349,350d358
< svg = re.sub('<path ', color_match, svg)
< return re.sub('<text ', color_match, svg)
351a360,391
if self.settings.group_mode != 'on':
svg = re.sub('<path ', color_match, svg)
return re.sub('<text ', color_match, svg)
else:
found = False
depth = 0
iopen = 0
lines = svg.split('\n')nsvg='' for line in lines: if line.find('<g ') != -1 or line.find('</g>') != -1: if not found: if line.find("<g ") != -1 and line.find('kvg:element') != -1: found = True #print "first element tag found" else: if line.find("</g>") != -1: if iopen != 0 and iopen == depth: iopen = 0 #print 'color group closed' depth-=1 if line.find("<g ") != -1: depth+=1 if iopen == 0 and line.find('kvg:element') != -1: iopen = depth line = re.sub('<g ', color_match, line) #print 'color group opened' nsvg+=line+"\n" return nsvg
kanji_colorizer.py:
55a56,60 > # don't color stroke by stroke but color kanji groups > config += " --group-mode " > #config += " off " > config += " on " >
�
Reply to this email directly or view it on GitHub.
from kanji-colorize.
Pull request merged a while ago
from kanji-colorize.
Related Issues (20)
- test fails with missing 0041b.svg
- clean up test setup
- general code cleanup
- investigate bug with generate all new HOT 5
- get the standard library dependencies that aren't included in anki out of the addon
- reorganize for easier development and building
- Hi there, HOT 1
- Note: If you don't have a github account you can also email me at [email protected] HOT 1
- Error with Anki 2.1.28 HOT 2
- configuration option for what characters to diagram in anki
- TypeError when generating new notes
- Option to prevent changing field if something is in it. HOT 2
- Create add-on file for manual installation HOT 3
- Direct SVG inside the Diagram Field HOT 3
- Diagram for 備
- FYI: Generated for two katakana words and got "divdivdiv(correctkatakana)divdiv"
- Stroke Order not working HOT 2
- Request: Bulk-add only to selected cards from browser or manually colorize from card editor (not on tab)
- Request: Update colorized-kanji-contrast.tgz & colorized-kanji-spectrum.tgz based on newest kanjivg data
- Readme Typo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kanji-colorize.