size(400,2800);
background(0);
textSize(20);
text(" Multiplication table ",100,50);
textSize(15);
// set base value
// number is value for multiplication
// stepDown is for plus Y in text multiplication
// step stepDonwline is value for plus Y in all next number multiplication
// X and Y is reference point of multiplication each number
int Number =1;
int stepDown =15;
int stepDownLine=30;
int X=120;
int Y=100;
int colour=0;
while(Number<=12){
int count = 1;//count for multiplication
fill(0,70+colour,255-colour);
while(count<=12){ // while for draw multiplication table
drawMultiplicationTable(X,Y,count,Number);
Y=Y+stepDown;
count++;
}
Y=Y+stepDownLine;
Number++;
colour+=15;
}
}
void drawMultiplicationTable(int X,int Y ,int count,int number){
int sum=0; // sum is sum of number * count
sum = count * number;
text(+number,X,Y);
text(" x " ,X+20,Y);
text(+count,X+60,Y);
text(" = ",X+100,Y);
text(+sum,X+140,Y);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น