如何将我自己的图标添加到Raphael的免费图标库存中?

时间:2015-06-02 08:47:34

标签: icons raphael

我使用wheelnav.js创建了我的轮子,它使用了raphael.js的集成free icon stock。 我的目标是整合我自己的图标。我做了什么:

  1. 以svg格式创建我的图标
  2. 使用this tool收到的基于raphael的我的图标代码
  3. 尝试将此代码添加到股票图标列表的末尾
  4. 问题是我收到了这种格式的代码:

    var rsr = Raphael('rsr', '50', '51'); 
    var path_a = rsr.path("
    M 0.00 0.00 L 27.39 0.00 C 27.82 0.61 28.68 1.82 29.11 2.42 C 32.78 4.14 33.05 8.47 33.97 11.91 C 35.39 9.61 36.73 7.26 38.06 4.91 C 37.99 7.33 37.89 9.75 37.85 12.18 C 38.54 8.95 38.63 5.61 37.92 2.37 C 36.80 4.54 35.77 6.75 34.76 8.96 C 33.95 5.24 31.80 1.99 28.54 0.00 L 50.00 0.00 L 50.00 29.99 C 48.25 27.65 45.99 25.77 43.58 24.16 C 45.00 26.32 46.59 28.35 48.14 30.40 C 47.53 30.47 46.30 30.59 45.68 30.65 C 46.80 31.84 47.91 33.03 49.01 34.23 C 49.26 33.74 49.75 32.74 50.00 32.25 L 50.00 51.00 L 0.00 51.00 L 0.00 0.00 Z");
    path_a.attr({fill: '#ffffff','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_a'); var path_b = rsr.path(" M 27.39 0.00 L 28.54 0.00 C 31.80 1.99 33.95 5.24 34.76 8.96 C 35.77 6.75 36.80 4.54 37.92 2.37 C 38.63 5.61 38.54 8.95 37.85 12.18 C 37.89 9.75 37.99 7.33 38.06 4.91 C 36.73 7.26 35.39 9.61 33.97 11.91 C 33.05 8.47 32.78 4.14 29.11 2.42 C 28.68 1.82 27.82 0.61 27.39 0.00 Z"); path_b.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_b'); var path_c = rsr.path(" M 2.78 11.05 C 7.94 6.81 14.16 3.46 20.93 3.05 C 24.09 2.93 27.13 4.17 29.54 6.15 C 30.08 5.47 30.62 4.79 31.18 4.13 C 31.36 6.70 31.48 9.27 31.48 11.84 C 30.11 9.02 28.34 5.89 25.01 5.16 C 17.04 2.97 9.58 7.53 2.78 11.05 Z"); path_c.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_c'); var path_d = rsr.path(" M 8.70 9.84 C 13.03 7.40 17.89 5.04 23.02 5.97 C 25.35 6.22 26.89 8.16 28.47 9.66 C 26.12 8.49 23.85 6.67 21.07 6.82 C 16.76 6.89 12.83 8.88 8.70 9.84 Z"); path_d.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_d'); var path_e = rsr.path(" M 18.74 14.77 C 20.40 13.59 22.34 12.62 24.31 13.85 C 24.31 14.53 24.28 15.20 24.23 15.87 C 22.64 17.29 23.60 19.33 23.76 21.11 C 22.28 19.38 21.62 17.37 22.73 15.22 C 22.06 15.16 20.72 15.04 20.05 14.98 C 20.26 17.31 20.50 19.63 20.67 21.96 C 19.12 19.86 18.76 17.32 18.74 14.77 Z"); path_e.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_e'); var path_f = rsr.path(" M 37.99 14.79 C 40.72 17.00 42.73 19.91 43.97 23.19 C 42.83 22.87 40.57 22.23 39.43 21.92 C 39.83 22.63 40.62 24.06 41.01 24.77 C 39.25 23.27 37.25 22.09 35.24 20.96 C 37.44 20.90 39.64 20.88 41.84 20.88 C 40.55 18.86 39.23 16.85 37.99 14.79 Z"); path_f.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_f'); var path_g = rsr.path(" M 31.10 32.89 C 29.68 29.70 29.08 26.25 29.21 22.76 C 29.88 25.69 30.50 28.66 31.82 31.37 C 34.29 36.36 33.25 42.09 32.83 47.40 C 32.06 47.31 31.30 47.22 30.53 47.13 C 30.12 47.68 29.29 48.76 28.88 49.30 C 31.08 44.21 33.35 38.37 31.10 32.89 Z"); path_g.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_g'); var path_h = rsr.path(" M 43.58 24.16 C 45.99 25.77 48.25 27.65 50.00 29.99 L 50.00 32.25 C 49.75 32.74 49.26 33.74 49.01 34.23 C 47.91 33.03 46.80 31.84 45.68 30.65 C 46.30 30.59 47.53 30.47 48.14 30.40 C 46.59 28.35 45.00 26.32 43.58 24.16 Z"); path_h.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_h'); var path_i = rsr.path(" M 31.77 26.72 C 35.70 27.90 37.71 31.56 37.81 35.49 C 38.68 36.54 39.53 37.60 40.37 38.67 C 38.98 37.92 37.58 37.19 36.15 36.50 C 36.78 32.52 34.79 29.12 31.77 26.72 Z"); path_i.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_i'); var path_j = rsr.path(" M 23.70 43.41 C 25.25 39.00 24.60 34.17 26.30 29.80 C 25.95 32.89 25.91 35.99 25.89 39.09 C 25.75 42.55 23.87 45.58 22.04 48.40 C 21.22 48.49 19.58 48.69 18.76 48.78 C 20.48 47.06 22.01 45.16 23.70 43.41 Z"); path_j.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_j'); var path_k = rsr.path(" M 42.80 41.08 C 44.86 39.40 46.70 37.47 48.33 35.36 C 47.90 36.92 47.41 38.46 46.90 39.98 C 45.53 40.36 44.17 40.73 42.80 41.08 Z"); path_k.attr({fill: '#727272','stroke-width': '0','stroke-opacity': '1'}).data('id', 'path_k'); var rsrGroups = [];

    但是在股票列表中,图标只有一个路径,就像这样

    opensource:"M15.5,1.125c-8.222,0-14.911,6.689-14.911,14.911c0,6.262,3.88,11.634,9.362,13.839l3.639-9.076c-1.888-0.758-3.222-2.604-3.222-4.763c0-2.834,2.297-5.132,5.131-5.132s5.131,2.298,5.131,5.132c0,2.157-1.334,4.005-3.222,4.763l3.64,9.076c5.479-2.206,9.361-7.578,9.361-13.839C30.41,7.814,23.721,1.125,15.5,1.125z"

    那么如何才能获得我真正需要的代码?

2 个答案:

答案 0 :(得分:1)

如果连接单个路径,则可以创建必要的路径。



var path_a = "M 0.00 0.00 L 27.39 0.00 C 27.82 0.61 28.68 1.82 29.11 2.42 C 32.78 4.14 33.05 8.47 33.97 11.91 C 35.39 9.61 36.73 7.26 38.06 4.91 C 37.99 7.33 37.89 9.75 37.85 12.18 C 38.54 8.95 38.63 5.61 37.92 2.37 C 36.80 4.54 35.77 6.75 34.76 8.96 C 33.95 5.24 31.80 1.99 28.54 0.00 L 50.00 0.00 L 50.00 29.99 C 48.25 27.65 45.99 25.77 43.58 24.16 C 45.00 26.32 46.59 28.35 48.14 30.40 C 47.53 30.47 46.30 30.59 45.68 30.65 C 46.80 31.84 47.91 33.03 49.01 34.23 C 49.26 33.74 49.75 32.74 50.00 32.25 L 50.00 51.00 L 0.00 51.00 L 0.00 0.00 Z";
var path_b = " M 27.39 0.00 L 28.54 0.00 C 31.80 1.99 33.95 5.24 34.76 8.96 C 35.77 6.75 36.80 4.54 37.92 2.37 C 38.63 5.61 38.54 8.95 37.85 12.18 C 37.89 9.75 37.99 7.33 38.06 4.91 C 36.73 7.26 35.39 9.61 33.97 11.91 C 33.05 8.47 32.78 4.14 29.11 2.42 C 28.68 1.82 27.82 0.61 27.39 0.00 Z";
var path_c = " M 2.78 11.05 C 7.94 6.81 14.16 3.46 20.93 3.05 C 24.09 2.93 27.13 4.17 29.54 6.15 C 30.08 5.47 30.62 4.79 31.18 4.13 C 31.36 6.70 31.48 9.27 31.48 11.84 C 30.11 9.02 28.34 5.89 25.01 5.16 C 17.04 2.97 9.58 7.53 2.78 11.05 Z";
var path_d = " M 8.70 9.84 C 13.03 7.40 17.89 5.04 23.02 5.97 C 25.35 6.22 26.89 8.16 28.47 9.66 C 26.12 8.49 23.85 6.67 21.07 6.82 C 16.76 6.89 12.83 8.88 8.70 9.84 Z";
var path_e = " M 18.74 14.77 C 20.40 13.59 22.34 12.62 24.31 13.85 C 24.31 14.53 24.28 15.20 24.23 15.87 C 22.64 17.29 23.60 19.33 23.76 21.11 C 22.28 19.38 21.62 17.37 22.73 15.22 C 22.06 15.16 20.72 15.04 20.05 14.98 C 20.26 17.31 20.50 19.63 20.67 21.96 C 19.12 19.86 18.76 17.32 18.74 14.77 Z";
var path_f = " M 37.99 14.79 C 40.72 17.00 42.73 19.91 43.97 23.19 C 42.83 22.87 40.57 22.23 39.43 21.92 C 39.83 22.63 40.62 24.06 41.01 24.77 C 39.25 23.27 37.25 22.09 35.24 20.96 C 37.44 20.90 39.64 20.88 41.84 20.88 C 40.55 18.86 39.23 16.85 37.99 14.79 Z";
var path_g = " M 31.10 32.89 C 29.68 29.70 29.08 26.25 29.21 22.76 C 29.88 25.69 30.50 28.66 31.82 31.37 C 34.29 36.36 33.25 42.09 32.83 47.40 C 32.06 47.31 31.30 47.22 30.53 47.13 C 30.12 47.68 29.29 48.76 28.88 49.30 C 31.08 44.21 33.35 38.37 31.10 32.89 Z";
var path_h = " M 43.58 24.16 C 45.99 25.77 48.25 27.65 50.00 29.99 L 50.00 32.25 C 49.75 32.74 49.26 33.74 49.01 34.23 C 47.91 33.03 46.80 31.84 45.68 30.65 C 46.30 30.59 47.53 30.47 48.14 30.40 C 46.59 28.35 45.00 26.32 43.58 24.16 Z";
var path_i = " M 31.77 26.72 C 35.70 27.90 37.71 31.56 37.81 35.49 C 38.68 36.54 39.53 37.60 40.37 38.67 C 38.98 37.92 37.58 37.19 36.15 36.50 C 36.78 32.52 34.79 29.12 31.77 26.72 Z";
var path_j = " M 23.70 43.41 C 25.25 39.00 24.60 34.17 26.30 29.80 C 25.95 32.89 25.91 35.99 25.89 39.09 C 25.75 42.55 23.87 45.58 22.04 48.40 C 21.22 48.49 19.58 48.69 18.76 48.78 C 20.48 47.06 22.01 45.16 23.70 43.41 Z";
var path_k = " M 42.80 41.08 C 44.86 39.40 46.70 37.47 48.33 35.36 C 47.90 36.92 47.41 38.46 46.90 39.98 C 45.53 40.36 44.17 40.73 42.80 41.08 z"; // The last 'z' must be lowercase!

lion = path_a + path_b + path_c + path_d + path_e + path_f + path_g + path_h + path_i + path_j + path_k;




注意:为了正确使用wheelnav.js,最后一个''必须是小写的。

我测试了它,这是示例页面:http://wheelnavjs.softwaretailoring.net/inspirations/stackoverflow30591371.html

答案 1 :(得分:1)

已经找到了让这段代码更短的方法以及如何使用softwaretailoring.net's回答将其包含到库存中。 Raphael的图标库存使用逗号而不是空格,所以如果我需要直接添加图标到库存 - 它很简单 - 在一行中写入所有路径,它们之间没有空格(您可以使用逗号或不用逗号替换空格在路径内),最后的Z当然必须是小写的,所以我的代码是:



lion:"M0.00,0.00,L27.39,0.00 C 27.82 0.61 28.68 1.82 29.11 2.42 C 32.78 4.14 33.05 8.47 33.97 11.91 C 35.39 9.61 36.73 7.26 38.06 4.91 C 37.99 7.33 37.89 9.75 37.85 12.18 C 38.54 8.95 38.63 5.61 37.92 2.37 C 36.80 4.54 35.77 6.75 34.76 8.96 C 33.95 5.24 31.80 1.99 28.54 0.00 L 50.00 0.00 L 50.00 29.99 C 48.25 27.65 45.99 25.77 43.58 24.16 C 45.00 26.32 46.59 28.35 48.14 30.40 C 47.53 30.47 46.30 30.59 45.68 30.65 C 46.80 31.84 47.91 33.03 49.01 34.23 C 49.26 33.74 49.75 32.74 50.00 32.25 L 50.00 51.00 L 0.00 51.00 L 0.00 0.00zM27.39,0.00 L 28.54 0.00 C 31.80 1.99 33.95 5.24 34.76 8.96 C 35.77 6.75 36.80 4.54 37.92 2.37 C 38.63 5.61 38.54 8.95 37.85 12.18 C 37.89 9.75 37.99 7.33 38.06 4.91 C 36.73 7.26 35.39 9.61 33.97 11.91 C 33.05 8.47 32.78 4.14 29.11 2.42 C 28.68 1.82 27.82 0.61 27.39 0.00zM2.78 11.05 C 7.94 6.81 14.16 3.46 20.93 3.05 C 24.09 2.93 27.13 4.17 29.54 6.15 C 30.08 5.47 30.62 4.79 31.18 4.13 C 31.36 6.70 31.48 9.27 31.48 11.84 C 30.11 9.02 28.34 5.89 25.01 5.16 C 17.04 2.97 9.58 7.53 2.78 11.05 zM 8.70 9.84 C 13.03 7.40 17.89 5.04 23.02 5.97 C 25.35 6.22 26.89 8.16 28.47 9.66 C 26.12 8.49 23.85 6.67 21.07 6.82 C 16.76 6.89 12.83 8.88 8.70 9.84 zM 18.74 14.77 C 20.40 13.59 22.34 12.62 24.31 13.85 C 24.31 14.53 24.28 15.20 24.23 15.87 C 22.64 17.29 23.60 19.33 23.76 21.11 C 22.28 19.38 21.62 17.37 22.73 15.22 C 22.06 15.16 20.72 15.04 20.05 14.98 C 20.26 17.31 20.50 19.63 20.67 21.96 C 19.12 19.86 18.76 17.32 18.74 14.77 zM 37.99 14.79 C 40.72 17.00 42.73 19.91 43.97 23.19 C 42.83 22.87 40.57 22.23 39.43 21.92 C 39.83 22.63 40.62 24.06 41.01 24.77 C 39.25 23.27 37.25 22.09 35.24 20.96 C 37.44 20.90 39.64 20.88 41.84 20.88 C 40.55 18.86 39.23 16.85 37.99 14.79 zM 31.10 32.89 C 29.68 29.70 29.08 26.25 29.21 22.76 C 29.88 25.69 30.50 28.66 31.82 31.37 C 34.29 36.36 33.25 42.09 32.83 47.40 C 32.06 47.31 31.30 47.22 30.53 47.13 C 30.12 47.68 29.29 48.76 28.88 49.30 C 31.08 44.21 33.35 38.37 31.10 32.89 zM 43.58 24.16 C 45.99 25.77 48.25 27.65 50.00 29.99 L 50.00 32.25 C 49.75 32.74 49.26 33.74 49.01 34.23 C 47.91 33.03 46.80 31.84 45.68 30.65 C 46.30 30.59 47.53 30.47 48.14 30.40 C 46.59 28.35 45.00 26.32 43.58 24.16 zM 31.77 26.72 C 35.70 27.90 37.71 31.56 37.81 35.49 C 38.68 36.54 39.53 37.60 40.37 38.67 C 38.98 37.92 37.58 37.19 36.15 36.50 C 36.78 32.52 34.79 29.12 31.77 26.72 zM 23.70 43.41 C 25.25 39.00 24.60 34.17 26.30 29.80 C 25.95 32.89 25.91 35.99 25.89 39.09 C 25.75 42.55 23.87 45.58 22.04 48.40 C 21.22 48.49 19.58 48.69 18.76 48.78 C 20.48 47.06 22.01 45.16 23.70 43.41 zM 42.80 41.08 C 44.86 39.40 46.70 37.47 48.33 35.36 C 47.90 36.92 47.41 38.46 46.90 39.98 C 45.53 40.36 44.17 40.73 42.80 41.08z"