java颜色代码表(Cult3D 高级教程之改变材质颜色的java代码)

本文目录
- Cult3D 高级教程之改变材质颜色的java代码
- 用java声明一个颜色类Color
- 怎么用java语言将颜色变深或变浅 就是提供一个深青色,通过什么算法处理,得到一个浅青色 在线等,谢
- 用java如何随机生成颜色
Cult3D 高级教程之改变材质颜色的java代码
样使用这个class:
定义一个新的颜色color,比如" private Color red = new Color ( 198, 58, 41); " 增加该颜色的变量名variable name到colors数组,使用changeColor方法来循环改变颜色。
修改如下设置
import com.cult3d.*; import com.cult3d.world.*; import java.awt.Color; import java.awt.Image; import java.awt.Graphics; public class ColorSwap implements Cult3DScript, Runnable { // TEXTURE_NAME 的值是你要改变得纹理的名字 private static final String TEXTURE_NAME = "MADAROSE"; // if you want to add more colors add a Color instance here // and add it to the colors array. The numbers are in RGB values (0 to 255, where 0 is black and 255 is white) private Color red = new Color(198, 58, 41); private Color blue = new Color(99, 93, 163); private Color green = new Color(138, 149, 78); private Color grey = new Color(136, 136, 136); private Color lightBlue = new Color(121, 130, 173); private Color black = new Color(64, 64, 64); private Color); colorCounter++; } // The actual color change private void switchColor(Color color) { graphics.setColor(color); graphics.fillRect(0,0, textureWidth,textureHeight); texture.setTexture(textureImage); } public void cult3dDestroy() { } }
用java声明一个颜色类Color
import java.awt.*;
import java.awt.event.*;
public class adjustcolor implements AdjustmentListener, WindowListener {
Frame f=new Frame("调整颜色");
Label l1=new Label("调整滚动条,会改变初始颜色",Label.CENTER);
Label l2=new Label("此处显示颜色值",Label.CENTER);
Label l3=new Label("红",Label.CENTER);
Label l4=new Label("绿",Label.CENTER);
Label l5=new Label("蓝",Label.CENTER);
Scrollbar scr1=new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,265);
Scrollbar scr2=new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,265);
Scrollbar scr3=new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,265);
public adjustcolor(){
f.add(l1);
f.add(l2);
f.add(l3);
f.add(l4);
f.add(l5);
f.add(scr1);
f.add(scr2);
f.add(scr3);
f.setSize(400,350);
f.setVisible(true);
f.addWindowListener(this);
f.setResizable(false);
l1.setBackground(Color.GREEN);
scr1.setBounds(35,225,360,25);
scr2.setBounds(35,255,360,25);
scr3.setBounds(35,285,360,25);
l1.setBounds(0,0,400,200);
l2.setBounds(0,310,400,30);
l3.setBounds(0,225,30,30);
l4.setBounds(0,255,30,30);
l5.setBounds(0,285,30,30);
scr1.addAdjustmentListener(this);
scr2.addAdjustmentListener(this);
scr3.addAdjustmentListener(this);
l1.setBackground(Color.GREEN);
scr1.setBackground(Color.RED);
scr2.setBackground(Color.GREEN);
scr3.setBackground(Color.blue);
}
public void adjustmentValueChanged(AdjustmentEvent e){
int a=scr1.getValue();
int b=scr2.getValue();
int c=scr3.getValue();
l1.setBackground(new Color(a,b,c)) ;
l2.setText("红"+" "+"绿"+" "+"蓝"+" "+a+" "+b+" "+c);
l1.setText(null);
}
public static void main(String args){
new adjustcolor();
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
}
public void windowClosing(WindowEvent arg0) {
System.exit(0);
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}
这是源代码 应该是你想要的
怎么用java语言将颜色变深或变浅 就是提供一个深青色,通过什么算法处理,得到一个浅青色 在线等,谢
如果有的话获取红绿蓝颜色代码 比如#111533 统统上调一个比例 换成#223066就可以
乘以一个系数 最大的值不超过255就可以
用java如何随机生成颜色
//将背景色的值定义成空字符串
var bgColor="";
//循环6次,生成一个随机的六位数
for (var i = 0 ; i 《 6 ; i++)
{
bgColor += "" + Math.round(Math.random() * 9);
}
//将随机生成的背景颜色值赋给页面的背景色。
document.getElementById("test")
.style.backgroundColor="#" + bgColor;
把下面的代码放在一个空网页的最后体验一下。
《SCRIPT language=javascript type=text/javascript》
var a=Math.round(Math.random()*0x1000000);
var c="00000".concat(a.toString(16));
document.bgColor="#"+c.substr(c.length-6,6);
《/SCRIPT》

更多文章:
fontcreator怎么导入字体(如何在FontCreator中加入我想要的字)
2025年7月10日 20:00
wordpress主题二次元(怎么用wordpress搭建情侣博客怎么自己弄情侣主题求达人详细赐教!)
2025年7月4日 02:00
腾讯会议怎么向主持人询问后台记录并保存?手机储存内容会被APP浏览并上传保存APP后台服务器吗连着WIFI
2025年7月21日 04:00
正则高考复读学校(2022南京高三复读有哪些学校 南京复读学校名单)
2025年8月7日 13:30
verify例句(please-slide-to-verify是什么意思)
2025年12月5日 06:45
false的副词(英语试卷判断对错,T和F,哪个是对,那个是错)
2026年7月29日 00:00
go语言需要编译吗(Go语言能在安卓运行吗 Go是脚本语言还是汇编)
2026年3月18日 20:00
有哪些js框架(web前端三大主流框架是什么 都有哪些功能)
2025年9月22日 16:30
springfestival六年级作文(六年级过春节英语作文300字)
2026年2月27日 20:45
在java语言中下列说法正确的是(Java语言说法正确的有())
2026年9月9日 20:30
edittext下划线颜色(android 如何使EditText中不同行显示不同的颜色(两种颜色))
2026年5月15日 11:30
帝国cms手机端(请教帝国cms中的手机端同步插件bug 修复方法)
2026年1月18日 22:15













