bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

圖像平移的java代碼 圖像平移的java代碼有哪些

用JAVA語言寫一個二維平面圖形(如長方形)的平移,旋轉,縮放的程序.

import?javax.swing.*;

在巨鹿等地區,都構建了全面的區域性戰略布局,加強發展的系統性、市場前瞻性、產品創新能力,以專注、極致的服務理念,為客戶提供網站設計制作、成都網站制作 網站設計制作定制網站開發,公司網站建設,企業網站建設,品牌網站制作,網絡營銷推廣,外貿網站制作,巨鹿網站建設費用合理。

import?java.awt.*;

import?java.awt.event.ActionEvent;

import?java.awt.geom.*;

/**

*?@author?Hardneedl

*/

class?RectTransform?extends?JFrame?{

private?static?final?Dimension?minSize?=?new?Dimension(300,?200);

private?static?final?Dimension?maxSize?=?new?Dimension(1024,?768);

private?static?final?Dimension?preferredSize?=?new?Dimension(600,?400);

public?Dimension?getMaximumSize()?{return?maxSize;}

public?Dimension?getMinimumSize()?{return?minSize;}

public?Dimension?getPreferredSize()?{return?preferredSize;}

public?String?getTitle()?{return?"Frame?Title";}

private?AffineTransform?af?=?new?AffineTransform();

private?Stroke?stroke?=?new?BasicStroke(2.0f);

private?Rectangle?rct?=?new?Rectangle(40,140,200,140);

private?JComponent?canvas?=?new?JComponent(){

protected?void?paintComponent(Graphics?g)?{

super.paintComponent(g);

g.setColor(Color.BLACK);

g.fillRect(0,0,getWidth(),getHeight());

Graphics2D?g2d?=?(Graphics2D)g.create();

g2d.setColor(Color.YELLOW);

g2d.setTransform(af);

g2d.setStroke(stroke);

g2d.draw(rct);

g2d.dispose();

}

};

RectTransform()?throws?HeadlessException?{

init();

doLay();

attachListeners();

}

private?void?init()?{

}

private?void?doLay()?{

Container?container?=?getContentPane();

JPanel?panel?=?new?JPanel(new?FlowLayout(FlowLayout.CENTER,30,5));

panel.add(new?JButton(?new?AfAction("move",?AffineTransform.getTranslateInstance(100,100))?));

panel.add(new?JButton(?new?AfAction("rotate",?AffineTransform.getRotateInstance(Math.PI/3,40,120)?)?));

panel.add(new?JButton(?new?AfAction("zoomIn",?AffineTransform.getScaleInstance(2,2))?));

panel.add(new?JButton(?new?AfAction("ZoomOut",?AffineTransform.getScaleInstance(.5d,.5d))?));

panel.add(new?JButton(?new?AfAction("Original",?new?AffineTransform())?)?);

container.add(panel,BorderLayout.NORTH);

container.add(canvas,BorderLayout.CENTER);

pack();

}

private?void?attachListeners()?{

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

private?class?AfAction?extends?AbstractAction?{

private?AffineTransform?aff;

private?AfAction(String?n,AffineTransform?af)?{

super(n);

this.aff?=?af;

}

public?void?actionPerformed(ActionEvent?e)?{

af.setTransform(aff);

if(canvas.isVisible())?canvas.paintImmediately(0,0,getWidth(),getHeight());

}

}

public?static?void?main(String[]?args)?{

new?RectTransform().setVisible(true);

}

}

用java怎樣編寫一個二維坐標平移程序

java編寫二維坐標平移程序,主要是通過類繼承Point2D,使用里面的方法來平移,如下代碼:

class??Point2D

{???

int?x,?y;

Point2D(){??}

Point2D(int?i,int?j)

{

x=i;

y=j;

}

void?offset(int?a,?int?b)

{

x=x+a;

y=y+b;

}

void?distance(Point2D?a,Point2D?b)?

{

float?m;

m=(float)Math.sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));

System.out.print("二維空間兩點之間的距離:");

System.out.println("m="+m);

}

}

public?class?Point3D?extends?Point2D

{

int?x,y,z;

Point3D(int?x,int?y,int?z)

{

this.x=x;

this.y=y;

this.z=z;

}

Point3D(Point2D?p,int?z)

{

x=p.x;

y=p.y;

this.z=z;

}

void?offset(int?a,?int?b,int?c)

{

x=x+a;

b=x+b;

c=x+c;

}?

void?distance(Point3D?a,Point3D?b)?

{

float?n;

n=(float)Math.sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.y-b.y)*(a.y-b.y));//計算兩點之間的距離。

System.out.print("三維空間兩點之間的距離:");

System.out.println("n="+n);

}

public?static?void?main(String[]?args)?

{

Point2D?p2d1=new?Point2D(2,3);

Point2D?p2d2=new?Point2D(3,6);

Point3D?p2d3=new?Point3D(1,2,3);

Point3D?p2d4=new?Point3D(p2d1,3);

p2d1.distance(p2d1,p2d2);

p2d3.distance(p2d3,p2d4);//平移一段距離。

}

}

Android如何純java代碼實現字體陰影效果

Android實現純java代碼字體陰影效果,主要是通過activity的draw方法,進行重新繪制,如下代碼:

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();//初始化畫筆,為后面陰影效果使用。

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

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

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();//如果不調用mutate方法,則原圖也會被改變,因為調用的資源是同一個,所有對象是共享狀態的。

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);//設置畫布顏色

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);//圖像(其實是畫布)縮放,Y方向縮小為1/2。

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

drawable.clearColorFilter();

canvas.restore();

canvas.save(Canvas.MATRIX_SAVE_FLAG);

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

canvas.restore();

//默認無效果原圖

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);//此為理論上的陰影圖坐標

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

//由于圖片的實際尺寸比顯示出來的圖像要大一些,因此需要適當更改下大小,以達到較好的效果

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

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

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

canvas.restore();

}

}

}

網頁名稱:圖像平移的java代碼 圖像平移的java代碼有哪些
URL地址:http://vcdvsql.cn/article38/ddopcsp.html

成都網站建設公司_創新互聯,為您提供搜索引擎優化微信公眾號網站設計網站導航網站建設全網營銷推廣

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站優化排名