mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
finished symbol rendering
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@90 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <render/symbol/filter.hpp>
|
||||
#include <render/symbol/viewer.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
#include <util/error.hpp>
|
||||
|
||||
@@ -37,6 +38,12 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
|
||||
}
|
||||
}
|
||||
|
||||
Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double border_radius, int size) {
|
||||
Image i = render_symbol(symbol, border_radius, size);
|
||||
filter_symbol(i, filter);
|
||||
return i;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFilter
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolFilter) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Symbol);
|
||||
class SymbolFilter;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Color
|
||||
@@ -32,6 +33,9 @@ class AColor : public Color {
|
||||
*/
|
||||
void filter_symbol(Image& symbol, const SymbolFilter& filter);
|
||||
|
||||
/// Render a Symbol to an Image and filter it
|
||||
Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double border_radius = 0.05, int size = 100);
|
||||
|
||||
/// Is a point inside a symbol?
|
||||
enum SymbolSet
|
||||
{ SYMBOL_INSIDE
|
||||
|
||||
@@ -11,6 +11,19 @@
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolPartP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Simple rendering
|
||||
|
||||
Image render_symbol(const SymbolP& symbol, double border_radius, int size) {
|
||||
SymbolViewer viewer(symbol, border_radius);
|
||||
Bitmap bmp(size, size);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bmp);
|
||||
clearDC_black(dc);
|
||||
viewer.draw(dc);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bmp.ConvertToImage();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Constructor
|
||||
|
||||
SymbolViewer::SymbolViewer(const SymbolP& symbol, double border_radius)
|
||||
|
||||
@@ -40,13 +40,14 @@ class SymbolViewer : public SymbolView {
|
||||
Rotation rotation; ///< Object that handles rotation, scaling and translation
|
||||
|
||||
// --------------------------------------------------- : Drawing
|
||||
|
||||
public:
|
||||
|
||||
/// Draw the symbol to a dc
|
||||
void draw(DC& dc);
|
||||
|
||||
|
||||
void highlightPart(DC& dc, const SymbolPart& part, HighlightStyle style);
|
||||
|
||||
|
||||
void onAction(const Action&, bool) {}
|
||||
|
||||
private:
|
||||
/// Combines a symbol part with what is currently drawn, the border and interior are drawn separatly
|
||||
/** directB/directI are true if the border/interior is the screen dc, false if it
|
||||
|
||||
Reference in New Issue
Block a user