⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jycshow.java

📁 一个图形旋转的好例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            offGraphics.fillRect(0,y+5,width-x,5);
          }
          break;
        case 6:
          offGraphics.fillOval(x-width/2,x*height/width-height/2,2*(width-x),2*(height-x*height/width));
          break;
        case 7:
          offGraphics.fillRect(x/2,0,width-x,height);
          break;
        case 8:
          offGraphics.fillRect(x/2,x*height/width/2,width-x,height-x*height/width);
          break;
        case 9:
          offGraphics.fillArc(-width,-height,3*width,3*height, 0, 180*(width-x)/width);
          offGraphics.fillArc(-width,-height,3*width,3*height, 180, 180*(width-x)/width);
          break;
        }
        refresh(10);
      }
      delay(1000);
    }
  }

  private void jShow5(int mode) { // Glimmer show
    for (int sw=0; sw<3; sw++) {
      for (int dt=5; dt>=0; dt--) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.setColor(Color.white);
        offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,margin,0,this);
        for (int x=0; x<=width-5; x+=5) {
          switch (mode) {
          case 1:
            for (int y=0; y<=height-5; y+=5) {
              offGraphics.fillRect(x,y,dt,dt);
            }
            break;
          case 2:
            offGraphics.fillRect(x,0,dt,height);
            break;
          case 3:
            offGraphics.fillRect(0,x*height/width,width,dt*height/width);
            break;
          }
        }
        refresh(10);
      }
      delay(1000);
    }
  }

  private void jShow6() { // Twice pull checkboard
    for (int sw=0; sw<3; sw++) {
      for (int y0=0; y0<=height; y0+=10) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,margin,0,this);
        offGraphics.setColor(Color.white);
        for (int x=0; x<=width-5; x+=10) {
          for (int y=0; y<=y0-5; y+=10) {
            offGraphics.fillRect(x,y,5,5);
            offGraphics.fillRect(x+5,y+5,5,5);
          }
        }
        offGraphics.fillRect(0,y0,width,height-y0);
        refresh(50);
      }
      for (int y0=0; y0<=height; y0+=10) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,margin,0,this);
        offGraphics.setColor(Color.white);
        for (int x=0; x<=width-5; x+=10) {
          for (int y=y0; y<height-5; y+=10) {
            offGraphics.fillRect(x,y,5,5);
            offGraphics.fillRect(x+5,y+5,5,5);
          }
        }
        refresh(10);
      }
      delay(1000);
    }
  }

  private void jShow7() { // Twice pull vert bar
    for (int sw=0; sw<3; sw++) {
      for (int x0=0; x0<=width; x0+=10) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,margin,0,this);
        offGraphics.setColor(Color.white);
        for (int x=0; x<=x0-5; x+=10) {
          offGraphics.fillRect(x,0,5,height);
        }
        offGraphics.fillRect(x0,0,width-x0,height);
        refresh(50);
      }
      for (int x0=0; x0<=width; x0+=10) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,margin,0,this);
        offGraphics.setColor(Color.white);
        for (int x=x0; x<width-5; x+=10) {
          offGraphics.fillRect(x,0,5,height);
        }
        refresh(10);
      }
      delay(1000);
    }
  }

  private void jShow8(int mode) { // Four direct expand
    for (int sw=0; sw<3; sw++) {
      for (int x=0; x<=width/2; x+=2) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.setClip(width/2-x, mode==1?(height/2-x*height/width):0, 2*x, mode==1?(2*x*height/width):height);
        offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,margin,0,this);
        refresh(10);
      }
      delay(1000);
    }
  }

  private void jShow9(int bn) { // Hori slide move
    for (int sw=0; sw<3; sw++) {
      for (int x=0; x<=width; x+=2) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        for (int i=0; i<bn; i++) {
          offGraphics=offGraphics.create();
          offGraphics.setClip(0, i*height/bn, width, height/bn);
          offGraphics.drawImage(sw==0?img1:sw==1?img2:img3,(i%2==0?1:-1)*(x-width)+margin,0,this);
        }
        refresh(10);
      }
      delay(1000);
    }
  }

  private void jShow10() { // Hori slide text move
    Font fnt = new Font("黑体", Font.BOLD, 90);
    int wid=adInfo.length();
    for (int x=0; x<=wid*80; x+=5) {
      offGraphics.setClip(0, 0, width, height);
      offGraphics.clearRect(0,0,width,height);
      offGraphics.drawImage(img0, 0, 17, this);
      offGraphics.setFont(fnt);
      offGraphics.setColor(Color.gray);
      offGraphics.drawString(adInfo, -x-2, 69);
      offGraphics.setColor(Color.white);
      offGraphics.drawString(adInfo, -x, 71);
      refresh(10);
    }
    delay(1000);
  }

  private void jShow11(int md) { // Hori slide text move
    int pos=0,wid=adInfo.length();
    char chad[]=adInfo.toCharArray();
    for (int sw=0;sw<2*wid;sw++) {
      for (int x=0; x<=md*10; x++) {
        Font fnt = new Font("黑体", Font.BOLD, 80);
        Color col;
        offGraphics.setFont(fnt);
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0,0,width,height);
        offGraphics.drawImage(img0, 0, 17, this);
        switch (md) {
        case 1:
          for (int i=Math.min(wid-1,6); i>=0; i--) {
            fnt = new Font("黑体", Font.BOLD, 90-i*10+x);
            offGraphics.setFont(fnt);
            col = new Color(225-i*30+x*3, 225-i*30+x*3, 0);
            offGraphics.setColor(col);
            offGraphics.drawChars(chad,(pos+i)%wid,1,15+i*15-x*3/2,height);
          }
          break;
        case 6:
          col = new Color(90+Math.abs(x-30)*165/30,
                          222+Math.abs(x-30)*33/30, 255);
          offGraphics.setColor(col);
          offGraphics.drawChars(chad, pos, 1, 20, height-5);
          break;
        }
        refresh(10);
      }
      pos=(pos+1)%wid;
    }
    delay(1000);
  }

  private void jShow12() { // Draw 2*6 flower rotately
    int px[]={-9, -2,   0,  2,  9,  4,  6,  0, -6, -4, -9};
    int py[]={-3, -3, -10, -3, -3,  1,  8,  4,  8,  1, -3};
    for (int i=0;i<10;i++) {
     for (int ang=-10; ang<10; ang++) {
      Color col=new Color(90+Math.abs(ang)*165/10,
                          222+Math.abs(ang)*33/10, 255);
      offGraphics.setClip(0, 0, width, height);
      offGraphics.clearRect(0,0,width,height);
      offGraphics.drawImage(img0, 0, 17, this);
      for (int x=-10; x<width; x+=20) {
        for (int y=10; y<height; y+=55) {
          offGraphics.translate(x+ang,y);
          offGraphics.setColor(col);
          offGraphics.fillPolygon(px, py, 11);
          offGraphics.translate(-x-ang,-y);
        }
      }
      refresh(10);
     }
    }
    delay(1000);
  }

  private void jCounter() {
    int w4 = img4.getWidth(this),
        h4 = img4.getHeight(this),
        wt = width+w4/2,
        ma = (width-w4)/2,
        i, x;
    for (i=0; i<5; i++) {
      for (x=wt; x>=0; x-=2) {
        offGraphics.setClip(0, 0, width, height);
        offGraphics.clearRect(0, 0, width, height);
        offGraphics.drawImage(img0, 0, 3, this);
        offGraphics.setColor(Color.black);
        offGraphics.fillRect(0, height-h4-3, width, h4+3);
        offGraphics.setClip(x-wt+ma+3, height-h4, w4-6, h4-6);
        offGraphics.drawImage(img4, x-wt+ma, height-h4-3, this);
        offGraphics.setClip(x+ma+3, height-h4, w4-6, h4-6);
        offGraphics.drawImage(img4, x+ma, height-h4-3, this);
        refresh(10);
      }
    }
    delay(1000);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -