Removed last of the BeginDrawing/EndDrawing calls;

Added english_number_ordinal script function;
Working on symbols with a different aspect ratio (i.e. wider/smaller symbols)

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@558 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-07-12 17:01:07 +00:00
parent b21192646b
commit d590819762
22 changed files with 137 additions and 54 deletions
+4 -4
View File
@@ -47,8 +47,8 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
alpha = (Byte*) malloc(width * height);
symbol.SetAlpha(alpha);
}
for (UInt y = 0 ; y < width ; ++y) {
for (UInt x = 0 ; x < height ; ++x) {
for (UInt y = 0 ; y < height ; ++y) {
for (UInt x = 0 ; x < width ; ++x) {
// Determine set
// green -> border or outside
// green+red=white -> border
@@ -71,8 +71,8 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
}
}
Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double border_radius, int size, bool edit_hints) {
Image i = render_symbol(symbol, border_radius, size, edit_hints);
Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double border_radius, int width, int height, bool edit_hints) {
Image i = render_symbol(symbol, border_radius, width, height, edit_hints);
filter_symbol(i, filter);
return i;
}
+1 -1
View File
@@ -35,7 +35,7 @@ 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, bool edit_hints = false);
Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double border_radius = 0.05, int width = 100, int height = 100, bool edit_hints = false);
/// Is a point inside a symbol?
enum SymbolSet
+25 -4
View File
@@ -14,13 +14,29 @@ DECLARE_TYPEOF_COLLECTION(SymbolPartP);
// ----------------------------------------------------------------------------- : Simple rendering
Image render_symbol(const SymbolP& symbol, double border_radius, int size, bool editing_hints) {
SymbolViewer viewer(symbol, size, border_radius);
Bitmap bmp(size, size);
Image render_symbol(const SymbolP& symbol, double border_radius, int width, int height, bool editing_hints) {
SymbolViewer viewer(symbol, editing_hints, width, border_radius);
// limit width/height ratio to aspect ratio of symbol
double ar = symbol->aspectRatio();
double par = (double)width/height;
if (par > ar && ar > 1) {
width = height * ar;
} else if (par < ar && ar < 1) {
height = width / ar;
}
if (width > height) {
viewer.setZoom(width);
viewer.setOrigin(Vector2D(0,-(width-height) * 0.5));
viewer.border_radius *= (double)height / width;
} else {
viewer.setZoom(height);
viewer.setOrigin(Vector2D(-(height-width) * 0.5,0));
viewer.border_radius *= (double)width / height;
}
Bitmap bmp(width, height);
wxMemoryDC dc;
dc.SelectObject(bmp);
clearDC(dc, Color(0,128,0));
viewer.setZoom(size);
viewer.draw(dc);
dc.SelectObject(wxNullBitmap);
return bmp.ConvertToImage();
@@ -40,8 +56,13 @@ SymbolViewer::SymbolViewer(const SymbolP& symbol, bool editing_hints, double siz
void SymbolViewer::setZoom(double zoom) {
rotation.setZoom(zoom);
rotation.setOrigin(zoom * origin);
multiply = Matrix2D(zoom,0, 0,zoom);
}
void SymbolViewer::setOrigin(const Vector2D& origin) {
this->origin = origin;
rotation.setOrigin(origin);
}
// ----------------------------------------------------------------------------- : Drawing : Combining
+2 -1
View File
@@ -17,7 +17,7 @@
// ----------------------------------------------------------------------------- : Simple rendering
/// Render a Symbol to an Image
Image render_symbol(const SymbolP& symbol, double border_radius = 0.05, int size = 100, bool editing_hints = false);
Image render_symbol(const SymbolP& symbol, double border_radius = 0.05, int width = 100, int height = 100, bool editing_hints = false);
// ----------------------------------------------------------------------------- : Symbol Viewer
@@ -41,6 +41,7 @@ class SymbolViewer : public SymbolView {
// --------------------------------------------------- : Point translation
void setZoom(double zoom);
void setOrigin(const Vector2D& origin);
Rotation rotation; ///< Object that handles rotation, scaling and translation
Matrix2D multiply; ///< Scaling/rotation of actual parts