欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Java簡(jiǎn)單特效代碼 簡(jiǎn)單的特效代碼

Android如何純java代碼實(shí)現(xiàn)字體陰影效果

Android實(shí)現(xiàn)純java代碼字體陰影效果,主要是通過(guò)activity的draw方法,進(jìn)行重新繪制,如下代碼:

創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括江南網(wǎng)站建設(shè)、江南網(wǎng)站制作、江南網(wǎng)頁(yè)制作以及江南網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,江南網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到江南省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

package?canvas.test;

import?android.app.Activity;

import?android.os.Bundle;

import?android.content.Context;

import?android.graphics.Bitmap;

import?android.graphics.BitmapFactory;

import?android.graphics.Canvas;

import?android.graphics.Color;

import?android.graphics.Paint;

import?android.graphics.PorterDuff;

import?android.graphics.PorterDuff.Mode;

import?android.graphics.PorterDuffXfermode;

import?android.graphics.Rect;

import?android.graphics.RectF;

import?android.graphics.drawable.Drawable;

import?android.view.View;

public?class?ShaderEffect?extends?Activity?{

@Override

public?void?onCreate(Bundle?savedInstanceState)?{

super.onCreate(savedInstanceState);

setContentView(new?ImageEffect(this));

}

class?ImageEffect?extends?View{

Paint?paint;?

public?ImageEffect?(Context?context){

super(context);

paint?=?new?Paint();//初始化畫(huà)筆,為后面陰影效果使用。

paint.setAntiAlias(true);//去除鋸齒。

paint.setShadowLayer(5f,?5.0f,?5.0f,?Color.BLACK);//設(shè)置陰影層,這是關(guān)鍵。

paint.setXfermode(new?PorterDuffXfermode(Mode.SRC_IN));

}

@Override

public?void?onDraw(Canvas?canvas){

super.onDraw(canvas);

int?posX?=?20;

int?posY?=?50;

int?PicWidth,PicHegiht;?

Drawable?drawable?=?getResources().getDrawable(R.drawable.button);

Drawable?dbe?=?getResources().getDrawable(R.drawable.button).mutate();//如果不調(diào)用mutate方法,則原圖也會(huì)被改變,因?yàn)檎{(diào)用的資源是同一個(gè),所有對(duì)象是共享狀態(tài)的。

Drawable?drawTest?=?getResources().getDrawable(R.drawable.button);

Bitmap?bmp?=?BitmapFactory.decodeResource(getResources(),?R.drawable.button);

PicWidth?=?drawable.getIntrinsicWidth();

PicHegiht?=?drawable.getIntrinsicHeight();

drawTest.setBounds(posX,?(2?*?posY)?+?PicHegiht,?posX?+?PicWidth,?(2?*?posY)?+?2?*?PicHegiht?);

drawable.setBounds(posX,posY,posX+PicWidth,posY+PicHegiht);

dbe.setBounds(0,?0,?PicWidth,?PicHegiht);

canvas.drawColor(Color.WHITE);//設(shè)置畫(huà)布顏色

canvas.save(Canvas.MATRIX_SAVE_FLAG);

dbe.setColorFilter(0x7f000000,PorterDuff.Mode.SRC_IN);

canvas.translate(posX?+?(int)(0.9?*?PicWidth/2),?posY?+?PicHegiht/2);//圖像平移為了剛好在原圖后形成影子效果。

canvas.skew(-0.9F,?0.0F);//圖像傾斜效果。

canvas.scale(1.0f,?0.5f);//圖像(其實(shí)是畫(huà)布)縮放,Y方向縮小為1/2。

dbe.draw(canvas);//此處為畫(huà)原圖像影子效果圖,比原圖先畫(huà),則會(huì)在下層。

drawable.clearColorFilter();

canvas.restore();

canvas.save(Canvas.MATRIX_SAVE_FLAG);

drawable.draw(canvas);//此處為畫(huà)原圖像,由于canvas有層次效果,因此會(huì)蓋在影子之上。

canvas.restore();

//默認(rèn)無(wú)效果原圖

canvas.save(Canvas.MATRIX_SAVE_FLAG);

drawTest.draw(canvas);

canvas.restore();

//圖片陰影效果

canvas.save(Canvas.MATRIX_SAVE_FLAG);

//Rect?rect?=?new?Rect(2*posX?+?PicWidth,?2*posY?+?PicHegiht,?2*posX?+?2*PicWidth,?2*posY?+?2*PicHegiht);//此為理論上的陰影圖坐標(biāo)

Rect?rect?=?new?Rect(2*posX?+?PicWidth?+?3,?2*posY?+?PicHegiht?+?3,?2*posX?+?2*PicWidth?-?2,?2*posY?+?2*PicHegiht?-?2);

//由于圖片的實(shí)際尺寸比顯示出來(lái)的圖像要大一些,因此需要適當(dāng)更改下大小,以達(dá)到較好的效果

RectF?rectF?=?new?RectF(rect);

canvas.drawRoundRect(rectF,?10f,?10f,?paint);//在原有矩形基礎(chǔ)上,畫(huà)成圓角矩形,同時(shí)帶有陰影層。

canvas.drawBitmap(bmp,?2*posX?+?PicWidth,?2*posY?+?PicHegiht,?null);//畫(huà)上原圖。

canvas.restore();

}

}

}

滾動(dòng)的小球 java源代碼

;

要制造那種效果只需要大約 30 行 Java 代碼:

import javax.swing.*;

import java.awt.*;

import java.awt.geom.*;

class RollingBall extends JPanel {

Ellipse2D.Float ball = new Ellipse2D.Float( -100, 100, 50, 50 );

public void paintComponent( Graphics g ) {

super.paintComponent( g );

Graphics2D g2 = ( Graphics2D ) g;

// Draw the ball

g2.fill( ball );

// Draw the rotating ellipse by skewing the Device Space

double angdeg =?????// One rotation per ball's travelling over its perimeter

ball.x++ % ( Math.PI * ball.width ) / ( Math.PI * ball.width ) * 360;

g2.rotate( Math.toRadians( angdeg ), ball.getCenterX( ), ball.getCenterY( ) );

g2.scale( .5, 1 );

g2.translate( ball.getCenterX( ), 0 );

g2.setColor( Color.gray );

g2.fill( ball );

}

public void roll( ) throws Exception {

while( true ) {

repaint( );

Thread.sleep( 8 );

}

}

public static void main( String[ ] args ) throws Exception {

JFrame f = new JFrame( );

RollingBall rb = new RollingBall( );

f.setSize( 999, 185 );

f.getContentPane( ).add( rb );

f.setVisible( true );

rb.roll( );

}

}

Java實(shí)現(xiàn)多種幻燈片切換特效(附源碼)

功能說(shuō)明 代碼實(shí)現(xiàn)了多種幻燈片變換特效 如 淡入淡出 緩慢覆蓋 旋轉(zhuǎn)覆蓋等 多種變換效果

功能實(shí)現(xiàn)

圖片加載類ImageLoader實(shí)現(xiàn)

)用阻塞隊(duì)列存儲(chǔ)要圖片 BlockingQueue images = new ArrayBlockingQueue( )

)用圖片eof表示圖片隊(duì)列結(jié)束 Image eof = new WritableImage( )

)循環(huán)讀取指定圖片 由于是阻塞隊(duì)列 所以當(dāng)隊(duì)列滿的時(shí)候線程會(huì)自動(dòng)阻塞

public void run() {

int id = ;

try {

while (true) {

String path = resources[id];

InputStream is = getClass() getResourceAsStream(path)

if (is != null) {

Image image = new Image(is width height true true)

if (!image isError()) {

images put(image)

}

}

id++;

if (id = resources length) {

id = ;

}

}

} catch (Exception e) {

} finally {

if (!cancelled) {

try {

images put(eof)

} catch (InterruptedException e) {

}

}

}

}

特效實(shí)現(xiàn) 以弧形切換圖片為例 首先定義LengthTransition變化特效 設(shè)置變化時(shí)間 以及弧度數(shù)跟時(shí)間的變化關(guān)系

class LengthTransition extends Transition {

Arc arc;

public LengthTransition(Duration d Arc arc) {

this arc = arc;

setCycleDuration(d)

}

@Override

protected void interpolate(double d) {

arc setLength(d * )

}

}

然后設(shè)置圖片層疊效果

group setBlendMode(BlendMode SRC_OVER)

next setBlendMode(BlendMode SRC_ATOP)

以及之前那張圖片的淡出特效

FadeTransition ft = new FadeTransition(Duration seconds( ) mask )

最后同時(shí)執(zhí)行這兩個(gè)特效

ParallelTransition pt = new ParallelTransition(lt ft)

效果圖

如何用JAVA實(shí)現(xiàn)聊天窗口的抖動(dòng)效果,最好是具體代碼

public class ShakeFrame extends JFrame {

private JButton btn = new JButton("Click me!");

public ShakeFrame() {

super("抖動(dòng)窗口");

this.setSize(300, 200);

this.setVisible(true);

this.setResizable(false);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setLayout(null);

btn.setBounds(10, 10, 100, 30);

this.add(btn);

btn.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

int x = ShakeFrame.this.getX();

int y = ShakeFrame.this.getY();

for (int i = 0; i 20; i++) {

if ((i 1) == 0) {

x += 3;

y += 3;

} else {

x -= 3;

y -= 3;

}

ShakeFrame.this.setLocation(x, y);

try {

Thread.sleep(50);

} catch (InterruptedException e1) {

e1.printStackTrace();

}

}

}

});

}

public static void main(String[] args) {

new ShakeFrame();

}

}

網(wǎng)站欄目:Java簡(jiǎn)單特效代碼 簡(jiǎn)單的特效代碼
文章出自:http://chinadenli.net/article42/hgdchc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)軟件開(kāi)發(fā)做網(wǎng)站App開(kāi)發(fā)網(wǎng)站制作建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

綿陽(yáng)服務(wù)器托管