Android面具手指画与其他不规则形状的图像
我尝试在不规则的形状上绘画,例如,它向用户显示完全透明的视图,但他只能在视图的某些区域(如动物形状)上绘画。这一切都完成了,因为动物器官形状将位于绘画视图的后面 前一层将是透明的视图,我将用于绘画Android面具手指画与其他不规则形状的图像,android,titanium,Android,Titanium,我尝试在不规则的形状上绘画,例如,它向用户显示完全透明的视图,但他只能在视图的某些区域(如动物形状)上绘画。这一切都完成了,因为动物器官形状将位于绘画视图的后面 前一层将是透明的视图,我将用于绘画 @Override protected void onDraw(Canvas canvas) { boolean containsBG = props.containsKeyAndNotNull( Ti
@Override
protected void onDraw(Canvas canvas) {
boolean containsBG = props.containsKeyAndNotNull(
TiC.PROPERTY_BACKGROUND_COLOR);
canvas.drawColor(containsBG ?
TiConvert.toColor(props, TiC.PROPERTY_BACKGROUND_COLOR) :
TiConvert.toColor("transparent"));
canvas.drawBitmap(tiBitmap, 0, 0, tiBitmapPaint);
for (int i = 0; i < maxTouchPoints; i++) {
if (tiPaths[i] != null) {
canvas.drawPath(tiPaths[i], tiPaint);
}
}
}
private void touch_start(int id, float x, float y) {
tiPaths[id] = new Path();
tiPaths[id].moveTo(x, y);
tiX[id] = x;
tiY[id] = y;
}
private void touch_move(int id, float x, float y) {
if (tiPaths[id] == null) {
tiPaths[id] = new Path();
tiPaths[id].moveTo(tiX[id], tiY[id]);
}
tiPaths[id].quadTo(tiX[id], tiY[id], (x + tiX[id]) / 2, (y + tiY[id]) / 2);
tiX[id] = x;
tiY[id] = y;
}
@Override
public boolean onTouchEvent(MotionEvent mainEvent) {
for (int i = 0; i < mainEvent.getPointerCount(); i++) {
int id = mainEvent.getPointerId(i);
float x = mainEvent.getX(i);
float y = mainEvent.getY(i);
int action = mainEvent.getAction();
if (action > 6) {
action = (action % 256) - 5;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
finalizePath(id);
touch_start(id, x, y);
invalidate();
break;
case MotionEvent.ACTION_MOVE:
touch_move(id, x, y);
invalidate();
break;
case MotionEvent.ACTION_UP:
finalizePath(id);
invalidate();
break;
}
}
return true;
}
public void finalizePath(int id) {
if (tiPaths[id] != null) {
tiCanvas.drawPath(tiPaths[id], tiPaint);
tiPaths[id].reset();
tiPaths[id] = null;
}
}
public void finalizePaths() {
for (int i = 0; i < maxTouchPoints; i++) {
if (tiPaths[i] != null) {
tiCanvas.drawPath(tiPaths[i], tiPaint);
tiPaths[i].reset();
tiPaths[i] = null;
}
}
}
@覆盖
受保护的void onDraw(画布){
布尔containsBG=props.containsKeyAndNotNull(
TiC.属性(背景颜色);
画布。drawColor(containsBG?
TiConvert.toColor(道具、TiC.PROPERTY\u背景颜色):
TiConvert.toColor(“透明”);
drawBitmap(tiBitmap,0,0,tiBitmapPaint);
对于(int i=0;i6){
操作=(操作%256)-5;
}
开关(动作){
case MotionEvent.ACTION\u DOWN:
最后确定路径(id);
触摸启动(id、x、y);
使无效();
打破
case MotionEvent.ACTION\u移动:
触摸移动(id、x、y);
使无效();
打破
case MotionEvent.ACTION\u UP:
最后确定路径(id);
使无效();
打破
}
}
返回true;
}
公共void finalizePath(内部id){
if(tipath[id]!=null){
tiCanvas.drawPath(tiPaths[id],tiPaint);
路径[id]。重置();
tiPaths[id]=null;
}
}
公共图书馆{
对于(int i=0;i
任何人都可以帮助实现这一点。请提前感谢如果您有面具,并且在使用应用程序时它不会改变,也许您可以尝试以下方法:
透明,但由于您的图片已使用白色边框, 你可以不这样做
你能更详细地阐述你的问题吗?嗨,格尔舒,我添加了图像以便于清晰理解。我想进一步利用绘制的透明层进行一些图像处理。因此,我使用了两层。如何做到这一点,请给我建议,我有相同的问题,仅手指绘制图像,而非外部区域请。。。。