Skip to main content
GameDev.net gamedev.net
🔒 Locked

Bored again

Started by capn_midnight Sep 14, 2005 at 5:59 PM 16 replies 1.5k views
Original Post
capn_midnight
capn_midnight
only this time I was at work so I couldn't burn something (well, I guess I could, and then I'd have a really long vacation after that...). Anyway, in about an hour for some reason I made a "dock" for windows. It's actually pretty stupid, it flickers really bad and only opens Windows Explorer Here it is at the bottom of the screen, all docile and stupid like. Notepad is there so you can see the transparency. and here I am, hovering over one of the icons. I have no idea why I did this. It's not like the dock is any good anyway.
CrimsonSun
CrimsonSun
Cool.

Did you often have freetime at work?
Mercury
Mercury
How do you resize the icons to make them get larger? I'm having problems with that right now.
capn_midnight
capn_midnight
Quote:
Original post by Mercury
How do you resize the icons to make them get larger? I'm having problems with that right now.


The icons are initially scaled down, and then are scaled up to normal when you hover over them. It depends on the graphics API on *how* you would do that. For GDI+ (which is what I'm using), it's all in the DrawImage method of the Graphics object. DrawImage accepts a parameter of a destination rectangle, which defines the location and the dimensions. There are a lot of overloaded copies of the DrawImage method (24 iirc), so you'd have to look for one in particular.

I'd post the code, but it's ugly and on Lappy686, which isn't in the room or on the network. I need to cook dinner, and then I'll bring it down.
Mercury
Mercury
Quote:
Original post by capn_midnight
Quote:
Original post by Mercury
How do you resize the icons to make them get larger? I'm having problems with that right now.


The icons are initially scaled down, and then are scaled up to normal when you hover over them.

I'd post the code, but it's ugly and on Lappy686, which isn't in the room or on the network. I need to cook dinner, and then I'll bring it down.

If you're using DrawIconEx to resize the icons, then don't worry about showing the code. It doesn't resize the icons to the quality I'm looking for. Otherwise, I'd be eternally greatful. [smile]
capn_midnight
capn_midnight
Quote:
Original post by Mercury
Quote:
Original post by capn_midnight
Quote:
Original post by Mercury
How do you resize the icons to make them get larger? I'm having problems with that right now.


The icons are initially scaled down, and then are scaled up to normal when you hover over them.

I'd post the code, but it's ugly and on Lappy686, which isn't in the room or on the network. I need to cook dinner, and then I'll bring it down.

If you're using DrawIconEx to resize the icons, then don't worry about showing the code. It doesn't resize the icons to the quality I'm looking for. Otherwise, I'd be eternally greatful. [smile]

If you're starting with a normal sized icon and resizing it larger, turn it around and use the normal sized icon as the "large" icon and scale down from there for "small". You won't have as much pixelation.
Mercury
Mercury
Quote:
Original post by capn_midnight
Quote:
Original post by Mercury
Quote:
Original post by capn_midnight
Quote:
Original post by Mercury
How do you resize the icons to make them get larger? I'm having problems with that right now.


The icons are initially scaled down, and then are scaled up to normal when you hover over them.

I'd post the code, but it's ugly and on Lappy686, which isn't in the room or on the network. I need to cook dinner, and then I'll bring it down.

If you're using DrawIconEx to resize the icons, then don't worry about showing the code. It doesn't resize the icons to the quality I'm looking for. Otherwise, I'd be eternally greatful. [smile]

If you're starting with a normal sized icon and resizing it larger, turn it around and use the normal sized icon as the "large" icon and scale down from there for "small". You won't have as much pixelation.

Yeah, that's what I'm doing right now. It's still pretty obvious that it's not the original image size, though. I guess I'll have to suffice with that, then.
PnP Bios
PnP Bios
width = "800" height = "600"

Is it realy that hard? Some of us are still running 1024x768 on our laptops here. That makes it kinda hard to see your work in all it's splendor.

Keep it up though. Boredom is awsome. Especialy when made into a productive kind of boredom.
Michalson
Michalson
Too bad the forum move command doesn't work the way I would want it to in order to move threads into the IOTD forum, otherwise this thread would have been "moderated".
PnP Bios
PnP Bios
Quote:
Original post by Michalson
Too bad the forum move command doesn't work the way I would want it to in order to move threads into the IOTD forum, otherwise this thread would have been "moderated".


moderated with extreme prejeduce?
capn_midnight
capn_midnight
Quote:
Original post by Michalson
Too bad the forum move command doesn't work the way I would want it to in order to move threads into the IOTD forum, otherwise this thread would have been "moderated".

I only found out about the IOTD after I made this post. Besides, I didn't think it worthy.
Endar
Endar
Quote:
Original post by capn_midnight
Quote:
Original post by CrimsonSun
Cool.

Did you often have freetime at work?

yeah...


What is it that you do that you have free time at work?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Hedos
Hedos
That's neat, please, when you get the chance to, post the code, that's the kind of stuff which interests me [smile]
capn_midnight
capn_midnight
My work involves writing mundane ASP.Net code for a mundane GIS application in a mundane little office without a Skull of Mundane from "Ultima 4: Quest of the Avatar". If you know the skull, at this point I don't care about its consequences.

At the end of the day (apparently 4pm) after everyone else has left and I'm socking away hours because I have nothing better to do, if I don't have anything else to do I pull out my own laptop and write some of the craziest code ever.

Some of it I'm about to post as soon as I pull it out of the bag.
capn_midnight
capn_midnight
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using Game.Common.Graphics;//using System.Timers;namespace Shenanigans{	/// <summary>	/// Summary description for Form1.	/// </summary>	public class Form1 : System.Windows.Forms.Form	{		/// <summary>		/// Required designer variable.		/// </summary>		private System.ComponentModel.Container components = null;		private Timer t;		private CyclicAnimation[] a;		private Bitmap buffer, pickBuffer;		private Graphics bufGraph, g;		private int mx, my;		private Color c;		private Brush clear, backBrush;		private Rectangle back;		public Form1()		{			//			// Required for Windows Form Designer support			//			InitializeComponent();			a = new CyclicAnimation[4]{new CyclicAnimation("mc.png"),										  new CyclicAnimation("nn.png"),										  new CyclicAnimation("md.png"),										  new CyclicAnimation("rb.png")};			a[0].X = 448;			a[0].Y = 720;			a[1].X = 480;			a[1].Y = 720;			a[2].X = 512;			a[2].Y = 720;			a[3].X = 544;			a[3].Y = 720;			c = Color.Transparent;			buffer = new Bitmap(1024, 768);			bufGraph = Graphics.FromImage(buffer);			pickBuffer = new Bitmap(buffer.Width, buffer.Height);			clear = new SolidBrush(Color.Transparent);			backBrush = new SolidBrush(Color.Turquoise);			back = new Rectangle(440, 720, 130, 30);			g = Graphics.FromImage(pickBuffer);			t = new Timer();			t.Tick +=new EventHandler(t_Tick);			t.Interval = 33;			t.Start();		}		protected override void OnMouseMove(MouseEventArgs e)		{			mx = e.X;			my = e.Y;		}		protected override void OnLostFocus(EventArgs e)		{			c = Color.Transparent;		}		protected override void OnClick(EventArgs e)		{			Pick();			int i;			for(i = 0; i < a.Length; ++i)			{				if(c.ToArgb() == a.Mask.ToArgb())				{					break;				}			}			System.Diagnostics.Process p = new System.Diagnostics.Process();			p.StartInfo.FileName = "explorer";			p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;			p.Start();		}		/// <summary>		/// Clean up any resources being used.		/// </summary>		protected override void Dispose( bool disposing )		{			if( disposing )			{				if (components != null) 				{					components.Dispose();				}			}			base.Dispose( disposing );		}		protected override void OnPaint(PaintEventArgs e)		{			bufGraph.Clear(Color.Transparent);			bufGraph.FillEllipse(backBrush, back);			foreach(CyclicAnimation b in a)			{				if(e.ClipRectangle.IntersectsWith(b.BoundingBox))				{					b.Paint(bufGraph);				}			}			e.Graphics.DrawImageUnscaled(buffer, 0, 0);		}		#region Windows Form Designer generated code		/// <summary>		/// Required method for Designer support - do not modify		/// the contents of this method with the code editor.		/// </summary>		private void InitializeComponent()		{			// 			// Form1			// 			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);			this.BackColor = System.Drawing.Color.Black;			this.ClientSize = new System.Drawing.Size(292, 275);			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;			this.Name = "Form1";			this.Opacity = 0.66;			this.ShowInTaskbar = false;			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;			this.Text = "Form1";			this.TopMost = true;			this.TransparencyKey = System.Drawing.Color.Black;			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;			this.Load += new System.EventHandler(this.Form1_Load);		}		#endregion		/// <summary>		/// The main entry point for the application.		/// </summary>		[STAThread]		static void Main() 		{			Application.Run(new Form1());		}		private void Pick()		{			g.Clear(Color.Black);			foreach(CyclicAnimation b in a)			{				b.PaintMask(g);			}			c = pickBuffer.GetPixel(mx, my);		}		private void t_Tick(object sender, EventArgs e)		{			Pick();						foreach(CyclicAnimation b in a)			{				if(b.Mask.ToArgb() == c.ToArgb())				{					b.Up();					if(b.Changed)					{						this.Invalidate(b.BoundingBox);					}				}				else 				{					Rectangle temp = b.BoundingBox;					b.Down();					if(b.Changed)					{						this.Invalidate(temp);					}				}							}		}	}	/// <summary>	/// Super class for all rendering objects	/// </summary>	public abstract class GraphicsObject	{		private static Color counter = Color.Black;		private Color mask;		private SolidBrush maskBrush;		public GraphicsObject()		{			mask = Color.FromArgb(counter.ToArgb() + 1);			counter = Color.FromArgb(counter.ToArgb() + 1);			maskBrush = new SolidBrush(mask);		}		public abstract void Paint(Graphics g);		public virtual void PaintMask(Graphics g)		{			g.FillRectangle(maskBrush, BoundingBox);		}		public abstract Rectangle BoundingBox		{			get;		}		public Color Mask		{			get			{				return mask;			}		}	}	/// <summary>	/// A two phase animation, forward and reverse. When forward 	/// the forward phase is complete, the reverse phase begins.	/// </summary>	public class CyclicAnimation : GraphicsObject	{		protected Bitmap img;		protected Rectangle bounds;		protected int frame, steps, dw, dh;		protected bool upswing, changed;		public CyclicAnimation(string filename)		{			img = new Bitmap(filename);			bounds = new Rectangle(0, 0, img.Width/2, img.Height/2);			steps = 3;			dw = (img.Width - bounds.Width) / steps;			dh = (img.Height - bounds.Height) / steps;			frame = 0;			upswing = true;			changed = false;		}		public virtual void Up()		{			changed = false;			if(frame < steps)			{				frame ++;				bounds.Width += dw;				bounds.X -= dw/2;				bounds.Height += dh;				bounds.Y -= dh;				changed = true;			}			if(frame == steps)			{				upswing = false;							}		}		public virtual void Down()			{			changed = false;			if(frame > 0)			{					changed = true;				frame --;				bounds.Width -= dw;				bounds.X += dw/2;				bounds.Height -= dh;				bounds.Y += dh;			}			if(frame == 0)			{				upswing = true;			}		}		public static CyclicAnimation operator++(CyclicAnimation ca)		{			ca.Up();			return ca;		}		public static CyclicAnimation operator--(CyclicAnimation ca)		{			ca.Down();			return ca;		}		public virtual void Update()		{			if(upswing) Up();			else Down();		}		public override void Paint(Graphics g)		{			g.DrawImage(img, bounds);		}		public int X		{			set			{				bounds.X = value;			}			get			{				return bounds.X;			}		}		public int Y		{			set			{				bounds.Y = value;			}			get			{				return bounds.Y;			}		}		public override Rectangle BoundingBox		{			get			{				return bounds;			}		}		public bool Changed		{			get			{				return changed;			}		}	}}


there wouldn't have been so many classes, but I had started doing something else and then just ended up making this.
Promit
Promit
Aren't OSX icons defined as vector images (SVG maybe) ? It doesn't seem like bitmaps are likely to scale very well. The Linux programs I've seen to do this usually have several sizes of icon at their disposal (16x16, 32x32, 48x48, 64x64, 96x96) and choose the closest one, scaling it a little bit.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
capn_midnight
capn_midnight
Quote:
Original post by Promit
Aren't OSX icons defined as vector images (SVG maybe) ? It doesn't seem like bitmaps are likely to scale very well. The Linux programs I've seen to do this usually have several sizes of icon at their disposal (16x16, 32x32, 48x48, 64x64, 96x96) and choose the closest one, scaling it a little bit.


yeah, well, that's too much work for an hour.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.