Skip to content

Latest commit

 

History

History
97 lines (69 loc) · 4.22 KB

README.markdown

File metadata and controls

97 lines (69 loc) · 4.22 KB

MROGeometry

Some C / Objective-C helpers related to

Parse a SVG path and return a retained CGPathRef.

See PathParser.h

Write a very simple, non-optimized form of SVG path.

Simple CGPoint math:

  • add,
  • subtract,
  • scale (multiply x and y with a number),
  • dot product,
  • distance square and distance.

Persist a CGPathRef using the SVG path format as ASCII/C String.

Parse a SVG path and return a retained CGPathRef.

Uses the Ragel-generate state machine PathParser.rl directly based on the W3C BNF path grammar for parsing.

Parse a SVG transform attribute and return a CGAffineTransform.

Uses the Ragel-generate state machine TrafoParser.rl directly based on the W3C grammar for parsing.

Global Macros

There are some macros I use all over the place. Instead including the same header in every source file I list them here (usually I put them into the common header *.pch):

// http://blog.mro.name/2010/06/xcode-missing-deprecated-warnings/
#define alloc(c)        ( (c *)[c alloc] )

#ifndef DEBUG
// Ensure DEBUG is defined properly
  #if NS_BLOCK_ASSERTIONS
//#error Define -DDEBUG=0 in Project Settings->GCC 4.2 Language->Other C Flags
	#define DEBUG 0
  #else
    #error Define -DDEBUG=1 in Project Settings->GCC 4.2 Language->Other C Flags
  #endif
#endif

#if DEBUG
  #ifdef NS_BLOCK_ASSERTIONS
    #error Don't define -DNS_BLOCK_ASSERTIONS=0 in Project Settings->GCC 4.2 Language->Other C Flags
  #endif
// Do Logging
  #define MRLogD(x, ...) NSLog(@"%s " x, __FUNCTION__, ## __VA_ARGS__)
#else
  #ifndef NS_BLOCK_ASSERTIONS
    #error Define -DNS_BLOCK_ASSERTIONS=1 in Project Settings->GCC 4.2 Language->Other C Flags
  #endif
  #if !NS_BLOCK_ASSERTIONS
    #error Define -DNS_BLOCK_ASSERTIONS=1 in Project Settings->GCC 4.2 Language->Other C Flags
  #endif
// No Logging
  #define MRLogD(x, ...)                            /* NSLog(x,##__VA_ARGS__) */
  #define NSLog(x, ...)                             /* NSLog(x,##__VA_ARGS__) */
#endif

Generate C state machines and pdf docs from Ragel sources.

Flattr this git repo