Skip to content

Instantly share code, notes, and snippets.

@drart
Created June 1, 2013 20:23
Show Gist options
  • Save drart/5691617 to your computer and use it in GitHub Desktop.
Save drart/5691617 to your computer and use it in GitHub Desktop.
Using a C4Slider to modulate the number of points in a C4Shape.
//
// C4WorkSpace.m
// ShapeSlider
//
// Created by Adam Tindale on 2013-06-01.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace
{
C4Slider * slid;
C4Shape * s;
CGPoint p[100];
}
-(void)setup
{
slid = [C4Slider slider:CGRectMake(0, 0, self.canvas.width, 20)];
[slid runMethod:@"blarg:" target:self forEvent:VALUECHANGED];
[self.canvas addUIElement:slid];
for (int i = 0; i < 100; i++)
{
p[i] = CGPointMake( [C4Math randomIntBetweenA:0 andB:self.canvas.width] ,[C4Math randomIntBetweenA:0 andB:self.canvas.height] );
}
s = [C4Shape polygon:p pointCount:4];
[self.canvas addShape:s];
}
-(void)blarg: (C4Slider *) sender
{
int temp = sender.value * 100;
[self.canvas removeObject:s];
s = [C4Shape polygon:p pointCount:temp];
[self.canvas addShape:s];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment