Commit 5d079e34 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

add Point struct

parent 2ab45d16
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ include_directories(${CAIRO_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${HARFBUZZ_IN
add_definitions(-DFNORDMETRIC_VERSION="unstable")

add_library(plotfxlib STATIC
    elements/gridlines.cc
    elements/plot.cc
    elements/plot_axis.cc
    elements/plot_lines.cc
+12 −17
Original line number Diff line number Diff line
@@ -102,16 +102,12 @@ void strokePath(

void strokeLine(
    Layer* layer,
    double x1,
    double y1,
    double x2,
    double y2,
    const Point& p1,
    const Point& p2,
    const StrokeStyle& style) {
  Path p;
  p.moveTo(x1, y1);
  p.lineTo(x2, y2);
  p.lineTo(x2, y2);
  p.lineTo(x2, y2);
  p.moveTo(p1.x, p1.y);
  p.lineTo(p2.x, p2.y);

  Rectangle clip(0, 0, layer->width, layer->height);
  strokePath(layer, clip, p, style);
@@ -119,17 +115,16 @@ void strokeLine(

void strokeRectangle(
    Layer* layer,
    double x,
    double y,
    double w,
    double h,
    const Point& origin,
    double width,
    double height,
    const StrokeStyle& style) {
  Path p;
  p.moveTo(x, y);
  p.lineTo(x + w, y);
  p.lineTo(x + w, y + h);
  p.lineTo(x, y + h);
  p.lineTo(x, y);
  p.moveTo(origin.x, origin.y);
  p.lineTo(origin.x + width, origin.y);
  p.lineTo(origin.x + width, origin.y + height);
  p.lineTo(origin.x, origin.y + height);
  p.lineTo(origin.x, origin.y);

  Rectangle clip(0, 0, layer->width, layer->height);
  strokePath(layer, clip, p, style);
+5 −8
Original line number Diff line number Diff line
@@ -100,18 +100,15 @@ void strokePath(

void strokeLine(
    Layer* layer,
    double x1,
    double y1,
    double x2,
    double y2,
    const Point& p1,
    const Point& p2,
    const StrokeStyle& style);

void strokeRectangle(
    Layer* layer,
    double x,
    double y,
    double w,
    double h,
    const Point& origin,
    double width,
    double height,
    const StrokeStyle& style);

} // namespace plotfx
+19 −0
Original line number Diff line number Diff line
@@ -33,6 +33,25 @@

namespace plotfx {

Point::Point() :
    x(0.0f),
    y(0.0f) {}

Point::Point(
    double _x,
    double _y) :
    x(_x),
    y(_y) {}

std::ostream& operator <<(std::ostream& os, const Point& p) {
  os << "Point(";
  os << p.x;
  os << ", ";
  os << p.y;
  os << ")";
  return os;
}

Rectangle::Rectangle() :
    x(0.0f),
    y(0.0f),
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,13 @@

namespace plotfx {

struct Point {
  Point();
  Point(double x, double y);
  double x;
  double y;
};

struct Rectangle {
  Rectangle();
  Rectangle(double x, double y, double w, double h);
@@ -43,6 +50,7 @@ struct Rectangle {
  double h;
};

std::ostream& operator <<(std::ostream& os, const Point& c);
std::ostream& operator <<(std::ostream& os, const Rectangle& c);

} // namespace plotfx
Loading