added three more Transformer implementations:
* AffineTransformer - affine matrix transformation * PerspectiveTransformer - perspective transformation * ContourTransformer - extending the underlying VertexSource by a certain width (like "false bold" in text rendering) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17898 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -75,7 +75,10 @@ Application Icon-O-Matic :
|
||||
Style.cpp
|
||||
StyleManager.cpp
|
||||
# transformer
|
||||
AffineTransformer.cpp
|
||||
ContourTransformer.cpp
|
||||
PathSource.cpp
|
||||
PerspectiveTransformer.cpp
|
||||
StrokeTransformer.cpp
|
||||
Transformer.cpp
|
||||
#
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "IconEditorApp.h"
|
||||
|
||||
// TODO: just for testing
|
||||
#include "AffineTransformer.h"
|
||||
#include "Gradient.h"
|
||||
#include "Icon.h"
|
||||
#include "MultipleManipulatorState.h"
|
||||
@@ -120,6 +121,22 @@ MainWindow::_Init()
|
||||
|
||||
fDocument->Icon()->Shapes()->AddShape(shape);
|
||||
|
||||
Style* style3 = new Style();
|
||||
style3->SetColor((rgb_color){ 255, 0, 169,200 });
|
||||
|
||||
StyleManager::Default()->AddStyle(style3);
|
||||
|
||||
shape = new Shape(style3);
|
||||
shape->Paths()->AddPath(path);
|
||||
AffineTransformer* transformer2
|
||||
= new AffineTransformer(shape->VertexSource());
|
||||
*transformer2 *= agg::trans_affine_translation(10.0, 6.0);
|
||||
*transformer2 *= agg::trans_affine_rotation(0.2);
|
||||
*transformer2 *= agg::trans_affine_scaling(0.8, 0.6);
|
||||
shape->AppendTransformer(transformer2);
|
||||
|
||||
fDocument->Icon()->Shapes()->AddShape(shape);
|
||||
|
||||
PathManipulator* pathManipulator = new PathManipulator(path);
|
||||
state->AddManipulator(pathManipulator);
|
||||
// ----
|
||||
|
||||
@@ -85,6 +85,7 @@ Shape::SetStyle(::Style* style)
|
||||
BRect
|
||||
Shape::Bounds() const
|
||||
{
|
||||
// TODO: incorrect - use VertexSource instead!!
|
||||
BRect bounds(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN);
|
||||
|
||||
int32 count = fPaths->CountPaths();
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "AffineTransformer.h"
|
||||
|
||||
// constructor
|
||||
AffineTransformer::AffineTransformer(VertexSource& source)
|
||||
: Transformer(source),
|
||||
Affine(source, *this)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
AffineTransformer::~AffineTransformer()
|
||||
{
|
||||
}
|
||||
|
||||
// rewind
|
||||
void
|
||||
AffineTransformer::rewind(unsigned path_id)
|
||||
{
|
||||
Affine::rewind(path_id);
|
||||
}
|
||||
|
||||
// vertex
|
||||
unsigned
|
||||
AffineTransformer::vertex(double* x, double* y)
|
||||
{
|
||||
return Affine::vertex(x, y);
|
||||
}
|
||||
|
||||
// SetSource
|
||||
void
|
||||
AffineTransformer::SetSource(VertexSource& source)
|
||||
{
|
||||
Transformer::SetSource(source);
|
||||
Affine::attach(source);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef AFFINE_TRANSFORMER_H
|
||||
#define AFFINE_TRANSFORMER_H
|
||||
|
||||
#include "agg_conv_transform.h"
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
#include "Transformer.h"
|
||||
|
||||
typedef agg::conv_transform<VertexSource,
|
||||
agg::trans_affine> Affine;
|
||||
|
||||
class AffineTransformer : public Transformer,
|
||||
public Affine,
|
||||
public agg::trans_affine {
|
||||
public:
|
||||
AffineTransformer(
|
||||
VertexSource& source);
|
||||
virtual ~AffineTransformer();
|
||||
|
||||
virtual void rewind(unsigned path_id);
|
||||
virtual unsigned vertex(double* x, double* y);
|
||||
|
||||
virtual void SetSource(VertexSource& source);
|
||||
};
|
||||
|
||||
#endif // AFFINE_TRANSFORMER_H
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "ContourTransformer.h"
|
||||
|
||||
// constructor
|
||||
ContourTransformer::ContourTransformer(VertexSource& source)
|
||||
: Transformer(source),
|
||||
Contour(source)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
ContourTransformer::~ContourTransformer()
|
||||
{
|
||||
}
|
||||
|
||||
// rewind
|
||||
void
|
||||
ContourTransformer::rewind(unsigned path_id)
|
||||
{
|
||||
Contour::rewind(path_id);
|
||||
}
|
||||
|
||||
// vertex
|
||||
unsigned
|
||||
ContourTransformer::vertex(double* x, double* y)
|
||||
{
|
||||
return Contour::vertex(x, y);
|
||||
}
|
||||
|
||||
// SetSource
|
||||
void
|
||||
ContourTransformer::SetSource(VertexSource& source)
|
||||
{
|
||||
Transformer::SetSource(source);
|
||||
Contour::attach(source);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef CONTOUR_TRANSFORMER_H
|
||||
#define CONTOUR_TRANSFORMER_H
|
||||
|
||||
#include "agg_conv_contour.h"
|
||||
|
||||
#include "Transformer.h"
|
||||
|
||||
typedef agg::conv_contour<VertexSource> Contour;
|
||||
|
||||
class ContourTransformer : public Transformer,
|
||||
public Contour {
|
||||
public:
|
||||
ContourTransformer(
|
||||
VertexSource& source);
|
||||
virtual ~ContourTransformer();
|
||||
|
||||
virtual void rewind(unsigned path_id);
|
||||
virtual unsigned vertex(double* x, double* y);
|
||||
|
||||
virtual void SetSource(VertexSource& source);
|
||||
};
|
||||
|
||||
#endif // CONTOUR_TRANSFORMER_H
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "PerspectiveTransformer.h"
|
||||
|
||||
// constructor
|
||||
PerspectiveTransformer::PerspectiveTransformer(VertexSource& source)
|
||||
: Transformer(source),
|
||||
Perspective(source, *this)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
PerspectiveTransformer::~PerspectiveTransformer()
|
||||
{
|
||||
}
|
||||
|
||||
// rewind
|
||||
void
|
||||
PerspectiveTransformer::rewind(unsigned path_id)
|
||||
{
|
||||
Perspective::rewind(path_id);
|
||||
}
|
||||
|
||||
// vertex
|
||||
unsigned
|
||||
PerspectiveTransformer::vertex(double* x, double* y)
|
||||
{
|
||||
return Perspective::vertex(x, y);
|
||||
}
|
||||
|
||||
// SetSource
|
||||
void
|
||||
PerspectiveTransformer::SetSource(VertexSource& source)
|
||||
{
|
||||
Transformer::SetSource(source);
|
||||
Perspective::attach(source);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef PERSPECTIVE_TRANSFORMER_H
|
||||
#define PERSPECTIVE_TRANSFORMER_H
|
||||
|
||||
#include "agg_conv_transform.h"
|
||||
#include "agg_trans_perspective.h"
|
||||
|
||||
#include "Transformer.h"
|
||||
|
||||
typedef agg::conv_transform<VertexSource,
|
||||
agg::trans_perspective> Perspective;
|
||||
|
||||
class PerspectiveTransformer : public Transformer,
|
||||
public Perspective,
|
||||
public agg::trans_perspective {
|
||||
public:
|
||||
PerspectiveTransformer(
|
||||
VertexSource& source);
|
||||
virtual ~PerspectiveTransformer();
|
||||
|
||||
virtual void rewind(unsigned path_id);
|
||||
virtual unsigned vertex(double* x, double* y);
|
||||
|
||||
virtual void SetSource(VertexSource& source);
|
||||
};
|
||||
|
||||
#endif // PERSPECTIVE_TRANSFORMER_H
|
||||
Reference in New Issue
Block a user