数独の色を変えてみる(2)

ヒントの描画をコメントアウト

    /*
    if (Settings.getHints(getContext())) {
       // ヒントを描画する...

       // 残された手の数に基づいてヒントの色を塗る
       Paint hint = new Paint();
       int c[] = { getResources().getColor(R.color.puzzle_hint_0),
             getResources().getColor(R.color.puzzle_hint_1),
             getResources().getColor(R.color.puzzle_hint_2), };
       Rect r = new Rect();
       for (int i = 0; i < 9; i++) {
          for (int j = 0; j < 9; j++) {
             int movesleft = 9 - game.getUsedTiles(i, j).length;
             if (movesleft < c.length) {
                getRect(i, j, r);
                hint.setColor(c[movesleft]);
                canvas.drawRect(r, hint);
             }
          }
       }

    }
    */


マス目の描画を無理やり変更。

    // マス目を区切る線
    for (int i = 1; i < 9; i++) {
       canvas.drawLine(0, i * height, getWidth(), i * height, light);
       canvas.drawLine(i * width, 0, i * width, getHeight(), light);
    }

    // 3 x 3 のブロックを区切る線
    for (int i = 1; i < 9; i++) {
       if (i % 3 != 0)
          continue;
       canvas.drawLine(0, i * height, getWidth(), i * height, hilite);
       canvas.drawLine(i * width, 0, i * width, getHeight(), hilite);
    }


フォントのサイズと位置を変更。このやり方は、たぶん間違っている。。。

    // 数値を描画する...
    // 数値の色とスタイルを定義する
    Paint foreground = new Paint(Paint.ANTI_ALIAS_FLAG);
    foreground.setColor(getResources().getColor(
        R.color.puzzle_foreground));
    foreground.setStyle(Style.FILL);
    //foreground.setTextSize(height * 0.75f);
    foreground.setTextSize(height);
    foreground.setTextScaleX(width / height);
    foreground.setTextAlign(Paint.Align.CENTER);
    // フォントを設定する
    foreground.setTypeface(Typeface.createFromAsset(game.getAssets(), "font/7barPBd.TTF"));

    // マス目の中央に数字を描く
    FontMetrics fm = foreground.getFontMetrics();
    // X軸方向でセンタリングする。アラインメントを使う
    float x = width / 2;
    // Y軸方向でセンタリングする。
    // まずアセント/ディセント(上半分と下半分)を調べる。
    //float y = height / 2 - (fm.ascent + fm.descent) / 2;
    float y = (float) (height / 2 - (fm.ascent + fm.descent) / 1.5);
    for (int i = 0; i < 9; i++) {
       for (int j = 0; j < 9; j++) {
          canvas.drawText(this.game.getTileString(i, j), i
              * width + x, j * height + y, foreground);
       }
    }


で、実行。

なかなかいい感じ。


思いつきでフォントの色を赤っぽくしてみる。

こっちのほうが落ち着いていて、いいかも。