1.外圓內圓
size(600,600);
rect(200,200,200,300,50);///弧度
fill(#654321);
rect(225,225,150,250,50);
2.multiple
void setup()
{
size(600,600);
}
int w=25;
void draw()
{
drawcard(120,120);
drawcard(150,150);
drawcard(180,180);
}
void drawcard(int x,int y)
{
fill(255);
rect(x-w/2,y-w/2,150+w,250+w,50);///弧度
fill(#654321);
rect(x,y,150,250,50);
}
3.S H C D
void setup()
{
size(600,600);
}
int w=25;
void draw()
{
drawcard(100,100,"S1");
drawcard(150,150,"H2");
drawcard(200,200,"C3");
drawcard(250,250,"D4");
}
void drawcard(int x,int y,String face)
{
fill(255);
rect(x-w/2,y-w/2,150+w,250+w,50);///弧度
fill(#654321);
rect(x,y,150,250,50);
fill(10);
textSize(30);
text(face,x+10,y+40);
}
4.黑桃 梅花 方塊 紅心
void setup()
{
size(600,600);
PFont font = createFont("標楷體",30);
textFont(font);
}
int w=25;
void draw()
{
drawcard(100,100,"黑桃1");
drawcard(160,160,"紅心2");
drawcard(220,220,"梅花3");
drawcard(280,280,"方塊4");
}
void drawcard(int x,int y,String face)
{
fill(255);
rect(x-w/2,y-w/2,150+w,250+w,50);///弧度
fill(#654321);
rect(x,y,150,250,50);
fill(10);
textSize(30);
text(face,x+10,y+40);
}
void setup()
{
size(600,600);
PFont font = createFont("標楷體",30);
textFont(font);
}
int w=25;
void draw()
{
drawcard(100,100,"黑桃1");
drawcard(160,160,"紅心2");
drawcard(220,220,"梅花3");
drawcard(280,280,"方塊4");
}
void drawcard(int x,int y,String face)
{
fill(255);
rect(x-w/2,y-w/2,150+w,250+w,50);///弧度
fill(#654321);
rect(x,y,150,250,50);
if(face.indexOf("黑桃")== -1 && face.indexOf("梅花")== -1) fill(#ff0000);
else fill(0);
textSize(30);
text(face,x+10,y+40);
}
void setup()
{
size(600,600);
PFont font = createFont("標楷體",30);
textFont(font);
String[] flower = {"黑桃","紅心","梅花","方塊"};
face1=flower[int(random(4))]+int(random(13)+1);
face2=flower[int(random(4))]+int(random(13)+1);
face3=flower[int(random(4))]+int(random(13)+1);
face4=flower[int(random(4))]+int(random(13)+1);
} ///(0-12)+1
int w=25;
String face1,face2,face3,face4;
void draw()
{
drawcard(100,100,face1);
drawcard(160,160,face2);
drawcard(220,220,face3);
drawcard(280,280,face4);
}
void drawcard(int x,int y,String face)
{
fill(255);
rect(x-w/2,y-w/2,150+w,250+w,50);///弧度
fill(#654321);
rect(x,y,150,250,50);
if(face.indexOf("黑桃")== -1 && face.indexOf("梅花")== -1) fill(#ff0000);
else fill(0);
textSize(30);
text(face,x+10,y+40);
}
7.mousepressed
void setup()
{
size(600,600);
PFont font = createFont("標楷體",30);
textFont(font);
String[] flower = {"黑桃","紅心","梅花","方塊"};
face1=flower[int(random(4))]+int(random(13)+1);
face2=flower[int(random(4))]+int(random(13)+1);
face3=flower[int(random(4))]+int(random(13)+1);
face4=flower[int(random(4))]+int(random(13)+1);
}
void mousePressed()
{
String[] flower = {"黑桃","紅心","梅花","方塊"};
face1=flower[int(random(4))]+int(random(13)+1);
face2=flower[int(random(4))]+int(random(13)+1);
face3=flower[int(random(4))]+int(random(13)+1);
face4=flower[int(random(4))]+int(random(13)+1);
}
int w=25;
String face1,face2,face3,face4;
void draw()
{
drawcard(100,100,face1);
drawcard(160,160,face2);
drawcard(220,220,face3);
drawcard(280,280,face4);
}
void drawcard(int x,int y,String face)
{
fill(255);
rect(x-w/2,y-w/2,150+w,250+w,50);///弧度
fill(#654321);
rect(x,y,150,250,50);
if(face.indexOf("黑桃")== -1 && face.indexOf("梅花")== -1) fill(#ff0000);
else fill(0);
textSize(30);
text(face,x+10,y+40);
}







沒有留言:
張貼留言