imagetooth-2.0.1/0000755000175000017500000000000011611570453013217 5ustar gramosgramosimagetooth-2.0.1/images/0000755000175000017500000000000011611570453014464 5ustar gramosgramosimagetooth-2.0.1/images/rwwng.png0000644000175000017500000000112611611570453016336 0ustar gramosgramosPNG  IHDR%4NbKGD X pHYsHHFk> vpAg%0IDATX=o@;SGtaiy$}M% Ht 7ЁɤkY܌qi(>P/<4Bw F0B!n4Ϗ[7/\F\sS}J69|fmй,]`65"q * K?&n}sRV 0+ ˮ6_i0 ۟auR[jK-ጰBI/n c1>Z[[[[[[[[[7 Qu-rO*P$mڦ+Œ°^utIt~PY`.?Cvm2a-۲ @</\ sax}o LuV)%tEXtdate:create2011-06-21T23:36:45-03:00P%tEXtdate:modify2011-06-21T23:36:45-03:00!BZ}IENDB`imagetooth-2.0.1/images/rwwww.png0000644000175000017500000000116511611570453016372 0ustar gramosgramosPNG  IHDR%4NbKGD X pHYsHHFk> vpAg%0IDATX=k@PnjD\\3 ] _)!Z2e%]&t z`CQx0B!YwBtw-ђdSJ|8pӗh }흺ěxosSO.f=ϗZ/~^ڇ2h)@ ka-9a4-Im Y{֞Ybc15sEOSo+ - - - - - - - - - ˋ.O}p<,<z0 0F(k;3»d5f܌72z^WT;N ^I$Dml۲9\تjZ;S?/0D%e_cw[0>k%tEXtdate:create2011-06-21T23:36:13-03:00{/ٟ%tEXtdate:modify2011-06-21T23:36:13-03:00 ra#IENDB`imagetooth-2.0.1/images/wwwww.png0000644000175000017500000000073011611570453016374 0ustar gramosgramosPNG  IHDR%I=@bKGD1 pHYsHHFk> vpAg%0IDATHcd`N12Bh&˴H 3 ߾V*N}%~/ղJe]FiLYtSe᭡bX;ɒ-gdDJZ6j٨eZ6j٨eZH&R*yrJb %tEXtdate:create2011-06-21T23:30:35-03:00Wě%tEXtdate:modify2011-06-21T23:30:35-03:00&##IENDB`imagetooth-2.0.1/images/rwwwg.png0000644000175000017500000000115611611570453016352 0ustar gramosgramosPNG  IHDR%4NbKGD X pHYsHHFk> vpAg%0IDATX?k@PnjH y.BB`ɢ!8|b2eN.YqCBpuzxr%4< !؉4w_kS?H߳G~8H$d$eR[W&ycޘ7rXO6M~=g0R /&Iw=/3.w a3l»0[l)u?"W &[ &[ &[ &[ &[ &[ &[ &[ &[w vRhuT.Kea4"{BTԒZM7<(+ֶVpN)^$ < xTuu7x/:隮=t=W)Ma z%tEXtdate:create2011-06-21T23:36:28-03:00%tEXtdate:modify2011-06-21T23:36:28-03:002:IENDB`imagetooth-2.0.1/imagetooth-2.0.0.gem0000644000175000017500000005200011611570453016501 0ustar gramosgramosdata.tar.gz0000644000000000000000000003514000000000000013322 0ustar00wheelwheel00000000000000WN} |ոr-J@97`)Ȓo'm%$k;$g%ŒV,$\(PJh)j @[ r_RRB9RА쮮$$ĖWsyy3%jl6S@)][[$> Mrɘb@UMlƾ/sNO׼)~|C|k-!r zv^~w—c`\ԯʟUTlsJ#ؿx;϶9`3jݶݴ_Wr;ۊs+Ϻ=Ӓo{G?:遞Y= m!羶;Դ4 nmX؅5m>wͻwڦ}kV㨦#?XO_s/ \zu[ߒ~o]tY'~~7^$7}ף}ǩ >zuyշn=F9|['{oL_dk^N%agv묝ΞV꼥~q>~fs/UT\Lo_{sz ~.y\q_<י}íتc{:p%'_^q'ԭhw{u.J͟yP>Otv^x| gx=:o<8od7fw8|=[{O>L̃>>im͔l3Ͼ2:7 ߺ{Vn󋻚?z}Վ_޾nI;E;?w]|gN7wdbo?M?=c+v}gO5ߺPµC{͞7[k5hŦz&bSԃ 4$I?Ms}Mo[)+?íǵ_2kSYd(;DcKO\yZשgvںkFλvUW>8my{b_㫏f]LL89㉉NwgէG䩹_^}e^Ӏu}HiϚWwcm:TC>_3.]lÁ?:ˏ? w~gwNLd8{G~zs0AuYgxus|Ig8սϹ%늊W7oQ+6.bkZA7E:Iĺ쿭7 y6J;aausn\Lw.}g~[ד/gm3??NqChyv}`g|;z?7>WQqƋ=ywGښ/.{_qcߺg|CVLvj.eͻ}d^|a^_'_;޺K/f}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ҿl?6{U~>nҭJpm`|WF#z data.tar.gz.sig0000644000000000000000000000040000000000000014072 0ustar00wheelwheel00000000000000tU \ƒM%P5jۋz#aBmvQ$xC>/f9Tl/~[&jPv Q1xgd!9WQl1 nӡF?zs=N+{lY>+pY+x ^6b2L@4@ZȻ0_6p: ɡS5;!C%߻޿ղZGܷR'Wt**26Ѷo6^3~acQjmetadata.gz.sig0000644000000000000000000000040000000000000014154 0ustar00wheelwheel00000000000000 [(W ߆*s:CY;a7]_^!(^rUAEkeE)A^g}dُ2#~>]uPpwƼ߷'JI3= ZǨ8w@MȾ18PJa`),^<5 sϲ:lF2gŖ]>iP-?ꤸ5tCڐZj )o5>u9="UvdUϰ]:i/wYKlf%AD*imagetooth-2.0.1/README.markdown0000644000175000017500000000347711611570453015733 0ustar gramosgramos ImageTooth 2.0.0 ================ ImageTooth is a library that provides programmers and users a simple way to generate images for odontograms. IT allows to choose between png or jpg images. What Does ImageTooth Do? ------------------------ ### Tooth image generation. Together with the library there is a simple script that allows you to create the teeth images directly. A simple interface for painting teeth faces. All permutations generating. Example: ------- First, you need to install the gem: gem install imagetooth Then, you can run the imagetooth command, like this: imagetooth --image wwwww.png --folder ./ This code generates an image where the filename's characters means: * w - White * g - Green * b - Blue * n - Black * r - Red and are ordered, begining on the upper face of the the tooth and moving clockwise ending on the center face. [top][right][bottom][left][center].png ![wwwww.png](https://github.com/gramos/imagetooth/blob/master/images/wwwww.png?raw=true) More examples ------------- Generate a tooth with its top face painted with red:![wwwww.png](https://github.com/gramos/imagetooth/blob/master/images/rwwww.png?raw=true) imagetooth --image rwwww.png --folder ./ Generate a tooth with its top face painted red and center one green:![wwwww.png](https://github.com/gramos/imagetooth/blob/master/images/rwwwg.png?raw=true) imagetooth --image rwwwg.png --folder ./ Generate a tooth with top face painted red, left one black and center one green:![wwwww.png](https://github.com/gramos/imagetooth/blob/master/images/rwwng.png?raw=true) imagetooth --image rwwng.png --folder ./ All permutations with 5 faces and 5 colors (3125) imagetooth --all --folder images/ this code generates 3125 images that are separated within five folders images/w/ images/g/ images/b/ images/r/ images/n/ imagetooth-2.0.1/spec/0000755000175000017500000000000011611570453014151 5ustar gramosgramosimagetooth-2.0.1/spec/image_tooth_spec.rb0000644000175000017500000000574511611570453020022 0ustar gramosgramos########################################################################## # Copyright (C) 2007 Ramos, Gastón - ramos.gaston@gmail.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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. # ######################################################################### require 'image_tooth' describe "Image Tooth" do before(:each) do @img_tooth = ImageTooth.new @base_img = 'base_tooth.png' @painted_tooth = 'painted_tooth.png' end def delete_img File.delete(@img_tooth.root_path + "/" + @base_img) \ if File.exists?(@img_tooth.root_path + "/" + @base_img) File.delete(@img_tooth.root_path + "/" + @painted_tooth) \ if File.exists?(@img_tooth.root_path + "/" + @painted_tooth) end def delete_folders ImageTooth.chars_colors{ |d| Dir.rmdir(@img_tooth.root_path + "/" + d) } end it "One color should be just one character" do @img_tooth.wrap_color(:r).should == 'red' @img_tooth.wrap_color(:g).should == 'green' @img_tooth.wrap_color(:w).should == 'white' @img_tooth.wrap_color(:n).should == 'black' @img_tooth.wrap_color(:b).should == 'blue' end it "Should be generate base image tooth" do @img_tooth.graph_base(@base_img) File.exists?(@img_tooth.root_path + "/" + @base_img).should be_true delete_img end it "Should be generate image with face painted, on base image" do hash_faces = { :top => 'blue', :right => 'white', :bottom => 'white', :left => 'white', :center => 'white' } @img_tooth.graph_base @img_tooth.paint hash_faces, @painted_tooth File.exists?(@img_tooth.root_path + "/" + @painted_tooth).should be_true delete_img hash_faces = { :top => 'blue', :right => 'green', :bottom => 'red', :left => 'black', :center => 'white' } @img_tooth.graph_base @img_tooth.paint hash_faces, @painted_tooth File.exists?(@img_tooth.root_path + "/" + @painted_tooth).should be_true end it "Should be generate image with face painted, on base image" do file_tooth = 'wrrgw.png' @img_tooth.graph_base @img_tooth.paint_img file_tooth File.exists?(@img_tooth.root_path + "/" + 'wrrgw.png').should be_true delete_img end it "Should have five colors chars" do [:w, :n, :r, :b, :g].each do |c| ImageTooth.chars_colors.should include c end end it "Should be generate a hash based on file name " do hash_faces = { :top => 'white', :right => 'white', :bottom => 'green', :left => 'green', :center => 'white' } @img_tooth.file_name2hash_faces('wwggw.png').should == hash_faces end end imagetooth-2.0.1/spec/array_spec.rb0000644000175000017500000000215111611570453016625 0ustar gramosgramos########################################################################## # Copyright (C) 2007 Ramos, Gastón - ramos.gaston@gmail.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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. # ######################################################################### $LOAD_PATH << '../lib' require 'array_adds' describe "Array" do it "Should be generate color sequence" do char_colors = ['r', 'w'] char_colors.permut(2).should == [["r", "r"], ["r", "w"], ["w", "r"], ["w", "w"]] end it "Should be generate color sequence" do char_colors = [['r', 'w'], ['r', 'w']] char_colors.sequence.should == [["r", "r"], ["r", "w"], ["w", "r"], ["w", "w"]] end end imagetooth-2.0.1/spec/wrrgw.png0000644000175000017500000000052611611570453016032 0ustar gramosgramosPNG  IHDR%<IDATH1k@=P tiqv(twn k@H'ǒ=LK| ;CPKKNoy?ރ "`7 >=c^V^~gAj 6`Y]qηݮ`ɭF;2!<~l'IEig~a//p_TzшF4!RYZw|(xK <.OX"~_+gbm=5r zat%qK;TO;ͲvKIENDB`imagetooth-2.0.1/LICENSE0000644000175000017500000004310211611570453014224 0ustar gramosgramos GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. imagetooth-2.0.1/data.tar.gz.sig0000644000175000017500000000040011611570453016032 0ustar gramosgramosvZ+Ul?׭)E9J;\-z3}~ g|U8WUezU}9AV;*Qy=\K\o$8L.~3}Is䦐"2DQ8?4²R6^[:[ǤԾ˰{~f9 5j&(Bx1Qfi/ǣ=<'d=Ja+^t2-dl?xFO\Cimagetooth-2.0.1/bin/0000755000175000017500000000000011611570453013767 5ustar gramosgramosimagetooth-2.0.1/bin/imagetooth0000755000175000017500000000240311611570453016054 0ustar gramosgramos#!/usr/bin/ruby ########################################################################## # Copyright (C) 2007 Ramos, Gastón - ramos.gaston@gmail.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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. # ######################################################################### lib_path = File.expand_path(File.dirname(__FILE__)) lib_path = File.join lib_path, "../lib" $LOAD_PATH << lib_path require 'optparse' require 'image_tooth' require 'arg_parser' require 'ostruct' require 'pp' opt = ArgParser.parse(ARGV) if (opt.all and opt.folder) @img_tooth = ImageTooth.new @img_tooth.root_path = opt.folder @img_tooth.create_folders @img_tooth.gen_all elsif (opt.image and opt.folder) @img_tooth = ImageTooth.new @img_tooth.root_path = opt.folder @img_tooth.paint_img opt.image else ArgParser.parse(["-h"]) end imagetooth-2.0.1/TODO0000644000175000017500000000000011611570453013675 0ustar gramosgramosimagetooth-2.0.1/Gemfile0000644000175000017500000000007511611570453014514 0ustar gramosgramossource "http://rubygems.org" gem "rspec", :require => "spec" imagetooth-2.0.1/metadata.yml0000644000175000017500000000620511611570453015525 0ustar gramosgramos--- !ruby/object:Gem::Specification name: imagetooth version: !ruby/object:Gem::Version prerelease: version: 2.0.1 platform: ruby authors: - Gaston Ramos autorequire: bindir: bin cert_chain: - | -----BEGIN CERTIFICATE----- MIIDOjCCAiKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxyYW1v cy5nYXN0b24xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW A2NvbTAeFw0wNzA3MDIwMjQ2MjlaFw0wODA3MDEwMjQ2MjlaMEMxFTATBgNVBAMM DHJhbW9zLmdhc3RvbjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCPYSFWY X84Ad0BeqY0nqUzkXbFkG6FRgz3op6N0uuT5W+B32NMthbwBWCjpje1WXg4qmLOY zaT6Kg1lR44+8Z4iT+xc+jc/GKgnBNitn+EJUPwwSQjRxlLsHd/nIB86FOiRW23C G++sB4fz7cfUIOjWL4nETfM/a+NbG8ksyYfu5HzTD5+HBdaWtG9ICvJg1tZpNVtK w4QZT38A1ll+wYO5cJg8KI3M07ilKIyxHV75sIq8rvteQRj6RTXYxG+mHtUGMoKr qSzYguy33PFx4Vd3WuDlYg3B4HB2S9ScQeVY9/xb0TTqP3YV0+Dfe7RdkOUpGkwQ wUvF7O3w6OZucQIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV HQ4EFgQUb10QHOXGast/GmehBgBVArTqlD8wDQYJKoZIhvcNAQEFBQADggEBADNv dirPPuJfL3nHUL34mZCgLDdB7Jk4YfHnIEFMLONFrOrqRM+jdttVUMMwsd0KN9aU rCJK9k4GbzwtZ1oZHCkqRCCzotd19CJ8ufySVfQdP0TDe01YnmicuJhGDFzibugF a4WnYFPSCl3fRtqOc4eHvFnxjiqmhhJU95Y5QuTt89O7Ga6CVlAhULM5Y1oLlhFw oCxaP/8LIlhm5acz3jU7O7QoZBl4YO5fCL4JJuwfll3goNKPxgLU6xQgEc2ce+N3 UorTvCTievJjwoYltJnJWN3zLkfiMPsDsapwi/J+vUuH941ugJKAATft1XZxHYbh 0xQa9X7YkXMgjqAHAC4= -----END CERTIFICATE----- date: 2011-07-18 00:00:00 -03:00 default_executable: imagetooth dependencies: - !ruby/object:Gem::Dependency name: rmagick prerelease: false requirement: &id001 !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version version: 2.13.1 type: :runtime version_requirements: *id001 description: | This library allows to generate images of teeth for odontograms with tooth faces painted in a color (red, green, blue, white or black for example). This is very usefull for dental applications. email: ramos.gaston@gmail.com executables: - imagetooth extensions: [] extra_rdoc_files: [] files: - images/rwwng.png - images/rwwww.png - images/wwwww.png - images/rwwwg.png - imagetooth-2.0.0.gem - README.markdown - spec/image_tooth_spec.rb - spec/array_spec.rb - spec/wrrgw.png - LICENSE - bin/imagetooth - TODO - Gemfile - imagetooth.gemspec - Gemfile.lock - lib/array_adds.rb - lib/image_tooth.rb - lib/arg_parser.rb has_rdoc: true homepage: http://rubyforge.org/projects/imagetooth licenses: [] post_install_message: rdoc_options: [] require_paths: - lib - bin - . required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version version: 1.9.2 required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version version: "0" requirements: [] rubyforge_project: imagetooth rubygems_version: 1.6.2 signing_key: specification_version: 3 summary: This library allows to generate images of teeth for odontograms with tooth faces painted in a color (red, green, blue, white or black for example). This is very usefull for dental applications.. test_files: [] imagetooth-2.0.1/imagetooth.gemspec0000644000175000017500000000246711611570453016735 0ustar gramosgramosrequire 'date' Gem::Specification.new do |s| s.name = %q{imagetooth} s.version = "2.0.1" s.date = Date.today.to_s s.summary = %q{This library allows to generate images of teeth for odontograms with tooth faces painted in a color (red, green, blue, white or black for example). This is very usefull for dental applications..} s.description =<= 2.13.1") s.files = Dir.glob("**/*").delete_if { |item| item.include?("~") } s.signing_key = '/home/gramos/src/ruby/ruby-sign/gem-private_key.pem' s.cert_chain = ['/home/gramos/src/ruby/ruby-sign/gem-public_cert.pem'] end imagetooth-2.0.1/Gemfile.lock0000644000175000017500000000050011611570453015434 0ustar gramosgramosGEM remote: http://rubygems.org/ specs: diff-lcs (1.1.2) rspec (2.6.0) rspec-core (~> 2.6.0) rspec-expectations (~> 2.6.0) rspec-mocks (~> 2.6.0) rspec-core (2.6.4) rspec-expectations (2.6.0) diff-lcs (~> 1.1.2) rspec-mocks (2.6.0) PLATFORMS ruby DEPENDENCIES rspec imagetooth-2.0.1/metadata.gz.sig0000644000175000017500000000040011611570453016114 0ustar gramosgramoszwc 5rogVBIJ`P.sR`ĸ~n)Q0lDTqt:˲PRxg"J@am݃ t?^[PI%gJLa`<qߜ w6d+:8 7I]:}^:3 Sztݰ,#:mst(`j؞1qMXvz;4D#p"-OEcOOq%v"$imagetooth-2.0.1/lib/0000755000175000017500000000000011611570453013765 5ustar gramosgramosimagetooth-2.0.1/lib/array_adds.rb0000644000175000017500000000037611611570453016431 0ustar gramosgramosclass Array def sequence(i = 0, *a) return [a] if i == size self[i].map {|x| sequence(i+1, *(a + [x])) }.inject([]) {|m, x| m + x} end def permut(n) arr = Array.new 1.upto(n){ arr.push(self) } arr.sequence end end imagetooth-2.0.1/lib/image_tooth.rb0000644000175000017500000001270411611570453016615 0ustar gramosgramos#!/usr/bin/ruby ########################################################################## # Copyright (C) 2007 Ramos, Gaston - ramos.gaston@gmail.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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. # ######################################################################### require 'RMagick' require 'array_adds' include Magick class ImageTooth attr_accessor :root_path @@colors = { :n => 'black', :w => 'white', :g => 'green', :r => 'red', :b => 'blue' } def initialize @root_path = './' @file_name_base = 'base_tooth.png' @extension = ".png" end def ImageTooth.colors=(hash_colors) @@colors = hash_colors end def ImageTooth.chars_colors @@colors.keys end # Generate the base tooth image, with all faces in white color. # This are store in root_path/base_path.png def graph_base file = @file_name_base background = Image.new(25, 35) gc = Draw.new gc.stroke('black') gc.fill('white') gc.rectangle(6, 6, 18, 28) gc.line(0, 0, 6, 6) gc.line(24, 0, 18, 6) gc.line(0, 35, 6, 28) gc.line(25, 35, 18, 28) gc.draw(background) background.border!(1, 1, 'black') background.write( "#{root_path}/#{file}" ) end # Paints the faces of the tooth image on hash colors based. # The tooth's filename represents the faces painted, # The filename's characters are: # * w - White # * g - Green # * b - Blue # * n - Black # * r - Red # * t - To extract # * x - Extracted # and are ordered, begining on the upper face of the # the tooth and moving clockwise ending on the center face. # Example: wrrgw.png def paint hash_faces, name_file # FIXME self.graph_base tooth = Magick::Image.read("#{@root_path}/#{@file_name_base}").first gc = Draw.new gc.fill(hash_faces[:top]) x = 1 y = 1 gc.polygon(x, y, x+7, y+5, x+18, y+5, x+23, y) gc.fill(hash_faces[:bottom]) x = 3 y = 35 gc.polygon(x, y, x+5, y-5, x+16, y-5, x+21, y) gc.fill(hash_faces[:center]) x = 8 y = 8 gc.rectangle(x, y, x+10, y+20) gc.fill(hash_faces[:right]) x = 20 y = 8 gc.polygon(x, y, x+5, y-6, x+5, y+25, x, y+20) gc.fill(hash_faces[:left]) x = 1 y = 35 gc.polygon(x, y, x+5, y-6, x+5, 7, 1, 2) gc.draw(tooth) tooth.write("#{self.root_path}/#{name_file}") File.delete("#{self.root_path}/#{@file_name_base}") end def paint_extract color, filename self.graph_base tooth = Magick::Image.read("#{@root_path}/#{@file_name_base}").first gc = Draw.new x = 4 y = 10 gc.stroke(color) gc.stroke_width(3) gc.line(x, y, x+19, y+15) gc.line(x + 18, y, x, y+16) gc.draw(tooth) tooth.write("#{self.root_path}/#{filename}#{@extension}") File.delete("#{self.root_path}/#{@file_name_base}") end # Generates a hash based on tooth's file name, where keys are the tooth's # faces and value is the colour to painted. def file_name2hash_faces file_name desc = file_name.split('.').first hash = Hash.new hash[:top] = @@colors[desc[0].chr.to_sym] hash[:right] = @@colors[desc[1].chr.to_sym] hash[:bottom] = @@colors[desc[2].chr.to_sym] hash[:left] = @@colors[desc[3].chr.to_sym] hash[:center] = @@colors[desc[4].chr.to_sym] hash end # Generates all tooth's images in a folder structure like this: # b/ w/ n/ r/ g/ # # * b/ - Blue (those wich it's top face is blue) # * w/ - White (those wich it's top face is white) # * n/ - Black (those wich it's top face is Black) # * g/ - Green (those wich it's top face is Green) # * t/ - To extrate (this will be extracted) # * x/ - Extracted (this was extracted) def gen_all root_path_aux = self.root_path self.permut.each{|i| self.root_path = "#{root_path_aux}/#{i[0].chr}" self.paint_img i } #Generate the 2 extractions marcs self.root_path = "#{root_path_aux}/t" self.paint2extract self.root_path = "#{root_path_aux}/x" self.paint_extracted self.root_path = root_path_aux end def method_missing(method_name, *args) case method_name.to_s when /paint_img/ case args[0] when /^ttttt/ self.paint2extract when /^xxxxx/ self.paint_extracted else self.paint(file_name2hash_faces(args[0]), args[0]) end when /paint2extract/ self.paint_extract 'blue', 'ttttt' when /paint_extracted/ self.paint_extract 'red', 'xxxxx' else super.method_missing end end # Generates all permutations tooth's filenames. def permut @@colors.keys.permut(5).collect{ |v| v.join('') + @extension} end def wrap_color char_color @@colors[char_color] end # Create all folders ones for each color and 2 more for extractions (x/ and t/) def create_folders #FIXME Dir.mkdir(@root_path) if not File.exist?(@root_path) ImageTooth.chars_colors.each { |f| Dir.mkdir("#{@root_path}/#{f}") if not File.exist?("#{@root_path}/#{f}") } Dir.mkdir("#{@root_path}/t") Dir.mkdir("#{@root_path}/x") end end imagetooth-2.0.1/lib/arg_parser.rb0000644000175000017500000000120211611570453016432 0ustar gramosgramosclass ArgParser def self.parse(args) options = OpenStruct.new opts = OptionParser.new do |opts| opts.on("-a", "--all", "Generate all teeth images's combinations.") do |all| options.all = all end opts.on("-i", "--image IMAGE", "Generate image tooth based on file name.") do |i| options.image = i end opts.on("-f", "--folder FOLDER", "Folder where images are saved. (** Required **)") do |f| options.folder = f end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end opts.parse!(args) options end end