Blame c++/vector/context.cpp
|
|
2fb9fd |
|
|
|
2fb9fd |
|
|
|
2fb9fd |
#include <cmath></cmath>
|
|
|
2fb9fd |
|
|
|
2fb9fd |
#include "activepoint.h"
|
|
|
2fb9fd |
|
|
|
2fb9fd |
#include "context.h"
|
|
|
2fb9fd |
|
|
|
2fb9fd |
|
|
|
2fb9fd |
Real Context::pixelsize_sqr() const {
|
|
|
2fb9fd |
Cairo::Matrix m;
|
|
|
2fb9fd |
ctx()->get_matrix(m);
|
|
|
2fb9fd |
return 0.25*sqrt(m.xx*m.xx + m.xy*m.xy + m.yx*m.yx + m.yy*m.yy);
|
|
|
2fb9fd |
}
|
|
|
2fb9fd |
|
|
|
2fb9fd |
Real Context::pixelsize() const {
|
|
|
2fb9fd |
return sqrt(pixelsize_sqr());
|
|
|
2fb9fd |
}
|
|
|
2fb9fd |
|
|
|
2fb9fd |
void Context::point(const ActivePoint &point) const {
|
|
|
2fb9fd |
if (!point.visible) return;
|
|
|
2fb9fd |
|
|
|
2fb9fd |
Color color = point.color;
|
|
|
2fb9fd |
Color stroke_color = Color::black();
|
|
|
2fb9fd |
if (!point.enabled) {
|
|
|
2fb9fd |
color = color.mergecolor(Color::gray()).mulalpha();
|
|
|
2fb9fd |
stroke_color = stroke_color.mergecolor(Color::gray()).mulalpha();
|
|
|
2fb9fd |
}
|
|
|
2fb9fd |
|
|
|
2fb9fd |
ctx()->save();
|
|
|
2fb9fd |
ctx()->arc(point.position.x, point.position.y, point.radius, 0, 2*pi);
|
|
|
2fb9fd |
set_source_rgba(color);
|
|
|
2fb9fd |
ctx()->fill_preserve();
|
|
|
2fb9fd |
set_line_width_px(point.active ? 2 : 1);
|
|
|
2fb9fd |
set_source_rgba(stroke_color);
|
|
|
2fb9fd |
ctx()->stroke();
|
|
|
2fb9fd |
|
|
|
2fb9fd |
ctx()->restore();
|
|
|
2fb9fd |
}
|
|
|
2fb9fd |
|
|
|
145120 |
void Context::bezier(const Bezier &bezier, bool jump) const {
|
|
|
145120 |
if (jump) move_to(bezier.p0); else line_to(bezier.p0);
|
|
|
145120 |
ctx()->curve_to(bezier.pp0.x, bezier.pp0.y, bezier.pp1.x, bezier.pp1.y, bezier.p1.x, bezier.p1.y);
|
|
|
2fb9fd |
}
|