Reversed the offsets

This commit is contained in:
Blake Thompson 2015-06-09 09:18:52 -05:00
parent 66efe02224
commit 75f7cb26bb
3 changed files with 18 additions and 17 deletions

View file

@ -238,8 +238,8 @@ private:
*/
static void displace(vertex2d & v, double dx, double dy, double a)
{
v.x += dx * std::cos(a) + dy * std::sin(a);
v.y += dx * std::sin(a) - dy * std::cos(a);
v.x += dx * std::cos(a) - dy * std::sin(a);
v.y += dx * std::sin(a) + dy * std::cos(a);
}
/**
@ -247,8 +247,8 @@ private:
*/
void displace(vertex2d & v, double a) const
{
v.x += offset_ * std::sin(a);
v.y -= offset_ * std::cos(a);
v.x -= offset_ * std::sin(a);
v.y += offset_ * std::cos(a);
}
/**
@ -256,8 +256,8 @@ private:
*/
void displace(vertex2d & v, vertex2d const& u, double a) const
{
v.x = u.x + offset_ * std::sin(a);
v.y = u.y - offset_ * std::cos(a);
v.x = u.x - offset_ * std::sin(a);
v.y = u.y + offset_ * std::cos(a);
v.cmd = u.cmd;
}
@ -266,8 +266,8 @@ private:
double sa = offset_ * std::sin(a);
double ca = offset_ * std::cos(a);
double h = std::tan(0.5 * (b - a));
v.x = v.x + sa + h * ca;
v.y = v.y - ca + h * sa;
v.x = v.x - sa - h * ca;
v.y = v.y + ca - h * sa;
}
status init_vertices()
@ -343,7 +343,7 @@ private:
double half_turns = half_turn_segments_ * std::fabs(joint_angle);
int bulge_steps = 0;
if (offset_ < 0.0)
if (offset_ > 0.0)
{
if (joint_angle > 0.0)
{
@ -444,7 +444,7 @@ private:
double half_turns = half_turn_segments_ * std::fabs(joint_angle);
int bulge_steps = 0;
if (offset_ < 0.0)
if (offset_ > 0.0)
{
if (joint_angle > 0.0)
{

View file

@ -209,7 +209,8 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
pixel_position align_offset = layout.alignment_offset();
pixel_position const& layout_displacement = layout.displacement();
double sign = (real_orientation == UPRIGHT_LEFT) ? -1 : 1;
double offset = layout_displacement.y + 0.5 * sign * layout.height();
//double offset = 0 - (layout_displacement.y + 0.5 * sign * layout.height());
double offset = layout_displacement.y - 0.5 * sign * layout.height();
double adjust_character_spacing = .0;
double layout_width = layout.width();
bool adjust = layout.horizontal_alignment() == H_ADJUST;
@ -228,7 +229,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
{
// Only subtract half the line height here and half at the end because text is automatically
// centered on the line
offset -= sign * line.height()/2;
offset += sign * line.height()/2;
vertex_cache & off_pp = pp.get_offseted(offset, sign * layout_width);
vertex_cache::scoped_state off_state(off_pp); // TODO: Remove this when a clean implementation in vertex_cache::get_offseted is done
double line_width = adjust ? (line.glyphs_width() + line.space_count() * adjust_character_spacing) : line.width();
@ -296,7 +297,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
glyphs->emplace_back(glyph, pos, rot);
}
// See comment above
offset -= sign * line.height()/2;
offset += sign * line.height()/2;
}
}

View file

@ -74,7 +74,7 @@ void test_simple_segment(double const &offset)
{
fake_path path = {0, 0, 1, 0}, off_path = {0, offset, 1, offset};
mapnik::offset_converter<fake_path> off_path_new(path);
off_path_new.set_offset(-offset);
off_path_new.set_offset(offset);
double x0, y0, x1, y1;
unsigned cmd0 = off_path_new.vertex(&x0, &y0);
@ -116,7 +116,7 @@ void test_straight_line(double const &offset) {
fake_path path = {0, 0, 1, 0, 9, 0, 10, 0},
off_path = {0, offset, 1, offset, 9, offset, 10, offset};
mapnik::offset_converter<fake_path> off_path_new(path);
off_path_new.set_offset(-offset);
off_path_new.set_offset(offset);
double x0, y0, x1, y1;
unsigned cmd0 = off_path_new.vertex(&x0, &y0);
@ -166,7 +166,7 @@ void test_offset_curve(double const &offset) {
fake_path path(pos), off_path(off_pos);
mapnik::offset_converter<fake_path> off_path_new(path);
off_path_new.set_offset(-offset);
off_path_new.set_offset(offset);
double x0, y0, x1, y1;
unsigned cmd0 = off_path_new.vertex(&x0, &y0);
@ -222,7 +222,7 @@ void test_s_shaped_curve(double const &offset) {
fake_path path(pos), off_path(off_pos);
mapnik::offset_converter<fake_path> off_path_new(path);
off_path_new.set_offset(-offset);
off_path_new.set_offset(offset);
double x0, y0, x1, y1;
unsigned cmd0 = off_path_new.vertex(&x0, &y0);