Add simplistic blueprint background.
This commit is contained in:
parent
078b06ab57
commit
cb2ca6c47c
@ -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();
|
||||
|
@ -14,7 +14,6 @@ public class TestActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
drawView = new DrawView(this);
|
||||
drawView.setBackgroundColor(Color.BLACK);
|
||||
setContentView(drawView);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user