예제 #1
0
    public void onDraw(Canvas canvas) {
      // 검정색 배경으로 지운다. 빈 화면이면 지우기만 하고 리턴
      canvas.drawColor(Color.BLACK);
      if (status == BLANK) {
        return;
      }

      // 도형 목록을 순회하면서 도형 정보대로 출력한다.
      int idx;
      for (idx = 0; idx < arShape.size(); idx++) {
        Paint Pnt = new Paint();
        Pnt.setAntiAlias(true);
        Pnt.setColor(arShape.get(idx).color);

        Rect rt = arShape.get(idx).rt;
        switch (arShape.get(idx).what) {
          case Shape.RECT:
            canvas.drawRect(rt, Pnt);
            break;
          case Shape.CIRCLE:
            canvas.drawCircle(
                rt.left + rt.width() / 2, rt.top + rt.height() / 2, rt.width() / 2, Pnt);
            break;
          case Shape.TRIANGLE:
            Path path = new Path();
            path.moveTo(rt.left + rt.width() / 2, rt.top);
            path.lineTo(rt.left, rt.bottom);
            path.lineTo(rt.right, rt.bottom);
            canvas.drawPath(path, Pnt);
            break;
        }
      }
    }
예제 #2
0
    public void onDraw(Canvas canvas) {
      canvas.drawColor(Color.LTGRAY);
      Paint Pnt = new Paint();
      String str = "Custom Font Test";

      Pnt.setAntiAlias(true);
      Pnt.setTypeface(mFont);
      Pnt.setTextSize(30);
      canvas.drawText(str, 10, 40, Pnt);
    }
예제 #3
0
 public void onDraw(Canvas canvas) {
   canvas.drawColor(Color.LTGRAY);
   Paint Pnt = new Paint();
   int y = 1;
   Pnt.setAntiAlias(true);
   Pnt.setTextSize(30);
   Pnt.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
   canvas.drawText("Font:Default", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.DEFAULT_BOLD, Typeface.NORMAL));
   canvas.drawText("Font:Default Bold", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL));
   canvas.drawText("Font:Monospace", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL));
   canvas.drawText("Font:Sans Serif", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.SERIF, Typeface.NORMAL));
   canvas.drawText("Font:Serif", 10, y++ * 40, Pnt);
 }