OK In progress...

This commit is contained in:
Kolan Sh 2018-01-20 14:43:21 +03:00
parent 21c39c46a0
commit 6bbce0fd5e
3 changed files with 182 additions and 72 deletions

115
src/Area.vala Normal file
View File

@ -0,0 +1,115 @@
namespace CairoChart {
/**
* Area rectangle.
*/
[Compact]
public class Area {
/**
* Left bound.
*/
public double x0 = 0;
/**
* Top bound.
*/
public double y0 = 0;
/**
* Right bound.
*/
public double x1 = 1;
/**
* Bottom bound.
*/
public double y1 = 1;
/**
* ``Area`` width.
*/
public double width {
get {
return x1 - x0;
}
protected set {
x1 = x0 + value;
}
}
/**
* ``Area`` height.
*/
public double height {
get {
return y1 - y0;
}
protected set {
y1 = y0 + value;
}
}
/**
* Constructs a new ``Area``.
*/
Area () { }
/**
* Constructs a new ``Area`` with absolute coordinates.
* @param x0 left bound.
* @param y0 top bound.
* @param x1 right bound.
* @param y1 bottom bound.
*/
Area.with_abs (double x0, double y0, double x1, double y1) {
this.x0 = x0;
this.y0 = y0;
this.x1 = x1;
this.y1 = y1;
}
/**
* Constructs a new ``Area`` with relative coordinates.
* @param x0 left bound.
* @param y0 top bound.
* @param width ``Area`` width.
* @param height ``Area`` height.
*/
Area.with_rel (double x0, double y0, double width, double height) {
this.x0 = x0;
this.y0 = y0;
this.width = width;
this.height = height;
}
/**
* Constructs a new ``Area`` by other ``Area``.
* @param area ``Area`` instance.
*/
Area.with_area (Area area) {
this.x0 = area.x0;
this.y0 = area.y0;
this.x1 = area.x1;
this.y1 = area.y0;
}
/**
* Constructs a new ``Area`` by ``Cairo.Rectangle``.
* @param rectangle ``Cairo.Rectangle`` instance.
*/
Area.with_rectangle (Cairo.Rectangle rectangle) {
this.x0 = rectangle.x;
this.y0 = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
}
/**
* Gets a copy of the ``Chart``.
*/
public Area copy () {
return new Area.with_area(this);
}
}
}

67
src/Range.vala Normal file
View File

@ -0,0 +1,67 @@
namespace CairoChart {
/**
* Linear range.
*/
[Compact]
public class Range {
/**
* Low bound.
*/
public double low = 0;
/**
* High bound.
*/
public double high = 1;
/**
* ``Range`` value.
*/
public double range {
get {
return high - low;
}
protected set {
high = low + value;
}
}
/**
* Constructs a new ``Range``.
*/
Range () { }
/**
* Constructs a new ``Range`` with a ``Range`` instance.
*/
Range.with_range (Range range) {
this.low = range.low;
this.high = range.high;
}
/**
* Constructs a new ``Range`` with absolute coordinates.
*/
Range.with_abs (double low, double high) {
this.low = low;
this.high = high;
}
/**
* Constructs a new ``Range`` with relative coordinates.
*/
Range.with_rel (double low, double range) {
this.low = low;
this.high = low + range;
}
/**
* Gets a copy of the ``Range``.
*/
public Range copy () {
return new Range.with_range(this);
}
}
}

View File

@ -1,72 +0,0 @@
namespace CairoChart {
/**
*
*/
[Compact]
public class Rect {
/**
*
*/
public double x0 = 0;
/**
*
*/
public double x1 = 1;
/**
*
*/
public double y0 = 0;
/**
*
*/
public double y1 = 1;
/**
*
*/
public double width {
get {
return x1 - x0;
}
protected set {
width = value;
x1 = x0 + width;
}
}
/**
*
*/
public double height {
get {
return y1 - y0;
}
protected set {
width = value;
y1 = y0 + height;
}
}
/**
*
*/
Rect () { }
/**
*
*/
Rect.with_abs () {
}
/**
*
*/
Rect.with_rel () {
}
}
}