My News: TOP - Autos Intimate goods Chairs Underwear Ladies handbag Bracelets Sportswear Top auto-moto furniture Dating Boots FDA Approved Pharmacy Boats Necklace Yachts Medical tests Suits Medicine news Building materials Top casino Rington ya.by Tunings Sale Auto Chronometer Blog Search the Web Cases Mobiles Cigarettes Cars auto-moto Ear rings Cigarette Green Card Information
uncommonplace
 

    Follow me

     Fun with matrix math
    Filed under: — David @ 9:34 am

    For a while, I was wondering why arcs weren’t working in my paths. Finally I took another look, and realized I had put off actually implementing that feature. The reason is that the way arcs are represented in SVG is very different from how they’re done in Quartz. SVG basically has an end point, a radius, and a couple of flags. Quartz has two methods: one with a center, radius, and start and end angles, and the other with two points and a radius, which I’m not 100% sure I understand, even though I’ve used it for round-cornered rectangles.

    The SVG spec actually documents a method for converting from their version to the center/radius version, but if you take a peek at it you can guess why I’m not eager to implement the formula. The details of matrix operations fell out of my head immediately after my last algebra final, which was about 10 years ago. The only thing I remember for sure is that the identity matrix is full of zeroes except for ones down the diagonal. I think addition works the obvious way, while multiplication uses the rows of one and the columns of the other. I’m going to have to do some research on the subject for this project.

    I added the first unit test last night, just checking named colors (I also implemented all the color names). One interesting thing is that Xcode automatically added the test target’s plist file to the Subversion repository, while the test case’s files had to be added manually. They didn’t even show up in the SCM list, and I’m guessing it’s because I put them in a new folder which wasn’t in the repository yet.

     Check it out
    Filed under: — David @ 11:00 pm

    My original plan was to wait until the alpha stage before releasing the source code, which would have been when the inspector was working well and there were some basic drawing tools in place. But I feel more secure being able to check my code in on a regular basis, and the SourceForge project was up sooner than expected, so there it is.

    It turned out the https problem I was having with svnX was a problem with my Subversion installation… plus it was old. I had 1.1.3, and the latest is 1.3. So I updated that (with a downloadable binary, not from Fink this time), but still found I was getting 403 (permission denied) errors. That was because I actually had to go in and grant myself permission to access the Subversion repository. Yes, even though I own the project, I don’t automatically have admin access to all the services. But at least that’s easily remedied.

    I didn’t notice until I started the big checkin than all those SVG test suite files take up a lot of space - several megabytes. It’s a good thing I stripped out a bunch of them. As for finding a likable client, svnX was good enough for the initial checkin, and for everyday business it looks like Xcode’s built-in Subversion support will work well enough. If I ever need to check in something that isn’t in the Xcode project, I’ll just pop back to svnX for a moment.

    A while back I found out that the Finder can actually be used as a WebDAV client, so in theory it could access a Subversion repository too. But in practice, it keeps wanting to put its invisible DS_Store files everywhere, which of course you don’t want, so it ends up being useless for that purpose. That’s too bad; it would have been a cool way to let people download the source code.

    Cocoa hint of the day: if you have a floating window owned by a window controller, be sure to call setShouldCascadeWindows:NO on it. Otherwise your document windows will cascade off the floating widow’s position, which is not the natural order of things. I’m surprised Cocoa doesn’t automatically handle that.

     SourceForge, mock-ups, and a feature request
    Filed under: — David @ 6:40 pm

    The XVG project on SourceForge has been approved. That was impressively quick; I only put in the application yesterday. Obviously there’s nothing there now but the description, but I hope to get the code checked in by the end of the week. I just need to find a Subversion client I like (I find svnX unintuitive, and it doesn’t like using https).

    As I was browsing through HITheme.h just now, I had an idea for an add-on that would make this useful for mock-ups: graphic objects that draw user interface elements such as buttons and window parts. Interface Builder is great for mock-ups of windows that are only going to use standard controls, but if custom content is going to play a big part I find myself turning to Photoshop (I can make a darn good button with just three shape layers). But duplicating the standard controls in Photoshop is time-consuming, especially if they need to have proper transparency, like in a sheet. So having a drawing program that uses the actual system calls for drawing interface elements could be quite useful. Of course, for this I’ll also have to come up with a good extension mechanism for the app, including support for non-SVG graphic objects.

    And finally, my hit-testing work has led me to file a feature request in Apple’s database, radar #4492708 for those of you keeping score. What I want is a CGPath equivalent of CGContextReplacePathWithStrokedPath, which would create a new path which outlines the outline of another path, if you take my meaning. It would require a few extra parameters for line width and so forth, since you don’t have a graphics context to get those from. But not having to have a graphics context is the point here… because when I’m doing hit testing in an NSView, it’s not clear whether I have access to the same graphics context as when I’m drawing.

     Inspection
    Filed under: — David @ 3:08 pm

    Yesterday I got a basic inspector window working. At least, a couple of the controls work, like fill and stroke color. And all with bindings, too. I had to dig around a bit to find how to do that, so I’ll share that here: you set “bind to” to “Shared Application”, and the key path is “mainWindow.windowController.document.(your controller).selection”, assuming your document has an accessor method for the tree/array controller.

    For some reason, the inspector controls are all initially enabled when there’s no document open, and when I do open a document they’re disabled until I select something. The latter makes sense, although there needs to be a way to select the attributes of whatever the user is about to draw even if nothing is selected. There are two approaches for this: use the same inspector window, but use some kind of placeholder object when nothing is selected, or have a separate “current tool properties” interface like Photoshop.

    I also registered for a new project on SourceForge for XVG. One interesting this is that they don’t notify you by e-mail when a new project is approved. I wonder why that is.

    Some things to accomplish in the near future:

    • Round-trip integrity tests for saving to SVG and reading back in again. Note that this is not the same as ensuring that a saved SVG file is the same as the original, which is not a goal. Unsupported elements will not be preserved.
    • Fix the default font size. I haven’t found where that’s defined. Apparently my guess of 24pt is too small, and for some test images in particular my text is way too big.
    • Start writing unit tests, such as the above-mentioned round-trip integrity, plus some tests to identify problems with test images.
    • Implement hit testing so that objects can be selected directly with the mouse.
     And then MySQL died again
    Filed under: — David @ 2:50 pm

    A couple of months ago when I was backing up my PowerBook in preparation for defragging, I had to change the permissions on some MySQL files so I could read them and back them up. Adding a read permission doesn’t seem like it should mess things up, but ever since I’ve done that nothing has been able to connect to MySQL. This isn’t the password problem I had before; the applications can’t even connect to the server. MediaWiki says it’s trying to connect through /var/mysql/mysql.sock; this is understandable since /var/mysql/ doesn’t exist. Not that I understand exactly how a .sock file works. If it’s even a file. The mysql server is running; it’s listed when I enter ps -ax | grep mysql. I tried installing phpMyAdmin, but it can’t connect to the server either so that didn’t help at all.

    Maybe it’s my fault for choosing something like this to store my journal in. It’s hard to find any free/open source software, especially something designed to run on a server, that has any considerable degree of user friendliness. It’s okay when I can follow the step-by-step directions to set it up, and it’s great while it’s working, but when it breaks I’m really left in the dark.

     Text is hard
    Filed under: — David @ 9:58 am

    Last night I finally got text to draw… though I’m not sure what I did to make it work. Eventually I even got it to draw right side up. This morning I actually got it to draw the correct text instead of garbage characters - the secret is to use kCGEncodingMacRoman in the call to CGContextSelectFont. Unicode support is obviously going to require using ATSUI, which will be a lot more work. For a while I had gradient fills working with text, but that seems to have broken. Gradient stroke on text will be much harder, since Quartz doesn’t provide an easy way to get the text stroke into the clipping path.

    Also, I figured out the secret to using isFlipped: you have to invert your frame bindings because they’re going to get flipped.

    I’m still figuring out what the default font settings are supposed to be; the test suite has lots of text elements with no font specified. It also appears that the current transformation isn’t supposed to affect text, which is weird, but until I look into it more that’s the only way I can explain some of the differences between my rendering and theirs.

    I also enabled the view to indicate the current selection from the outline view in the drawer, drawing the usual handle boxes on the corners of the bounding box. I’m going to need a better way to calculate the bounding box of a path, since CGPathGetBoundingBox just gives you a rectangle enclosing all the control points, and in many cases that’s too big. The next step along this path - towards making an actual functional drawing app - is hit testing so you can select objects directly with the mouse, plus an inspector window for showing and changing fill and stroke properties and so forth. That will be fun to have working.

     XVG first look
    Filed under: — David @ 9:21 am

    I’ve uploaded a screen shot of the current XVG document window showing one of the test suite files.

    The drawer was added just this morning, in another cool Cocoa Bindings moment. I just popped in the outline view and the tree controller and off it went. This will probably evolve into the equivalent of Photoshop’s layers palette, and may get moved to a floating window.

    Obviously I still haven’t gotten the text to render. I’m also struggling with NSView. I haven’t figured out a way to size it correctly while keeping it anchored to the top left instead of the bottom left. Having to flip the coordinate system before drawing only complicates things. I’d like to find the NeXT guy who thought putting the origin in the bottom left was a good idea and smack him around a little.

    Edit: I just discovered the -isFlipped method in NSView. It interacts strangely with the scroll view, but if I can get it to work right it will help a lot.

     XVG: One week later
    Filed under: — David @ 11:46 pm

    After just a week of working on this in my spare time, I’ve made some pretty impressive progress. The basic shapes are all working (except polygons and ovals). Fill and stroke colors are working, except for some CSS and inheritance situations. Gradients mostly work, depending on the coordinate space. I’ve sketched out the filter classes, but really it’s time to start working on the document stuff so I can more easily test it with other SVG files, and make sure the XML generation is working.

    A while back, when I was first experimenting with Inkscape, I made a couple of icons - Squiver and Sprightly versions of some application icons. I added the Sprightly iTunes icon to the XVG test files, and that worked almost right away - I just had to add support for specifying all the display properties in the style attribute, CSS-style, since that’s how Inkscape stores them. Other than the iTunes icon, the other test files are all taken from the SVG standard test suite, based on which features I intend to implement. A few are rendering correctly (except for the text which I still need to fix), and some others I may still prune out.

    Inkscape also has a bunch of extensions to SVG, such as storing whether a point on a path is a corner or smooth. Generally they’re things that are just useful to keep track of for editing, which is why they aren’t part of the SVG standard. I may adopt some of them, especially if I can figure out what they are. That wiki page of theirs has a nice long list, but not many actual descriptions.


    This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

    Powered by WordPress

    Shareware Icons Games
    Topic - News Blogs: Bracelets auto-moto Chairs Blog Search the Web Top auto-moto Boats Autos Cases Intimate goods Necklace Trousers Underwear Top casino Sale Auto Building materials Evening dress Yachts Tunings Medicine news furniture Rington Replica Rolex Mobiles Rolex Replica Boots Ear rings Fashions Green Card Information ya.by Balans Cigarettes Medical tests Sport Betting Cars