• Advertisement
  • entries
    359
  • comments
    237
  • views
    189008

Borders

Sign in to follow this  

63 views

Spent about two hours this morning writing up a class for border rendering. I'd been avoiding it for some time, since I couldn't think of an elegant system to allow for both inner and outer controlled borders (and because I'd not implemented rotation yet). That is, some will need to be "fit within this space" sort of borders, and some will be "wrap around this stuff" sort of borders. Both should render similarly, and both should allow for other rectangles to reference both the 'inner' and 'outer' rectangles in the auto-arrangement system.

Anyways, once I thought about the requirements and put them into phrasing like above, it was pretty simple to knock up a dummy renderable system where a border is represented by two objects in the auto-arrangement system. The object takes two resources (a corner texture and a bar texture), a width, and an enumerated behavior (wether the inner rect depends on the outer, or vice versa). It then generates and arranges/rotates 4 corners, 4 bars, and 10 interlinked rectangles representing the border.

I am quite pleased with it so far.

[edit:]

Hah! I have made a slightly clever mechanism to allow borders to decorate other renderables, while not requiring the user to update references too much upon decoration. Much nicer:

BorderedBackground testAround = BorderedBackground.Around(kanji, "solid", "solid", "solid", 1);
testAround.BGColor = System.Drawing.Color.Crimson.ToArgb();
testAround.Color = System.Drawing.Color.SkyBlue.ToArgb();


Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement