mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Added functions for blurring and scaling images and changing the alpha value
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@494 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -86,6 +86,12 @@ AColor SolidFillSymbolFilter::color(double x, double y, SymbolSet point) const {
|
||||
else return AColor(0,0,0,0);
|
||||
}
|
||||
|
||||
bool SolidFillSymbolFilter::operator == (const SymbolFilter& that) const {
|
||||
const SolidFillSymbolFilter* that2 = dynamic_cast<const SolidFillSymbolFilter*>(&that);
|
||||
return that2 && fill_color == that2->fill_color
|
||||
&& border_color == that2->border_color;
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(SolidFillSymbolFilter) {
|
||||
REFLECT_BASE(SymbolFilter);
|
||||
REFLECT(fill_color);
|
||||
@@ -101,6 +107,13 @@ AColor GradientSymbolFilter::color(double x, double y, SymbolSet point, const T*
|
||||
else return AColor(0,0,0,0);
|
||||
}
|
||||
|
||||
bool GradientSymbolFilter::equal(const GradientSymbolFilter& that) const {
|
||||
return fill_color_1 == that.fill_color_1
|
||||
&& fill_color_2 == that.fill_color_2
|
||||
&& border_color_1 == that.border_color_1
|
||||
&& border_color_2 == that.border_color_2;
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(GradientSymbolFilter) {
|
||||
REFLECT_BASE(SymbolFilter);
|
||||
REFLECT(fill_color_1);
|
||||
@@ -120,6 +133,14 @@ LinearGradientSymbolFilter::LinearGradientSymbolFilter()
|
||||
: center_x(0.5), center_y(0.5)
|
||||
, end_x(1), end_y(1)
|
||||
{}
|
||||
LinearGradientSymbolFilter::LinearGradientSymbolFilter
|
||||
( const Color& fill_color_1, const Color& border_color_1
|
||||
, const Color& fill_color_2, const Color& border_color_2
|
||||
, double center_x, double center_y, double end_x, double end_y)
|
||||
: GradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)
|
||||
, center_x(center_x), center_y(center_y)
|
||||
, end_x(end_x), end_y(end_y)
|
||||
{}
|
||||
|
||||
AColor LinearGradientSymbolFilter::color(double x, double y, SymbolSet point) const {
|
||||
len = sqr(end_x - center_x) + sqr(end_y - center_y);
|
||||
@@ -132,6 +153,13 @@ double LinearGradientSymbolFilter::t(double x, double y) const {
|
||||
return min(1.,max(0.,t));
|
||||
}
|
||||
|
||||
bool LinearGradientSymbolFilter::operator == (const SymbolFilter& that) const {
|
||||
const LinearGradientSymbolFilter* that2 = dynamic_cast<const LinearGradientSymbolFilter*>(&that);
|
||||
return that2 && equal(*that2)
|
||||
&& center_x == that2->center_x && end_x == that2->end_x
|
||||
&& center_y == that2->center_y && end_y == that2->end_y;
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(LinearGradientSymbolFilter) {
|
||||
REFLECT_BASE(GradientSymbolFilter);
|
||||
REFLECT(center_x); REFLECT(center_y);
|
||||
@@ -149,3 +177,8 @@ AColor RadialGradientSymbolFilter::color(double x, double y, SymbolSet point) co
|
||||
double RadialGradientSymbolFilter::t(double x, double y) const {
|
||||
return sqrt( (sqr(x - 0.5) + sqr(y - 0.5)) * 2);
|
||||
}
|
||||
|
||||
bool RadialGradientSymbolFilter::operator == (const SymbolFilter& that) const {
|
||||
const RadialGradientSymbolFilter* that2 = dynamic_cast<const RadialGradientSymbolFilter*>(&that);
|
||||
return that2 && equal(*that2);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ class SymbolFilter : public IntrusivePtrVirtualBase {
|
||||
virtual AColor color(double x, double y, SymbolSet point) const = 0;
|
||||
/// Name of this fill type
|
||||
virtual String fillType() const = 0;
|
||||
/// Comparision
|
||||
virtual bool operator == (const SymbolFilter& that) const = 0;
|
||||
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
};
|
||||
@@ -66,8 +68,13 @@ intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader);
|
||||
/// Symbol filter that returns solid colors
|
||||
class SolidFillSymbolFilter : public SymbolFilter {
|
||||
public:
|
||||
inline SolidFillSymbolFilter() {}
|
||||
inline SolidFillSymbolFilter(Color fill_color, Color border_color)
|
||||
: fill_color(fill_color), border_color(border_color)
|
||||
{}
|
||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
||||
virtual String fillType() const;
|
||||
virtual bool operator == (const SymbolFilter& that) const;
|
||||
private:
|
||||
Color fill_color, border_color;
|
||||
DECLARE_REFLECTION();
|
||||
@@ -75,11 +82,18 @@ class SolidFillSymbolFilter : public SymbolFilter {
|
||||
|
||||
/// Symbol filter that returns some gradient
|
||||
class GradientSymbolFilter : public SymbolFilter {
|
||||
public:
|
||||
inline GradientSymbolFilter() {}
|
||||
inline GradientSymbolFilter(const Color& fill_color_1, const Color& border_color_1, const Color& fill_color_2, const Color& border_color_2)
|
||||
: fill_color_1(fill_color_1), border_color_1(border_color_1)
|
||||
, fill_color_2(fill_color_2), border_color_2(border_color_2)
|
||||
{}
|
||||
protected:
|
||||
Color fill_color_1, border_color_1;
|
||||
Color fill_color_2, border_color_2;
|
||||
template <typename T>
|
||||
AColor color(double x, double y, SymbolSet point, const T* t) const;
|
||||
bool equal(const GradientSymbolFilter& that) const;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
@@ -88,9 +102,12 @@ class GradientSymbolFilter : public SymbolFilter {
|
||||
class LinearGradientSymbolFilter : public GradientSymbolFilter {
|
||||
public:
|
||||
LinearGradientSymbolFilter();
|
||||
LinearGradientSymbolFilter(const Color& fill_color_1, const Color& border_color_1, const Color& fill_color_2, const Color& border_color_2
|
||||
,double center_x, double center_y, double end_x, double end_y);
|
||||
|
||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
||||
virtual String fillType() const;
|
||||
virtual bool operator == (const SymbolFilter& that) const;
|
||||
|
||||
/// return time on the gradient, used by GradientSymbolFilter::color
|
||||
inline double t(double x, double y) const;
|
||||
@@ -105,8 +122,14 @@ class LinearGradientSymbolFilter : public GradientSymbolFilter {
|
||||
/// Symbol filter that returns a radial gradient
|
||||
class RadialGradientSymbolFilter : public GradientSymbolFilter {
|
||||
public:
|
||||
inline RadialGradientSymbolFilter() {}
|
||||
inline RadialGradientSymbolFilter(const Color& fill_color_1, const Color& border_color_1, const Color& fill_color_2, const Color& border_color_2)
|
||||
: GradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)
|
||||
{}
|
||||
|
||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
||||
virtual String fillType() const;
|
||||
virtual bool operator == (const SymbolFilter& that) const;
|
||||
|
||||
/// return time on the gradient, used by GradientSymbolFilter::color
|
||||
inline double t(double x, double y) const;
|
||||
|
||||
@@ -180,7 +180,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi
|
||||
segment_subdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
|
||||
}
|
||||
// draw border
|
||||
if (border) {
|
||||
if (border && border_radius > 0) {
|
||||
// white/black or, if directB white/green
|
||||
border->SetBrush(Color(borderCol, (directB && borderCol == 0 ? 128 : borderCol), borderCol));
|
||||
border->SetPen(wxPen(*wxWHITE, (int) rotation.trS(border_radius)));
|
||||
|
||||
Reference in New Issue
Block a user