using UnityEngine;
using ProtoTurtle.BitmapDrawing;
public class BitmapDrawHandler : MonoBehaviour {
Material material;
Texture2D texture;
int num = 5;
Color color;
Color color2;
Vector2 tempPos;
int tempY;
int tempX;
ModelHandler model;
void Start () {
model = GameObject.Find("Model").GetComponent<ModelHandler>();
init();
}
void init(){
material = GetComponent<Renderer>().material;
texture = new Texture2D(model.Width,model.Height, TextureFormat.RGB24, false);
texture.wrapMode = TextureWrapMode.Repeat;
material.SetTexture(0, texture);
}
public void Draw(Vector2 startPos, Vector2 endPos){
texture.DrawLine(startPos, endPos, Color.black);
texture.Apply();
}
void FixedUpdate () {
color = new Vector4(Random.RandomRange(0.2f,0.3f),Random.RandomRange(0,1f),Random.RandomRange(0,1),1);
color2 = new Vector4(Random.RandomRange(1,1),Random.RandomRange(1,1),Random.RandomRange(1,1f),1f);
int x = Random.RandomRange(0,model.Width);
int y = Random.RandomRange(0,model.Height);
texture.DrawFilledCircle(x,y,Random.RandomRange(10,20), color);
texture.DrawFilledCircle(x,y,Random.RandomRange(5,10), color2);
texture.Apply();
// tempX = Random.RandomRange(0,width);
// tempY = Random.RandomRange(0,width);
// texture.DrawFilledCircle(tempX,tempY,Random.RandomRange(10,300), color2);
// texture.DrawFilledCircle(tempX,tempY,Random.RandomRange(10,400), color2);
}
}