diff --git a/app/src/main/java/com/codigoparallevar/minicards/DrawView.java b/app/src/main/java/com/codigoparallevar/minicards/DrawView.java index 8052aa8..e52ecb0 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/DrawView.java +++ b/app/src/main/java/com/codigoparallevar/minicards/DrawView.java @@ -21,13 +21,15 @@ class DrawView extends View { public DrawView(Context context) { super(context); - paint.setColor(Color.RED); + this.setBackgroundColor(Color.rgb(4, 69, 99)); parts.add(new RoundButton(500, 1200, 80, 100)); } @Override public void onDraw(Canvas canvas){ long time = System.currentTimeMillis(); + drawBackground(canvas); + for (Part part : parts){ part.draw(canvas); } @@ -35,6 +37,26 @@ class DrawView extends View { Log.d("Render time", System.currentTimeMillis() - time + "ms"); } + private void drawBackground(Canvas canvas) { + // Blueprint background + final int width = getWidth() + getLeft(); + final int height = getHeight() + getTop(); + final int cellSize = 50; + + Paint blueprintLines = new Paint(Paint.ANTI_ALIAS_FLAG); + blueprintLines.setColor(Color.argb(100, 255, 255, 255)); + + // Vertical lines + for (int x = cellSize; x < width; x += cellSize){ + canvas.drawLine(x, 0, x, height, blueprintLines); + } + + // Horizontal lines + for (int y = cellSize; y < height; y += cellSize){ + canvas.drawLine(0, y, width, y, blueprintLines); + } + } + @Override public boolean onTouchEvent(MotionEvent event){ int x = (int) event.getX() - this.getLeft(); diff --git a/app/src/main/java/com/codigoparallevar/minicards/TestActivity.java b/app/src/main/java/com/codigoparallevar/minicards/TestActivity.java index 49f55fc..675e2f9 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/TestActivity.java +++ b/app/src/main/java/com/codigoparallevar/minicards/TestActivity.java @@ -14,7 +14,6 @@ public class TestActivity extends AppCompatActivity { super.onCreate(savedInstanceState); drawView = new DrawView(this); - drawView.setBackgroundColor(Color.BLACK); setContentView(drawView); }