- KidDynamite
- Feb 11, 2005
-
|
The iBook says println("Hello, world") should be it's own self-contained program but when I make a playgrounds file with just that it has nothing over in the "playground" What's up with that? In fact any print doesn't show up over there but when you declare a variable it does show up like it was being printed.
|
#
¿
Jun 3, 2014 01:53
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 5, 2024 14:09
|
|
- KidDynamite
- Feb 11, 2005
-
|
So I'm having a weird issue where I'm trying to make a whiteboard app and the code works fine on a workmates phone and on the simulators on his laptop but then as soon as I ty it any line I draw is skewed and moved up almost as if it's getting pushed onto the z axis. This is just code we're using from a Ray Wanderlich tutorial.
code: func drawLineFrom(fromPoint: CGPoint, toPoint: CGPoint) {
// 1
UIGraphicsBeginImageContext(view.frame.size)
let context = UIGraphicsGetCurrentContext()
tempImageView.image?.drawInRect(CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height))
// 2
CGContextMoveToPoint(context, fromPoint.x, fromPoint.y)
CGContextAddLineToPoint(context, toPoint.x, toPoint.y)
// 3
CGContextSetLineCap(context, kCGLineCapRound)
CGContextSetLineWidth(context, brushWidth)
CGContextSetRGBStrokeColor(context, red, green, blue, 1.0)
CGContextSetBlendMode(context, kCGBlendModeNormal)
// 4
CGContextStrokePath(context)
// 5
tempImageView.image = UIGraphicsGetImageFromCurrentImageContext()
tempImageView.alpha = opacity
UIGraphicsEndImageContext()
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
swiped = false
if let touch = touches.first as? UITouch {
lastPoint = touch.locationInView(self.view)
}
}
override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
// 6
swiped = true
if let touch = touches.first as? UITouch {
let currentPoint = touch.locationInView(view)
drawLineFrom(lastPoint, toPoint: currentPoint)
// 7
lastPoint = currentPoint
}
}
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
if !swiped {
// draw a single point
drawLineFrom(lastPoint, toPoint: lastPoint)
}
// Merge tempImageView into mainImageView
UIGraphicsBeginImageContext(mainImageView.frame.size)
mainImageView.image?.drawInRect(CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height), blendMode: kCGBlendModeNormal, alpha: 1.0)
tempImageView.image?.drawInRect(CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height), blendMode: kCGBlendModeNormal, alpha: opacity)
mainImageView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
tempImageView.image = nil
}
Is there any reason why that logic would work fine for him and not for me? I suspect it's something to do with UIGraphicsGetImageFromCurrentImageContext() but we're both on the same version of Xcode. We're going to write our own code for the whiteboard soon but we just needed to get a demo off the ground really quickly.
|
#
¿
Apr 23, 2015 16:51
|
|
- KidDynamite
- Feb 11, 2005
-
|
Is that rjmcall with the teapot shirt?
|
#
¿
Jun 9, 2015 19:52
|
|
- KidDynamite
- Feb 11, 2005
-
|
Awesome I came in late but that was a great presentation from what I saw.
|
#
¿
Jun 9, 2015 20:52
|
|
- KidDynamite
- Feb 11, 2005
-
|
I signed up for the mailing list and immediately regretted it. I am interested in helping, but this is miserable.
|
#
¿
Aug 1, 2016 02:23
|
|