The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Point flags

These changes was commited to the Birdfont repository Sat, 22 Oct 2016 11:08:24 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 22 Oct 2016 11:08:24 +0000 (13:08 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 22 Oct 2016 11:08:24 +0000 (13:08 +0200)
commit 3607be16e7430d40192e8a4d28174f8eb35e9b2b
tree 6b108eca02efb05fbc83d696178ed6ead5ac51a9
parent a8da87a425411014c1d0beb632353ebad8ae4cd0
Point flags

libbirdfont/ColorPicker.vala
libsvgbird/Doubles.vala
libsvgbird/Gradient.vala
libsvgbird/PointValue.vala
libsvgbird/Points.vala
libsvgbird/SvgPath.vala
libsvgbird/point_value.h
resources/icons.bf
svgbirdpoint.vapi
--- a/libbirdfont/ColorPicker.vala +++ b/libbirdfont/ColorPicker.vala @@ -147,7 +147,7 @@ public Color get_fill_color () { return fill_color; } - + public override void draw_tool (Context cr, double px, double py) { draw_bars (cr, px, py); draw_dial (cr, px, py, 0, hue);
--- a/libsvgbird/Doubles.vala +++ b/libsvgbird/Doubles.vala @@ -53,7 +53,7 @@ data[index].value = p; } - public void set_type (int index, uchar t) { + public void set_type (int index, uint32 t) { if (unlikely (index < 0)) { warning ("index < 0"); return; @@ -72,7 +72,7 @@ data[index].value = p; } - public void insert_type (int index, uchar p) { + public void insert_type (int index, uint32 p) { insert_element (index); data[index].type = p; } @@ -137,7 +137,7 @@ capacity = new_capacity; } - public void add_type (uchar type) { + public void add_type (uint32 type) { if (size >= capacity) { increase_capacity (); } @@ -179,7 +179,7 @@ return data[index].value; } - public uchar get_point_type (int index) { + public uint32 get_point_type (int index) { if (unlikely (index < 0)) { warning ("index < 0"); return 0; @@ -191,6 +191,20 @@ } return data[index].type; + } + + public void set_point_type (int index, uint32 type) { + if (unlikely (index < 0)) { + warning ("index < 0"); + return; + } + + if (unlikely (index >= size)) { + warning ("index >= size"); + return; + } + + data[index].type = type; } public string get_string (int i) {
--- a/libsvgbird/Gradient.vala +++ b/libsvgbird/Gradient.vala @@ -29,6 +29,15 @@ public Gradient () { stops = new Gee.ArrayList<Stop> (); transforms = new SvgTransforms (); + } + + public Stop get_stop (int index) { + if (unlikely (index < 0 || index >= stops.size)) { + warning ("Stop index out of bounds"); + return new Stop (); + } + + return stops.get (index); } public void copy_stops (Gradient g) {
--- a/libsvgbird/PointValue.vala +++ b/libsvgbird/PointValue.vala @@ -14,10 +14,13 @@ namespace SvgBird { - public static const uchar POINT_NONE = 0; - public static const uchar POINT_ARC = 1; - public static const uchar POINT_CUBIC = 2; - public static const uchar POINT_LINE = 3; + public static const uint32 POINT_NONE = 0; + public static const uint32 POINT_ARC = 1; + public static const uint32 POINT_CUBIC = 1 << 1; + public static const uint32 POINT_LINE = 1 << 2; + public static const uint32 POINT_NEXT_LINE = 1 << 3; + public static const uint32 POINT_PREVIOUS_LINE = 1 << 4; + public static const uint32 POINT_TYPE = POINT_ARC | POINT_CUBIC | POINT_LINE; }
--- a/libsvgbird/Points.vala +++ b/libsvgbird/Points.vala @@ -28,7 +28,7 @@ } } - public void set_type (int index, uchar p) { + public void set_type (int index, uint32 p) { point_data.set_type (index, p); } @@ -36,7 +36,7 @@ point_data.set_double (index, p); } - public void insert_type (int index, uchar t) { + public void insert_type (int index, uint32 t) { point_data.insert_type (index, t); } @@ -48,7 +48,7 @@ point_data.add (p); } - public void add_type (uchar type) { + public void add_type (uint32 type) { point_data.add_type (type); } @@ -113,8 +113,12 @@ return point_data.get_double (index); } - public uchar get_point_type (int index) { + public uint32 get_point_type (int index) { return point_data.get_point_type (index); + } + + public void set_point_type (int index, uint32 type) { + point_data.set_point_type (index, type); } public void all (LineIterator iter) {
--- a/libsvgbird/SvgPath.vala +++ b/libsvgbird/SvgPath.vala @@ -94,7 +94,7 @@ return_if_fail (size % 8 == 0); return_if_fail (size >= 8); - switch (path.get_point_type (0)) { + switch (path.get_point_type (0) & POINT_TYPE) { case POINT_ARC: x = path.get_double (6); y = path.get_double (7); @@ -120,7 +120,7 @@ return_if_fail (size % 8 == 0); for (int i = 0; i < size; i += 8) { - switch (points[i].type) { + switch (points[i].type & POINT_TYPE) { case POINT_ARC: draw_arc (cr, points[i + 1].value, points[i + 2].value, points[i + 3].value, points[i + 4].value,
--- a/libsvgbird/point_value.h +++ b/libsvgbird/point_value.h @@ -19,9 +19,9 @@ typedef union { gdouble value; - guchar type; + guint32 type; } SvgBirdPointValue; #endif
--- a/resources/icons.bf +++ b/resources/icons.bf @@ -1647,6 +1647,16 @@ <path data="B -14.0000000000,24.0000000000 M -14.0000000000,18.0000000000 M -14.0000000000,18.0000000000 M -20.0000000000,18.0000000000 M -20.0000000000,24.0000000000 M -14.0000000000,24.0000000000" /> <path data="B -4.9487179487,42.0000000000 M -4.9487179487,18.0000000000 M -10.9487179487,18.0000000000 M -10.9487179487,42.0000000000 M -4.9487179487,42.0000000000" /> <path data="B 6.0000000000,42.0000000000 M 6.0000000000,50.0000000000 M 8.0000000000,50.0000000000 M 22.0000000000,30.0000000000 M 8.0000000000,10.0000000000 M 6.0000000000,10.0000000000 M 6.0000000000,18.0000000000 M -2.0000000000,18.0000000000 M -2.0000000000,42.0000000000 M 6.0000000000,42.0000000000" /> + </layer> + </glyph> + </collection> + + <collection name="translate"> + <selected id="0"/> + <glyph id="0" left="-28" right="28"> + <layer name= "Layer" visible="true"> + <path data="B -8.7490642589,49.3988532131 C -6.3869401212,50.3651767240 -4.3469238204,50.1504381663 -1.4479532876,48.9693760972 T C 1.2293855707,47.8786084141 3.0615564298,44.4598663798 -0.1595219398,43.9230199847 T C -3.3806003095,43.3861735897 -7.6753714690,47.6809447493 -8.7490642589,49.3988532131" /> + <path data="B -20.0228385528,33.5081999227 C -14.2248974874,34.8324210304 -6.1722015632,36.4071704554 -2.6290153565,37.4808632453 T C 0.9141708501,38.5545560352 8.3226511004,41.1314187310 9.6110824483,41.1314187310 T C 10.8995137961,41.1314187310 13.5837457707,41.7756344048 14.8721771186,40.3798337780 T C 16.1606084666,38.9840331512 17.3416705355,38.9840331511 8.7521282163,37.3734939663 T C 0.1625858972,35.7629547815 2.7394485929,36.0134830991 -0.2668912188,35.3334776655 M 2.3099714770,33.0787228069 C 1.5583865241,31.0387065061 0.1625858972,21.9123177920 -1.1258454507,18.1543930272 C 3.3120847475,15.2912122543 6.8194811945,11.2827591720 12.1879451440,9.5648507082 T C 17.7862147007,7.7734044500 21.5648621756,7.4890446477 26.2533206915,6.4511416175 C 22.4953959270,4.3037560377 23.7838272747,4.6258638747 13.2616379339,3.5521710848 T C 8.0179209976,3.0170979280 2.5247100350,11.4974977300 -2.8437539145,15.4701610526 C -3.7027081464,13.7522525888 -6.2541544206,11.0696298246 -10.4669727228,9.3501121502 T C -15.7280673932,7.2027265704 -22.0628548536,7.0953572913 -25.3913025023,7.6322036864 C -20.8102132654,9.1353735921 -15.2988717451,10.5981041010 -13.6880510924,11.6048670090 T C -10.2522341648,13.7522525888 -7.0311557951,16.2217460054 -5.5279858892,19.2280858171 M -12.6143583025,26.4218275094 M -15.8354366722,28.0323666944 C -15.7280673932,28.3186847717 -14.6543746033,29.3207980421 -13.0438354185,29.4281673211 T C -11.8850313613,29.5054209250 -11.3259269547,28.6765823683 -9.2859106539,26.5291967884 T C -8.2992874836,25.4906460827 -5.4206166103,22.9860105819 -4.5616623783,21.8049485130 C -3.7027081464,23.7375955348 -3.4879695884,24.8112883247 -2.9511231935,27.2807817413 T C -2.0107080383,31.6066914556 -2.4142767986,34.7966312706 -3.4879695884,35.1187391077 M -15.2985902773,32.4345071328 C -16.4080728268,32.3271378538 -18.4122993678,31.6829221800 -18.6270379259,32.1123992960 T C -18.8417764839,32.5418764118 -19.5575716772,33.0429330471 -20.0228385528,33.5081999227" /> </layer> </glyph> </collection> @@ -1883,6 +1893,7 @@ <ligature sequence="h e l p _ l i n e s" replacement="help_lines"/> <ligature sequence="l e f t _ a r r o w" replacement="left_arrow"/> <ligature sequence="c l o s e _ p a t h" replacement="close_path"/> + <ligature sequence="t r a n s l a t e" replacement="translate"/> <ligature sequence="t r a n s f o r m" replacement="transform"/> <ligature sequence="a d d _ l a y e r" replacement="add_layer"/> <ligature sequence="o p e n _ f o n t" replacement="open_font"/>
--- a/svgbirdpoint.vapi +++ b/svgbirdpoint.vapi @@ -2,9 +2,9 @@ [CCode (cheader_filename="point_value.h")] public extern struct PointValue { - uchar type; + uint32 type; double value; } }