Created
March 15, 2012 09:10
-
-
Save aquarius/2043104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MNNewNodeDown.m | |
// Left | |
// | |
// Created by Markus Müller on 15.03.12 | |
// Copyright 2011 Markus Müller | |
// This code was generated by Opacity. You may use or modify it in any way. | |
// | |
#include "MNNewNodeDown.h" | |
#include <math.h> | |
const CGFloat kMyDrawingFunctionWidth = 20.0f; | |
const CGFloat kMyDrawingFunctionHeight = 20.0f; | |
void MyDrawingFunction(CGContextRef context, CGRect bounds) | |
{ | |
CGRect imageBounds = CGRectMake(0.0f, 0.0f, kMyDrawingFunctionWidth, kMyDrawingFunctionHeight); | |
CGFloat alignStroke; | |
CGFloat resolution; | |
CGMutablePathRef path; | |
CGPoint point; | |
CGColorRef color; | |
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); | |
CGAffineTransform transform; | |
CGFloat components[4]; | |
transform = CGContextGetUserSpaceToDeviceSpaceTransform(context); | |
resolution = sqrtf(fabsf(transform.a * transform.d - transform.b * transform.c)) * 0.5f * (bounds.size.width / imageBounds.size.width + bounds.size.height / imageBounds.size.height); | |
CGContextSaveGState(context); | |
CGContextClipToRect(context, bounds); | |
CGContextTranslateCTM(context, bounds.origin.x, bounds.origin.y); | |
CGContextScaleCTM(context, (bounds.size.width / imageBounds.size.width), (bounds.size.height / imageBounds.size.height)); | |
// Layer 3 | |
alignStroke = 0.0f; | |
path = CGPathCreateMutable(); | |
point = CGPointMake(10.0f, 9.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathMoveToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(13.0f, 9.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(13.0f, 6.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(16.0f, 6.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(16.0f, 9.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(19.0f, 9.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(19.0f, 12.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(16.0f, 12.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(16.0f, 15.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(13.0f, 15.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(13.0f, 12.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(10.0f, 12.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(10.0f, 9.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
CGPathCloseSubpath(path); | |
components[0] = 0.0f; | |
components[1] = 0.0f; | |
components[2] = 0.0f; | |
components[3] = 1.0f; | |
color = CGColorCreate(space, components); | |
CGContextSetFillColorWithColor(context, color); | |
CGColorRelease(color); | |
CGContextAddPath(context, path); | |
CGContextFillPath(context); | |
CGPathRelease(path); | |
alignStroke = 0.0f; | |
CGContextSaveGState(context); | |
CGContextTranslateCTM(context, 4.5f, 10.5f); | |
CGContextRotateCTM(context, -1.571f); | |
CGContextTranslateCTM(context, -4.5f, -10.5f); | |
path = CGPathCreateMutable(); | |
point = CGPointMake(-2.0f, 14.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathMoveToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(11.0f, 14.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(4.5f, 7.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
point = CGPointMake(-2.0f, 14.0f); | |
point.x = (roundf(resolution * point.x + alignStroke) - alignStroke) / resolution; | |
point.y = (roundf(resolution * point.y + alignStroke) - alignStroke) / resolution; | |
CGPathAddLineToPoint(path, NULL, point.x, point.y); | |
CGPathCloseSubpath(path); | |
components[0] = 0.0f; | |
components[1] = 0.0f; | |
components[2] = 0.0f; | |
components[3] = 1.0f; | |
color = CGColorCreate(space, components); | |
CGContextSetFillColorWithColor(context, color); | |
CGColorRelease(color); | |
CGContextAddPath(context, path); | |
CGContextFillPath(context); | |
CGPathRelease(path); | |
CGContextRestoreGState(context); | |
CGContextRestoreGState(context); | |
CGColorSpaceRelease(space); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment