﻿using UnityEngine;
using System.Collections;

public class Photo : MonoBehaviour {

	public string photoName;
	public float scale;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void setPosition (int x, int y) {
		transform.localPosition = new Vector3 (x * 1.5f, y * 1.5f, 0);
	}

	public void SetPhoto (Texture2D photo) {

		photoName = photo.name;
		gameObject.GetComponent<Renderer> ().material.mainTexture = photo;

		Vector3 t = gameObject.transform.localScale;

		//float scale;
		if (photo.width > photo.height) {
			scale = (float)photo.width / (float)photo.height;
			t.x *= scale;

		} else {
			scale = (float)photo.height / (float)photo.width;
			t.y *= scale;
		}

		gameObject.transform.localScale = t;
	}
}
