Freigeben über


Calligraphy in Ink!

Ok, this is something I think is kinda cool... one of my side hobbies is calligraphy. I've been doing it since I was in early high school, and there's something graceful in the old style of writing. Well, as far as I knew, an InkCanvas only allows either a single rectangle or ellipse tip, which is pretty much set.

Well, that's not true. I did some experimenting, and by using the StylusTipTransform property on the DefaultDrawingAttributes of an InkCanvas, you can create whatever tip you want. Check this code out, that I call in the Window1 constructor: (My InkCanvas is named "Paper").

public Window1()

{

this.InitializeComponent();

Paper.DefaultDrawingAttributes.StylusTipTransform = new RotateTransform(-45).Value;

Paper.DefaultDrawingAttributes.Width = 20;

Paper.DefaultDrawingAttributes.StylusTip = System.Windows.Ink.StylusTip.Rectangle;

Paper.DefaultDrawingAttributes.IgnorePressure = false;

// Insert code required on object creation below this point.

}

Try that out, and it works pretty cool! Now, changing the Width of the tip makes a small or wider nib, and you do get slightly different looks if you change the StylusTip from Rectangle to Ellipse or turn on IgnorePressure. Actually, the way it works right now, I prefer the IgnorePressure to be ON, then it looks more like you're doing calligraphy with a pen, as opposed to with it off, it looks like you work with a brush.

So, the next thing I want to do (and I should be able to figure something out), is to get a dual line. I got my hands on a neat calligraphy marker that has two tips and a space between it. It's hard to visualize, but imagine if you draw a straight line, what you actually get are two straight lines spaced a little bit apart.

Comments