Skip to content

Instantly share code, notes, and snippets.

@C4Examples
Created July 26, 2012 18:14
Show Gist options
  • Select an option

  • Save C4Examples/3183597 to your computer and use it in GitHub Desktop.

Select an option

Save C4Examples/3183597 to your computer and use it in GitHub Desktop.
Fill Rule
//
// C4WorkSpace.m
// Examples
//
// Created by Travis Kirton
//
#import "C4WorkSpace.h"
@interface C4WorkSpace ()
-(void)createAndStylePolygons;
@end
@implementation C4WorkSpace {
C4Shape *poly1, *poly2;
}
-(void)setup {
[self createAndStylePolygons];
[self createLabels];
//define the fill rules for each polygon
poly1.fillRule = FILLNORMAL; //Default value
poly2.fillRule = FILLEVENODD;
}
-(void)createAndStylePolygons {
//the base width for the polygons
CGPoint polyPoints[7] = {
CGPointZero,
CGPointMake(150,-150),
CGPointMake(200,-100),
CGPointMake(100,0),
CGPointMake(0,-100),
CGPointMake(50,-150),
CGPointMake(200,0)
};
//create poly1 and style it
poly1 = [C4Shape polygon:polyPoints pointCount:7];
poly1.center = CGPointMake(self.canvas.center.x, self.canvas.height /3);
//create poly2 and style it
poly2 = [C4Shape polygon:polyPoints pointCount:7];
poly2.center = CGPointMake(self.canvas.center.x, self.canvas.height * 2/3);
//add all the polygons to the canvas
[self.canvas addShape:poly1];
[self.canvas addShape:poly2];
}
-(void)createLabels {
C4Font *f = [C4Font fontWithName:@"ArialRoundedMTBold" size:30.0f];
C4Label *l;
CGPoint center;
//create the FILLNORMAL label, center it to the base of poly1
l = [C4Label labelWithText:@"FILLNORMAL" font:f];
[l sizeToFit];
center = poly1.center;
center.y += poly1.height/2 +l.height;
l.center = center;
[self.canvas addLabel:l];
//create the FILLEVENODD label, center it to the base of poly2
l = [C4Label labelWithText:@"FILLEVENODD" font:f];
[l sizeToFit];
center = poly2.center;
center.y += poly2.height/2 + l.height;
l.center = center;
[self.canvas addLabel:l];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment