畫出殘影格子
void setup(){
size(800,300);
}
void draw(){
rect(mouseX,mouseY,50,20);
}
打卡機基本功能
void setup(){
size(800,300);
for(int x=0;x<800;x+=16){
for(int y=0;y<300;y+=30){
rect(x,y,16,30);
}
}
}
void draw(){
int nowX=mouseX/16*16,nowY=mouseY/30*30;
fill(0);
rect(nowX,nowY,16,30);
}
打卡機完整功能
void setup(){
size(800,300);
for(int x=0;x<800;x+=16){
for(int y=0;y<300;y+=30){
rect(x,y,16,30);
}
}
}
void draw(){
int nowX=mouseX/16*16,nowY=mouseY/30*30;
if(mousePressed && mouseButton==LEFT){
fill(0);
rect(nowX,nowY,16,30);
}else if(mousePressed && mouseButton==RIGHT){
fill(255);
rect(nowX,nowY,16,30);
}
}
匯入圖片
size(500,500);
PImage img=loadImage("http://pic.90sjimg.com/design/00/78/05/88/592e5cf898cda.png");
image(img,0,0,500,500);
用滑鼠畫圖片
PImage img;
void setup(){
size(500,500);
img=loadImage("http://pic.90sjimg.com/design/00/78/05/88/592e5cf898cda.png");
}
void draw(){
image(img,mouseX,mouseY,200,200);
}
打卡機最終版本
PImage imgBG;
int [][]table=new int[55][50];
void setup(){
size(1023,656);
imgBG=loadImage("https://static7.depositphotos.com/1242588/746/i/950/depositphotos_7461636-stock-photo-old-vintage-postcard-background.jpg");
}
void draw(){
background(imgBG);
int nowI=mouseX/16,nowJ=mouseY/30;
if(mousePressed && mouseButton==LEFT){
table[nowI][nowJ]=1;
}
else if(mousePressed && mouseButton==RIGHT){
table[nowI][nowJ]=0;
}
for(int i=0;i<55;i++){
for(int j=0;j<50;j++){
fill(0);
if(table[i][j]==1)rect(i*16,j*30,16,30);
}
}
}
沒有留言:
張貼留言