iphone Programming Glossary: fabsf
Optimized Image Loading in a UIScrollView http://stackoverflow.com/questions/1098234/optimized-image-loading-in-a-uiscrollview NSRange loadRange int totalChange lastCenterIndex centerIndex if totalChange 0 scrolling backwards loadRange.length fabsf totalChange loadRange.location centerIndex 5 unloadRange.length fabsf totalChange unloadRange.location centerIndex 6 else.. 0 scrolling backwards loadRange.length fabsf totalChange loadRange.location centerIndex 5 unloadRange.length fabsf totalChange unloadRange.location centerIndex 6 else if totalChange 0 scrolling forwards unloadRange.length fabsf totalChange.. fabsf totalChange unloadRange.location centerIndex 6 else if totalChange 0 scrolling forwards unloadRange.length fabsf totalChange unloadRange.location centerIndex 6 loadRange.length fabsf totalChange loadRange.location centerIndex 5 self..
Successful Swipe in UITextView? http://stackoverflow.com/questions/2042930/successful-swipe-in-uitextview withEvent event UITouch touch touches anyObject CGPoint currentPosition touch locationInView self CGFloat deltaX fabsf gestureStartPoint.x currentPosition.x CGFloat deltaY fabsf gestureStartPoint.y currentPosition.y if deltaX kMinimumGestureLength.. currentPosition touch locationInView self CGFloat deltaX fabsf gestureStartPoint.x currentPosition.x CGFloat deltaY fabsf gestureStartPoint.y currentPosition.y if deltaX kMinimumGestureLength deltaY kMaximumVariance NSLog @ Horizontal swipe detected..
iPhone UIScrollView Speed Check http://stackoverflow.com/questions/3719753/iphone-uiscrollview-speed-check isn't really necessary....... CGFloat scrollSpeedNotAbs distance 10 1000 in pixels per millisecond CGFloat scrollSpeed fabsf scrollSpeedNotAbs if scrollSpeed 0.5 isScrollingFast YES NSLog @ Fast else isScrollingFast NO NSLog @ Slow lastOffset..
Tap pressure strength detection using accelerometer http://stackoverflow.com/questions/5179426/tap-pressure-strength-detection-using-accelerometer setNextPressureValue KNumberOfPressureSamples float mostRecent pressureValues currentPressureValueIndex 1 sz pressure fabsf average mostRecent caluculate pressure as difference between average and current acceleration float diff fabsf average.. fabsf average mostRecent caluculate pressure as difference between average and current acceleration float diff fabsf average acceleration.z if pressure diff pressure diff setNextPressureValue if setNextPressureValue 0 if pressure minimumPressureRequired..
Detect horizontal panning in UITableView http://stackoverflow.com/questions/5426306/detect-horizontal-panning-in-uitableview view CGPoint translation gestureRecognizer translationInView cell superview Check for horizontal gesture if fabsf translation.x fabsf translation.y return YES return NO The calculation for the horizontal gesture is copied form Erik's.. translation gestureRecognizer translationInView cell superview Check for horizontal gesture if fabsf translation.x fabsf translation.y return YES return NO The calculation for the horizontal gesture is copied form Erik's code “Â I've tested this..
How to combine video clips with different orientation using AVFoundation http://stackoverflow.com/questions/6575128/how-to-combine-video-clips-with-different-orientation-using-avfoundation CGSizeApplyAffineTransform sourceVideoTrack.naturalSize sourceVideoTrack.preferredTransform CGSize size CGSizeMake fabsf temp.width fabsf temp.height CGAffineTransform transform sourceVideoTrack.preferredTransform videoComposition.renderSize.. sourceVideoTrack.naturalSize sourceVideoTrack.preferredTransform CGSize size CGSizeMake fabsf temp.width fabsf temp.height CGAffineTransform transform sourceVideoTrack.preferredTransform videoComposition.renderSize sourceVideoTrack.naturalSize..
UIScrollView : paging horizontally, scrolling vertically? http://stackoverflow.com/questions/728014/uiscrollview-paging-horizontally-scrolling-vertically withEvent UIEvent event if _isHorizontalScroll _isMultitouch CGPoint point touches anyObject locationInView self if fabsf _originalPoint.x point.x kThresholdX fabsf _originalPoint.y point.y kThresholdY _isHorizontalScroll YES _currentChild touchesCancelled.. _isMultitouch CGPoint point touches anyObject locationInView self if fabsf _originalPoint.x point.x kThresholdX fabsf _originalPoint.y point.y kThresholdY _isHorizontalScroll YES _currentChild touchesCancelled event touchesForView self withEvent..
Rotate a Sprite on a bezier path with touch - Cocos2D/Box2D http://stackoverflow.com/questions/7494795/rotate-a-sprite-on-a-bezier-path-with-touch-cocos2d-box2d array float piOverTwo M_PI 2.0 float sgn startAngle endAngle 1 1 float a1 startAngle for float totalAngle fminf twoPI fabsf endAngle startAngle totalAngle 0.00001f FLT_EPSILON nil float a2 a1 sgn min totalAngle piOverTwo curves addObject self createSmallArc.. nil float a2 a1 sgn min totalAngle piOverTwo curves addObject self createSmallArc radius_ a1 a1 a2 a2 totalAngle fabsf a2 a1 a1 a2 return curves Cubic bezier approximation of a circular arc centered at the origin This algorithm is based on.. bezierAngle ccpAngleSigned ccpSub startPoint positionOffset ccpSub endPoint positionOffset float bezierDuration radius fabsf bezierAngle speed id bezierTo CCBezierTo actionWithDuration bezierDuration bezier bezier id rotateBy CCRotateBy actionWithDuration..
Tap pressure strength detection using CPBPressureTouchGestureRecognizer http://stackoverflow.com/questions/8079580/tap-pressure-strength-detection-using-cpbpressuretouchgesturerecognizer setNextPressureValue KNumberOfPressureSamples float mostRecent pressureValues currentPressureValueIndex 1 sz pressure fabsf average mostRecent caluculate pressure as difference between average and current acceleration float diff fabsf average.. fabsf average mostRecent caluculate pressure as difference between average and current acceleration float diff fabsf average acceleration.z if pressure diff pressure diff setNextPressureValue if setNextPressureValue 0 if pressure minimumPressureRequired..
|