Japan/Japan/JapanView.swift

//
//  JapanView.swift
//  Japan
//
//  Created by Mark Meretzky on 10/24/18.
//  Copyright © 2018 New York University School of Professional Studies. All rights reserved.
//

import UIKit

class JapanView: UIView {
    
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!;
        
        print("init(coder:) frame  = \(frame)");
        print("init(coder:) bounds = \(bounds)");
        
        //Unnecessary because white is the default.  Must come here, not in draw(_:).
        backgroundColor = UIColor.white;
    }


    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    
    override func draw(_ rect: CGRect) {
        // Drawing code
        print("draw(_:)     frame  = \(frame)");
        print("draw(_:)     bounds = \(bounds)");
        
        /*
         Create the invisible square that will surround the circle.
         Place the upper left corner of the square at the upper left corner of
         the JapanView.  The coordinates of the upper left corner of the
         JapanView are bounds.minX and bounds.minY.
        */
        let radius: CGFloat = 0.3 * bounds.width;    //in points
        
        let r: CGRect = CGRect(
            x: bounds.minX,
            y: bounds.minY,
            width: 2 * radius,
            height: 2 * radius);
        
        let c: CGContext = UIGraphicsGetCurrentContext()!;
        c.beginPath();    //unnecessary here: the path is already empty.
        c.addEllipse(in: r);
        c.setFillColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0);    //red, opaque
        c.fillPath();
    }


}