Blame c++/perspective/src/perspective.h
|
|
4dc49c |
#ifndef PERSPECTIVE_H
|
|
|
4dc49c |
#define PERSPECTIVE_H
|
|
|
4dc49c |
|
|
|
4dc49c |
#include <vector></vector>
|
|
|
3a6f9b |
#include <string></string>
|
|
|
4dc49c |
|
|
|
4dc49c |
#include "vector.h"
|
|
|
4dc49c |
#include "matrix.h"
|
|
|
4dc49c |
#include "surface.h"
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
class Perspective {
|
|
|
4dc49c |
public:
|
|
|
4dc49c |
class Layer {
|
|
|
4dc49c |
public:
|
|
|
4dc49c |
IntPair2 dst_bounds;
|
|
|
4dc49c |
Pair2 src_bounds;
|
|
|
4dc49c |
IntVector2 src_size;
|
|
|
4dc49c |
Matrix3 back_matrix;
|
|
|
4dc49c |
Matrix3 back_alpha_matrix;
|
|
|
4dc49c |
};
|
|
|
4dc49c |
|
|
|
4dc49c |
typedef std::vector<layer> LayerList;</layer>
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
3a6f9b |
static Matrix3 make_matrix(
|
|
|
3a6f9b |
const Vector2 &p0,
|
|
|
3a6f9b |
const Vector2 &px,
|
|
|
3a6f9b |
const Vector2 &py,
|
|
|
3a6f9b |
const Vector2 &p1 );
|
|
|
3a6f9b |
|
|
|
4dc49c |
static int truncate_line(
|
|
|
4dc49c |
Vector2 *out_points,
|
|
|
4dc49c |
const Pair2 &bounds,
|
|
|
4dc49c |
Real a,
|
|
|
4dc49c |
Real b,
|
|
|
4dc49c |
Real c );
|
|
|
4dc49c |
|
|
|
4dc49c |
static Vector2 calc_optimal_resolution(
|
|
|
4dc49c |
const Vector2 &ox,
|
|
|
4dc49c |
const Vector2 &oy );
|
|
|
4dc49c |
|
|
|
4dc49c |
static Vector3 make_alpha_matrix_col(
|
|
|
4dc49c |
Real w0,
|
|
|
4dc49c |
Real w1,
|
|
|
4dc49c |
const Vector3 &w_col );
|
|
|
4dc49c |
|
|
|
4dc49c |
static Matrix3 make_alpha_matrix(
|
|
|
4dc49c |
Real aw0, Real aw1,
|
|
|
4dc49c |
Real bw0, Real bw1,
|
|
|
4dc49c |
const Vector3 &w_col );
|
|
|
4dc49c |
|
|
|
4dc49c |
static void calc_raster_size(
|
|
|
4dc49c |
Pair2 &out_bounds,
|
|
|
4dc49c |
IntVector2 &out_raster_size,
|
|
|
4dc49c |
Matrix3 &out_raster_matrix,
|
|
|
4dc49c |
const Vector2 &resolution,
|
|
|
4dc49c |
const Pair2 &bounds );
|
|
|
4dc49c |
|
|
|
4dc49c |
static void create_layers(
|
|
|
4dc49c |
LayerList &out_layers,
|
|
|
4dc49c |
const Matrix3 &matrix,
|
|
|
4dc49c |
const IntPair2 &dst_bounds,
|
|
|
4dc49c |
const Real step = 4.0 );
|
|
|
4dc49c |
|
|
|
4dc49c |
static void add_premulted(
|
|
|
4dc49c |
const Layer &layer,
|
|
|
3a6f9b |
Surface &src_surface,
|
|
|
3a6f9b |
Surface &dst_surface );
|
|
|
3a6f9b |
|
|
|
3a6f9b |
|
|
|
3a6f9b |
static void print_layer(const Layer &layer, const std::string &prefix = std::string());
|
|
|
3a6f9b |
static void print_layers(const LayerList &layers, const std::string &prefix = std::string());
|
|
|
4dc49c |
};
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
|
|
|
4dc49c |
#endif
|