| |
---|
| | import android.util.Log; |
---|
| | import android.view.MotionEvent; |
---|
| | import android.view.View; |
---|
| | |
---|
| | import org.ntlab.acanthus_client.entities.Pen; |
---|
| | import org.ntlab.acanthus_client.entities.Position; |
---|
| | import org.ntlab.acanthus_client.entities.Stroke; |
---|
| | |
---|
| | import java.io.ByteArrayOutputStream; |
---|
| |
---|
| | private int curw; |
---|
| | private int curh; |
---|
| | private int curoldw; |
---|
| | private int curoldh; |
---|
| | private Pen pen; |
---|
| | |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | //----------------------------------------------------------------- |
---|
| | public PaintCanvas(Context context, @Nullable AttributeSet attrs) { |
---|
| | super(context, attrs); |
---|
| | |
---|
| | pen = new Pen(255,0,0,0,20); |
---|
| | //pen =new Pen(Color.BLACK,20);//新しくPenクラスを作り色と幅の値を設定 |
---|
| | path = new Path(); // 図形描画 |
---|
| | clonepath = new Path(); // 図形描画 |
---|
| | latestpath = new Path(); // 図形描画 |
---|
| | paint = new Paint();//筆の種類 |
---|
| | clonepaint = new Paint();//筆の種類 |
---|
| | latestpaint = new Paint();//筆の種類 |
---|
| | paint.setColor(Color.BLACK);//色の指定 |
---|
| | paint.setColor(Color.argb(pen.getAlpha(),pen.getRed(),pen.getGreen(),pen.getBlue()));//色の指定 |
---|
| | paint.setStyle(Paint.Style.STROKE);//線をひく |
---|
| | paint.setStrokeWidth(20);//幅 |
---|
| | paint.setStrokeWidth(pen.getThickness());//幅 |
---|
| | clonepaint.setColor(Color.RED);//色の指定 |
---|
| | clonepaint.setStyle(Paint.Style.STROKE);//線をひく |
---|
| | clonepaint.setStrokeWidth(20);//幅 |
---|
| | latestpaint.setColor(Color.GREEN);//色の指定 |
---|
| |
---|
| | public Canvas getCurCanvas() { |
---|
| | return curCanvas; |
---|
| | } |
---|
| | |
---|
| | public Pen getPen(){return pen;} |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | // setter |
---|
| | public void setPaintViewModel(PaintViewModel paintViewModel) { |
---|
| | this.paintViewModel = paintViewModel; |
---|
| |
---|
| | protected void onDraw(Canvas canvas) { |
---|
| | super.onDraw(curCanvas); |
---|
| | //canvas.setBitmap(image); |
---|
| | //curCanvas = canvas; |
---|
| | // paint.setColor(pen.getColor()); |
---|
| | // paint.setStrokeWidth(pen.getThickness()); |
---|
| | paint.setColor(Color.argb(pen.getAlpha(),pen.getRed(),pen.getGreen(),pen.getBlue())); |
---|
| | paint.setStrokeWidth(pen.getThickness()); |
---|
| | canvas.drawPath(path, paint); |
---|
| | canvas.drawPath(clonepath, clonepaint); |
---|
| | canvas.drawPath(latestpath,latestpaint); |
---|
| | curCanvas.drawPath(path, paint); |
---|
| |
---|
| | |