-
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.android.browser;
// first experimental behavior
private void doit1(float dx, float dy) {
- int index;
+ final float scale = 0.75f; // temper how far we actually move
+ dx *= scale;
+ dy *= scale;
+ int index;
if (dx < 0) {
index = 10;
} else {
}
private void doit2(float dx, float dy) {
- int index;
+ final float scale = 0.35f; // temper how far we actually move
+ dx *= scale;
+ dy *= scale;
+ final float cornerScale = 0.25f;
+ int index;
if (dx < 0) {
index = 4;
} else {
}
mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx;
mCubics[index*2 + 2] = mOrig[index*2 + 2] + dx;
+ // corners
+ index -= 1;
+ mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx * cornerScale;
+ index = (index + 3) % 12; // next corner
+ mCubics[index*2 + 0] = mOrig[index*2 + 0] + dx * cornerScale;
if (dy < 0) {
index = 7;
}
mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy;
mCubics[index*2 + 3] = mOrig[index*2 + 3] + dy;
+ // corners
+ index -= 1;
+ mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy * cornerScale;
+ index = (index + 3) % 12; // next corner
+ mCubics[index*2 + 1] = mOrig[index*2 + 1] + dy * cornerScale;
}
public void setStretch(float dx, float dy) {
private Mesh mMesh;
private Bitmap mBitmap;
private int mWhich;
+ private Paint mBGPaint;
public MeshTracker(int which) {
mWhich = which;
}
+ public void setBGPaint(Paint paint) {
+ mBGPaint = paint;
+ }
+
@Override public void onStartDrag(float x, float y) {
mMesh = new Mesh(mWhich, 16, 16);
}
}
@Override public void onDraw(Canvas canvas) {
- canvas.drawColor(0xFF000000);
- Paint paint = new Paint();
- paint.setAlpha(0x80);
- canvas.drawBitmap(mBitmap, 0, 0, paint);
+ if (mWhich == 2) {
+ if (mBGPaint != null) {
+ canvas.drawPaint(mBGPaint);
+ } else {
+ canvas.drawColor(0xFF000000);
+ }
+ }
mMesh.draw(canvas);
}
}
package com.android.browser;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapShader;
+import android.graphics.Paint;
+import android.graphics.Shader;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
s.addObserver(w.getSettings()).update(s, null);
// pick a default
- w.setDragTracker(new MeshTracker(1));
+ if (true) {
+ MeshTracker mt = new MeshTracker(2);
+ Paint paint = new Paint();
+ Bitmap bm = BitmapFactory.decodeResource(mActivity.getResources(),
+ R.drawable.pattern_carbon_fiber_dark);
+ paint.setShader(new BitmapShader(bm, Shader.TileMode.REPEAT,
+ Shader.TileMode.REPEAT));
+ mt.setBGPaint(paint);
+ w.setDragTracker(mt);
+ }
return w;
}