顯示具有 Week11 標籤的文章。 顯示所有文章
顯示具有 Week11 標籤的文章。 顯示所有文章

2020年6月29日 星期一

你當我的錢是大風颳來的嗎_week11


textSize 代表字體大小
textAlign 是對齊 
打eg. textAlign(LEFT, TOP) 會對齊左上角
泡泡排序
int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup(){
  size(500,800);
  for(int i=0;i<10;i++){//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT,TOP);
  showArray(y);
}
int y=0;
void showArray(int y){
  for(int i=0;i<10;i++){
    fill(255);  rect(i*50, y, 50,50);
    fill(0);         text(a[i], i*50, y);
  } 
}
void draw(){

}
void mousePressed(){
  for(int i=0; i<10-1;i++){
    if(a[i] > a[i+1]){
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}

2020年6月18日 星期四

08160581_week11

泡泡排序法
int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup() {
  size(500, 800);
  for (int i=0; i<10; i++) {//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT, TOP);
  showArray(y);
}
int y=0;
void showArray(int y) {
  for (int i=0; i<10; i++) {
    fill(255); 
    rect(i*50, y, 50, 50);
    fill(0);       
    text(a[i], i*50, y);
  }//秀文字
}
void draw() {
}
void mousePressed() {
  for (int i=0; i<10-1; i++) {//i從左到右 0 1 2 3 ... 8
    if (a[i] > a[i+1]) {
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255, 0, 0, 128);
      rect(i*50, y, 100, 50);
    }//R紅G綠B藍A半透明Alpha
  }
  y+=50;
  showArray(y);
}

2020年6月4日 星期四

2020年5月21日 星期四

week11


程式碼:
PImage imgBird;
void setup()
{
   size(500,400);
   imgBird=loadImage("bird.png");
   imageMode(CENTER);
}
float birdX=100,birdY=300,oldX,oldY;
void draw()
{
   background(255);
   image(imgBird,mouseX,mouseY,100,100);
   if(mousePressed) line(birdX,birdY,oldX,oldY);
}
void mousePressed(){
    oldX=birdX; oldY=birdY;
}
void mouseDragged(){
    birdX=mouseX;
    birdY=mouseY;
}

2020年5月7日 星期四

week11 球球複習

泡泡排序法(P語言)
字的大小、對齊
球球複習(隨機填色)

emmmm..........._week11

(o´・ω・`)σ)Д`)
Processing 的泡泡排序法
對齊.......的方法
沒打完的程式,下次再繼續

week11 程式設計

泡泡排序
int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup(){
  size(500,800);
  for(int i=0;i<10;i++){//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT,TOP);
  showArray(y);
}
int y=0;
void showArray(int y){
  for(int i=0;i<10;i++){
    fill(255);  rect(i*50, y, 50,50);
    fill(0);         text(a[i], i*50, y);
  } 
}
void draw(){
 
}
void mousePressed(){
  for(int i=0; i<10-1;i++){
    if(a[i] > a[i+1]){
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}



size(200,200);
rect(50,50,50,50);
textSize(40); textAlign(LEFT,TOP);
fill(#ff0000); text("A", 50,50);



大小寫轉換

#include <stdio.h>
int main(){
char a[100];
scanf("%s", a);
for(int i=0;a[i]!=0;i++){
///char c=a[i];
if(a[i]>='A' && a[i]<='Z'){
a[i]=a[i]-'A'+'a';///減掉大寫加小寫
}
else if(a[i]>='a' && a[i]<='z'){
a[i]=a[i]-'a'+'A';
}
}
printf("%s\n", a);
}
A的B次方函數 

#include <stdio.h>
int MYPOWER(int a,int b){///呼叫
int ans=1;
for(int i=0;i<b;i++){
ans*=a;///a乘b次
}
return ans;
}
int main(void)
{
int a,b;
scanf("%d%d",&a,&b);
printf("[%d]",MYPOWER(a,b));
return 0;
}



void setup(){
    size(300,500);
    colorMode(HSB);
}
int ansX=2, ansY=3;
int N=5;///5X5
int H=255,S=255,B=255;///色調,色相,飽和
void draw(){
    background(0);
    int R=300/N, w=R/2;
    for(int x=0;x<N;x++){
        for(int y=0;y<N;y++){
            if(x==ansX && y==ansY) fill(H+10, S-35, B-45);///更改圓顏色
            else fill(H, S, B);
            ellipse(0+w+x*R, 200+w+y*R, R,R);
        }
    }
}
void mousePressed(){
    ansX = int(random(N)); ansY = int(random(N));///隨機換圓
    H+=16;
    if(H>255)H=0;
}

Programming-week11

BUBBLE

泡泡位置
照片:

程式碼:

int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup() {
  size(500, 800);
  for (int i=0; i<10; i++) {//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT, TOP);
  showArray(y);
}
int y=0;
void showArray(int y) {
  for (int i=0; i<10; i++) {
    fill(255); 
    rect(i*50, y, 50, 50);
    fill(0);       
    text(a[i], i*50, y);
  }//秀文字
}
void draw() {
}
void mousePressed() {
  for (int i=0; i<10-1; i++) {//i從左到右 0 1 2 3 ... 8
    if (a[i] > a[i+1]) {
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255, 0, 0, 128);
      rect(i*50, y, 100, 50);
    }//R紅G綠B藍A半透明Alpha
  }
  y+=50;
  showArray(y);
}
-----------------------------------------------------------------------
Bubble位置及顏色變化
照片:


程式碼:

void setup() {//Lyto Different Color

  size(300, 500);//下面300x300
  colorMode(HSB);
  
}//300x300 分成 2x2, 每個圓 300/2
int ansX=2, ansY=3;
int N=5;//單邊有幾個大圓?
int H=255, S=255, B=255;//Hus色相/色調, Sat飽, Bright高度
void draw() {
  background(0);///300x300 分成 2x2, 每個圓 300/2
  int R=300/N, w=R/2;
  for (int x=0; x<N; x++) {
    for (int y=0; y<N; y++) {
      if(x==ansX && y==ansY) fill(H+10, S-35, B-45);
      else fill(H, S, B);
      ellipse(0+w+x*R, 200+w+y*R, R, R);
    }
  }
}
void mousePressed(){
  ansX = int(random(N)); ansY = int(random(N));
  H+=16;
  if(H>255)H=0;
}

重修學長的程式設計

今天先教了泡泡排序法

int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup(){
  size(500,800);
  for(int i=0;i<10;i++){//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT,TOP);
  showArray(y);
}
int y=0;
void showArray(int y){
  for(int i=0;i<10;i++){
    fill(255);  rect(i*50, y, 50,50);
    fill(0);         text(a[i], i*50, y);
  } 
}
void draw(){
 
}
void mousePressed(){
  for(int i=0; i<10-1;i++){
    if(a[i] > a[i+1]){
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}
重新教了一次大小寫轉換

教了一次 A的B次方函數

CPE高中物理

一個顏色的遊戲

week11






今天上課一開始,老師示範processing的泡泡排序髮給我們看,並把程式碼傳給我們讓我們自行練習觀察。

int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup(){
  size(500,800);
  for(int i=0;i<10;i++){//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT,TOP);
  showArray(y);
}
int y=0;
void showArray(int y){
  for(int i=0;i<10;i++){
    fill(255);  rect(i*50, y, 50,50);
    fill(0);         text(a[i], i*50, y);
  }
}
void draw(){

}
void mousePressed(){
  for(int i=0; i<10-1;i++){
    if(a[i] > a[i+1]){
      int temp=a[i];//泡泡排序法
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}


接著,老師教了如何用processing來秀文字,只需要運用簡單的"textAlign"和"texySize"就可以輕鬆地寫出想表達的文字,也可以調整位置和大小。




size(200,200);
rect(50,50,50,50);
textSize(40); textAlign(LEFT,TOP);
fill(#ff0000); text("A", 50,50);


接著老師又接下去講了第二種泡泡排序法,在這邊講的是數字漸層  fill(255,0,0,128)



int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup(){
  size(500,800);
  for(int i=0;i<10;i++){//random choose number
    a[i]=int(random(10));//亂數決定數字
  }/// Java是用 int(3.14)會轉成3, C/C++ int b=3.14變3
  textSize(32);
  textAlign(LEFT,TOP);//文字改用左上角
  showArray(y);
}
int y=0;
void showArray(int y){      //左上角
  for(int i=0;i<10;i++){//rect(x,y, w,h)四邊形
    fill(255);     rect(i*50, y, 50,50);
    fill(0); text(a[i], i*50, y);
  }      ///秀文字(字,  x,    y) 放哪裡 (左下角)
}
void draw(){

}
void mousePressed(){
  for(int i=0; i<10-1;i++){// i從左到右 0 1 2 3 4 5 6 7 8
    if(a[i] > a[i+1]){
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}

下一堂課來了~
這堂課老師接著教下去上星期教到一半的課程,n*n的圓圈排序



void setup()
{
  size(300,500);
}
int N=5;
void draw()
{
  background(0);
  int R=300/N , w=R/2;
  for(int x=0;x<N;x++)
  {
    for(int y=0;y<N;y++)
    {
      ellipse(0+w+x*R ,200+w+y*R , R , R );
    }
  }
}

畫好了圓圈的基本架構後,接下來要開始幫圓圈上色啦~!





void setup()
{
  size(300,500);
  colorMode(HSB);
}
int ansX=2,ansY=3;
int N=5;
int H=255,S=255,B=255;
void draw()
{
  background(0);
  int R=300/N , w=R/2;
  for(int x=0;x<N;x++)
  {
    for(int y=0;y<N;y++)
    {
      if(x==ansX && y==ansY) fill(H+10,S-35,B-45);
      else fill(H,S,B);//上色
      ellipse(0+w+x*R ,200+w+y*R , R , R );
    }
  }

}
void mousePressed()
{
  ansX = int (random(N));ansY=int(random(N));
  H+=16;
  if(H>255)H=0;

}

利用這些程式碼,便可以點完個彩色圈圈就換成另一個彩色圈圈,且每次位置皆不同。

泡泡排序法的程式碼很難,所以老師今天用processing再教我們一次,教完後就接續著上星期ig的小遊戲。今天的進度是讓他上色並且有一個的顏色不一樣!!

可憐的大三重修仔_week11

2020/5/7 week11
part1:
(1)泡泡排序法

老師先用youtube上的影片介紹泡泡排序法,泡泡排序法是利用
陣列中兩兩數字大小做比較,比較大的就往後放,依此類推~

(2)P語言的基本打法


Part2:
(1)練習實習課進階題(大寫轉小寫,小寫轉大寫)


(2)函數次方


(3)講解讀入整數反序列印&Back to High School Physics(CPE)

(4)玩電玩,學程式

N=多少就會呈現出多少N*N顆球

會變顏色的球球
void setup(){
  size(300,500);
  colorMode(HSB);
}
int ansX=2, ansY=3;
int N=5;
int H=255,S=255,B=255;
void draw(){
  background(0);
  int R=300/N, w=R/2;
  for(int x=0;x<N;x++){
    for(int y=0;y<N;y++){
      if(x==ansX && y==ansY)  fill(H+10,S-35,B-45);
      else fill(H,S,B);
      ellipse(0+w+x*R,200+w+y*R,R,R);
    }
  }
}
void mousePressed(){
   ansX=int(random(N));
   ansY=int(random(N));
   H+=16;
   if(H>255)  H=0;
}

邪惡微笑教主征服地球計畫W11:)來點不一樣的2!


首先來個泡泡排序開場!
泡泡排序法:
int []a=new int[10];//Java's Array
//int []a={6,3,5,9,1,0,4,2,7,8};
//int []a={1,2,3,5,0,4,6,7,8,9};
//int []a={9,8,7,6,5,4,3,2,1,0};
void setup(){
  size(500,800);
  for(int i=0;i<10;i++){//random choose number
    a[i]=int(random(10));//亂數決定數字
  }
  textSize(36);
  textAlign(LEFT,TOP);
  showArray(y);
}
int y=0;
void showArray(int y){
  for(int i=0;i<10;i++){
    fill(255);  rect(i*50, y, 50,50);
    fill(0);         text(a[i], i*50, y);
  }  
}
void draw(){
  
}
void mousePressed(){
  for(int i=0; i<10-1;i++){
    if(a[i] > a[i+1]){
      int temp=a[i];
      a[i]=a[i+1];
      a[i+1]=temp;
      fill(255,0,0,128); rect(i*50, y, 100,50);
    }
  }
  y+=50;
  showArray(y);
}





繼續坐上禮拜的東西吧!
void setup(){
  size(300,500);
}
int N=5;
void draw(){
    background(0);
    int R=300/N,w=R/2;
    for(int x=0;x<N;x++){
      for(int y=0;y<N;y++){
          ellipse(0+w+x*R,200+w+y*R,R,R);
      }
    }

}



























void setup(){
  size(300,500);
  colorMode(HSB);
}
int N=5,ansX=2,ansY=3,H=255,S=255,B=255;
void draw(){
    background(0);
    int R=300/N,w=R/2;
    for(int x=0;x<N;x++){
      for(int y=0;y<N;y++){
        if(x==ansX && y==ansY)fill(H+10,S-35,B-45);
          else fill(H,S,B);
          ellipse(0+w+x*R,200+w+y*R,R,R);
      }
    }
}
void mousePressed(){
  ansX=int(random(N));
  ansY=int(random(N));
  if(H>255)H=0;

}

WEEK-11


P語言,JAVA泡泡排序法

秀英文字

week-11

今天了解了泡泡排序法跟textAlign


還做了讀入A的B次方函數跟Back to High School Physic

還補做了



Week11

Bubble sort:
rect() : 正方形 rect( x座標 , y座標 , 長 , 寬 )
textSize() : 字體大小
textAlign() : 對齊 eg. textAlign(LEFT, TOP) 會對齊左上角
fill( red, green, blue, alpha)

Lyto different color :
練習寫出很多個圓圈
接著練習改變顏色 :