summaryrefslogtreecommitdiff
path: root/Sprite.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Sprite.cs')
-rw-r--r--Sprite.cs146
1 files changed, 143 insertions, 3 deletions
diff --git a/Sprite.cs b/Sprite.cs
index 290f582..ac2c0e7 100644
--- a/Sprite.cs
+++ b/Sprite.cs
@@ -145,8 +145,12 @@ namespace BitmapSpriteEd
Color[,] d=new Color[m_width,m_height];
for(int y=0;y<m_height;y++)
+ {
for(int x=0;x<m_width;x++)
- d[x,y]=m_data[m_width-x-1,y];
+ {
+ d[x,y]=m_data[m_width-x-1,y];
+ }
+ }
m_data=d;
m_changed=true;
@@ -157,8 +161,12 @@ namespace BitmapSpriteEd
Color[,] d=new Color[m_width,m_height];
for(int y=0;y<m_height;y++)
+ {
for(int x=0;x<m_width;x++)
- d[x,y]=m_data[x,m_height-y-1];
+ {
+ d[x,y]=m_data[x,m_height-y-1];
+ }
+ }
m_data=d;
m_changed=true;
@@ -169,8 +177,12 @@ namespace BitmapSpriteEd
Color[,] d=new Color[m_width,m_height];
for(int y=0;y<m_height;y++)
+ {
for(int x=0;x<m_width;x++)
- d[Mod(x+dx,m_width),Mod(y+dy,m_height)]=m_data[x,y];
+ {
+ d[Mod(x+dx,m_width),Mod(y+dy,m_height)]=m_data[x,y];
+ }
+ }
m_data=d;
m_changed=true;
@@ -218,6 +230,134 @@ namespace BitmapSpriteEd
m_changed=true;
}
+ public void DropShadow(int dx, int dy, Color col)
+ {
+ Color[,] d=new Color[m_width,m_height];
+
+ // I'm sure this is too convoluted...
+ //
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ d[x,y]=Color.Transparent;
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y].A!=0)
+ {
+ int nx=x+dx;
+ int ny=y+dy;
+
+ if (nx>=0 && nx<m_width && ny>=0 && ny<m_height &&
+ m_data[nx,ny].A==0)
+ {
+ d[nx,ny]=col;
+ }
+ }
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (d[x,y].A!=0)
+ {
+ m_data[x,y]=d[x,y];
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
+ public void Edge(Color col)
+ {
+ Color[,] d=new Color[m_width,m_height];
+
+ // I'm sure this is too convoluted...
+ //
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ d[x,y]=Color.Transparent;
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y].A!=0)
+ {
+ for(int dx=-1;dx<2;dx++)
+ for(int dy=-1;dy<2;dy++)
+ {
+ int nx=x+dx;
+ int ny=y+dy;
+
+ if (nx>=0 && nx<m_width && ny>=0 && ny<m_height &&
+ m_data[nx,ny].A==0)
+ {
+ d[nx,ny]=col;
+ }
+ }
+ }
+ }
+ }
+
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (d[x,y].A!=0)
+ {
+ m_data[x,y]=d[x,y];
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
+ public void Replace(Color from, Color to)
+ {
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y]==from)
+ {
+ m_data[x,y]=to;
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
+ public void Replace(Color to)
+ {
+ for(int y=0;y<m_height;y++)
+ {
+ for(int x=0;x<m_width;x++)
+ {
+ if (m_data[x,y].A>0)
+ {
+ m_data[x,y]=to;
+ }
+ }
+ }
+
+ m_changed=true;
+ }
+
public void Output(Stream stream)
{
Util.WriteInt(stream,m_width);