Blame c++/vector/context.h

2fb9fd
#ifndef CONTEXT_H
2fb9fd
#define CONTEXT_H
2fb9fd
2fb9fd
2fb9fd
#include <cassert></cassert>
2fb9fd
2fb9fd
#include <cairomm cairomm.h=""></cairomm>
2fb9fd
2fb9fd
#include "color.h"
145120
#include "vector.h"
145120
#include "curve.h"
2fb9fd
2fb9fd
class ActivePoint;
2fb9fd
2fb9fd
2fb9fd
class Context {
2fb9fd
public:
2fb9fd
	Cairo::RefPtr<cairo::context> context;</cairo::context>
2fb9fd
	
2fb9fd
	explicit Context(
2fb9fd
		const Cairo::RefPtr<cairo::context> &context = Cairo::RefPtr<cairo::context>()</cairo::context></cairo::context>
2fb9fd
	): context(context) { }
2fb9fd
2fb9fd
	Cairo::RefPtr<cairo::context> ctx() const { assert(context); return context; }</cairo::context>
2fb9fd
	Cairo::Context* operator->() const { return context.operator->(); }
2fb9fd
	
2fb9fd
	Real pixelsize_sqr() const;
2fb9fd
	Real pixelsize() const;
2fb9fd
2fb9fd
	void set_source_rgb(const Color &c) const
2fb9fd
		{ ctx()->set_source_rgb(c.r, c.g, c.b); }
2fb9fd
	void set_source_rgba(const Color &c) const
2fb9fd
		{ ctx()->set_source_rgba(c.r, c.g, c.b, c.a); }
2fb9fd
	void set_line_width_px(const Real &pixels) const
2fb9fd
		{ ctx()->set_line_width( pixels*pixelsize() ); }
2fb9fd
	
2fb9fd
	void move_to(const Vector &p) const
2fb9fd
		{ ctx()->move_to(p.x, p.y); }
2fb9fd
	void line_to(const Vector &p) const
2fb9fd
		{ ctx()->line_to(p.x, p.y); }
2fb9fd
	
2fb9fd
	void point(const ActivePoint &point) const;
145120
	void bezier(const Bezier &bezier, bool jump = false) const;
145120
	void hermite(const Hermite &hermite, bool jump = false) const
145120
		{ bezier(hermite.get_bezier(), jump); }
2fb9fd
};
2fb9fd
2fb9fd
2fb9fd
#endif