Posted By

ronaldm333 on 03/27/15


Tagged

xcode CoreGraphics iDraw


Versions (?)

iDrawCoreGraphics1


 / Published in: Other
 

iDraw generates Swift Core Graphics code for images. This listing is for an iOS Single View Application in Xcode.

  1. func drawCircle() {
  2. UIGraphicsBeginImageContextWithOptions (CGSize(width:100, height:100), false, 0.0) // false - not opaque; 0.0 - no scaling
  3. let ctx = UIGraphicsGetCurrentContext()
  4.  
  5. /* Shape */
  6. let pathRef = CGPathCreateMutable()
  7. // draws four 90 degree arcs
  8. CGPathMoveToPoint(pathRef, nil, 50, 100)
  9. CGPathAddCurveToPoint(pathRef, nil, 22.386, 100, 0, 77.614, 0, 50)
  10. CGPathAddCurveToPoint(pathRef, nil, 0, 22.386, 22.386, 0, 50, 0)
  11. CGPathAddCurveToPoint(pathRef, nil, 77.614, 0, 100, 22.386, 100, 50)
  12. CGPathAddCurveToPoint(pathRef, nil, 100, 77.614, 77.614, 100, 50, 100)
  13. CGPathCloseSubpath(pathRef)
  14.  
  15. //CGContextSetRGBFillColor(ctx, 0.341, 0.855, 0.835, 1) old way
  16. CGContextSetFillColorWithColor(ctx, UIColor(red: 0.341, green: 0.855, blue: 0.835, alpha: 1.0).CGColor)
  17. CGContextAddPath(ctx, pathRef)
  18. CGContextFillPath(ctx)
  19.  
  20. // Returns an image based on the contents of the current bitmap-based graphics context.
  21. let img = UIGraphicsGetImageFromCurrentImageContext()
  22. let imageView = UIImageView(image: img!)
  23. // place origin of frame at 180, 300
  24. imageView.frame = CGRect(x: 180, y: 300, width: 100, height: 100)
  25. self.view.addSubview(imageView)
  26. UIGraphicsEndImageContext()
  27. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jack23 on September 11, 2019

I am looking for play dvd in windows 10 in a short span of time and there are many different players are available at our websites.

You need to login to post a comment.