Apple Swift (iOS-CoreGraphics / QuartzCore)-832 바이트
Apple iOS 장치에 Quartz를 사용하여 모양을 완전히 그렸습니다. 불행히도 이것은 특히 규모가 큰 언어가 아니기 때문에 결과가 상당히 크지 만 얻을 수있는만큼 작습니다.
UIGraphicsBeginImageContext(CGSize(width:60,height:60));let c=UIGraphicsGetCurrentContext()!;UIColor.lightGray.setStroke();c.addRect(CGRect(x:0,y:0,width:60,height:60));c.move(to: CGPoint(x:20,y:0));c.addLine(to: CGPoint(x:20,y:60));c.move(to: CGPoint(x:40,y:0));c.addLine(to: CGPoint(x:40,y:60));c.move(to: CGPoint(x:0,y:20));c.addLine(to: CGPoint(x:60,y:20));c.move(to: CGPoint(x:0,y:40));c.addLine(to: CGPoint(x:60, y:40));c.strokePath();UIColor.black.setFill();c.addEllipse(in:CGRect(x:22,y:2,width:16,height:16));c.addEllipse(in:CGRect(x:42,y:22,width:16,height:16));c.addEllipse(in:CGRect(x:2,y:42,width:16,height:16));c.addEllipse(in:CGRect(x:22,y:42,width:16,height:16));c.addEllipse(in:CGRect(x:42,y:42,width:16,height:16));c.fillPath();let i=UIGraphicsGetImageFromCurrentImageContext();sub.addSubview(UIImageView(image:i))
관심있는 사람을위한 더 읽기 쉬운 버전 :
UIGraphicsBeginImageContext(CGSize(width: 60, height: 60))
let c = UIGraphicsGetCurrentContext()!
UIColor.lightGray.setStroke()
c.addRect(CGRect(x: 0, y: 0, width: 60, height: 60))
c.move(to: CGPoint(x: 20, y: 0))
c.addLine(to: CGPoint(x: 20, y: 60))
c.move(to: CGPoint(x: 40, y: 0))
c.addLine(to: CGPoint(x: 40, y: 60))
c.move(to: CGPoint(x: 0, y: 20))
c.addLine(to: CGPoint(x: 60, y: 20))
c.move(to: CGPoint(x: 0, y: 40))
c.addLine(to: CGPoint(x: 60, y: 40))
c.strokePath()
UIColor.black.setFill()
c.addEllipse(in: CGRect(x: 22, y: 2, width: 16, height: 16))
c.addEllipse(in: CGRect(x: 42, y: 22, width: 16, height: 16))
c.addEllipse(in: CGRect(x: 2, y: 42, width: 16, height: 16))
c.addEllipse(in: CGRect(x: 22, y: 42, width: 16, height: 16))
c.addEllipse(in: CGRect(x: 42, y: 42, width: 16, height: 16))
c.fillPath()
let i = UIGraphicsGetImageFromCurrentImageContext()
sub.addSubview(UIImageView(image: i))
iOS 시뮬레이터에서 생성 된 출력은 다음과 같습니다.