有没有大佬把下面这段p5.js语言转换成java的,救救孩子
processing吧
全部回复
仅看楼主
level 1
var yoff = 0.0
function setup() {
createCanvas(800,500);
background(255);
}
function draw() {
stroke(255, 20);
fill(random(255),random(255),random(255),1);
beginShape();
var xoff= 0;
for (var x = 0; x <= width; x += 10) {
// Map noise value (between 0 and 1) to y-value of canvas
var y = map(noise(xoff, yoff), 0, 1, 100, 500);
// Set the vertex
vertex(x, y);
xoff += 0.05;
}
//Speed of moving waves
yoff += 0.008;
vertex(width, height);
vertex(0, height);
endShape(CLOSE);
}
function mousePressed() {
setup();
}
就是上面这一串,可以转成java吗😭😭求求各位大佬,非常感谢
2018年12月07日 14点12分 1
level 7
Hello,关于这段 p5.js 转变 processing 应该很简单,就需要改几处代码。但若是要转为 Java,由于部分库函数和程序设计等问题,得重写所有代码。
2018年12月08日 02点12分 2
那转成processing该怎么写呢😭😭刚入门实在不太明白,可以帮忙改一下吗,真的非常感谢
2018年12月08日 05点12分
@是否和你在一起 我想你只需要这篇文章——《p5.js 和 Processing 的恩怨情仇》。倘若你还不能解决,@我吧。
2018年12月08日 12点12分
level 3
楼主解决了吗?没有解决我可以帮你
2018年12月09日 06点12分 3
啊对不起已经解决了所以没怎么看贴吧!!真的非常感谢!您真的好厉害
2020年01月14日 05点01分
level 3
float yoff = 0.0;
void setup() {
size(800,500);
background(255);
}
void draw() {
stroke(255, 20);
fill(random(255),random(255),random(255),1);
beginShape();
float xoff= 0;
for (int x = 0; x <= width; x += 10) {
// Map noise value (between 0 and 1) to y-value of canvas
float y = map(noise(xoff, yoff), 0, 1, 100, 500);
// Set the vertex
vertex(x, y);
xoff += 0.05;
}
//Speed of moving waves
yoff += 0.008;
vertex(width, height);
vertex(0, height);
endShape(CLOSE);
}
void mousePressed() {
setup();
}
2018年12月09日 06点12分 4
level 3
2018年12月09日 06点12分 5
level 1
楼上太牛了,能加扣扣么
2019年02月25日 12点02分 6
level 1
var particles_a = [];
var particles_b = [];
var particles_c = [];
var nums =200;
var noiseScale = 800;
function setup(){
createCanvas(windowWidth, windowHeight);
background(21, 8, 50);
for(var i = 0; i < nums; i++){
particles_a[i] = new Particle(random(0, width),random(0,height));
particles_b[i] = new Particle(random(0, width),random(0,height));
particles_c[i] = new Particle(random(0, width),random(0,height));
}
}
function draw(){
noStroke();
smooth();
for(var i = 0; i < nums; i++){
var radius = map(i,0,nums,1,2);
var alpha = map(i,0,nums,0,250);
fill(69,33,124,alpha);
particles_a[i].move();
particles_a[i].display(radius);
particles_a[i].checkEdge();
fill(7,153,242,alpha);
particles_b[i].move();
particles_b[i].display(radius);
particles_b[i].checkEdge();
fill(255,255,255,alpha);
particles_c[i].move();
particles_c[i].display(radius);
particles_c[i].checkEdge();
}
}
function Particle(x, y){
this.dir = createVector(0, 0);
this.vel = createVector(0, 0);
this.pos = createVector(x, y);
this.speed = 0.4;
this.move = function(){
var angle = noise(this.pos.x/noiseScale, this.pos.y/noiseScale)*TWO_PI*noiseScale;
this.dir.x = cos(angle);
this.dir.y = sin(angle);
this.vel = this.dir.copy();
this.vel.mult(this.speed);
this.pos.add(this.vel);
}
this.checkEdge = function(){
if(this.pos.x > width || this.pos.x < 0 || this.pos.y > height || this.pos.y < 0){
this.pos.x = random(50, width);
this.pos.y = random(50, height);
}
}
this.display = function(r){
ellipse(this.pos.x, this.pos.y, r, r);
}
2019年02月25日 12点02分 7
level 1
这个怎么转
2019年02月25日 12点02分 8
level 3
2019年03月01日 03点03分 10
可以问您下,有个P5js的代码怎么改写成processing的代码吗?
2021年06月06日 09点06分
level 3
下次直接找个processing的,转来转去多麻烦[开心]
2019年03月01日 03点03分 13
您好,接processing+kinect的体感交互装置代写吗
2019年03月28日 08点03分
求合作
2019年04月06日 11点04分
level 3
2019年03月01日 03点03分 15
接processing代写吗
2019年03月20日 06点03分
请问在吗 方便的话可不可以加一下我的微信 我有一段java代码想转化成p5的语言 大佬能不能帮帮我 我可以给钱的 微是liuxinnuo0420 求求大佬了
2019年11月20日 17点11分
level 1
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.MemoryImageSource;
import java.util.Random;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.Timer;
public class Rain extends JDialog implements ActionListener {
private Random random = new Random();
private Dimension screenSize;
private JPanel graphicsPanel;
//行高,列宽
private final static int gap = 20;
//存放雨点顶部的位置信息(marginTop)
private int[] posArr;
//行数
private int lines;
//列数
private int columns;
public Rain() {
initComponents();
}
private void initComponents() {
setLayout(new BorderLayout());
graphicsPanel = new GraphicsPanel();
add(graphicsPanel, BorderLayout.CENTER);
//设置光标不可见
Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
Image image = defaultToolkit.createImage(new MemoryImageSource(0, 0, null, 0, 0));
Cursor invisibleCursor = defaultToolkit.createCustomCursor(image, new Point(0, 0), "cursor");
setCursor(invisibleCursor);
//ESC键退出
KeyPressListener keyPressListener = new KeyPressListener();
this.addKeyListener(keyPressListener);
//this.setAlwaysOnTop(true);
//去标题栏
this.setUndecorated(true);
//全屏
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(this);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setVisible(true);
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
lines = screenSize.height / gap;
columns = screenSize.width / gap;
posArr = new int[columns + 1];
random = new Random();
for (int i = 0; i < posArr.length; i++) {
posArr[i] = random.nextInt(lines);
}
//每秒10帧
new Timer(100, this).start();
}
/**
* @Return 随机字符
*/
private char getChr() {
return (char) (random.nextInt(94) + 33);
}
@Override
public void actionPerformed(ActionEvent e) {
graphicsPanel.repaint();
}
private class GraphicsPanel extends JPanel {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setFont(getFont().deriveFont(Font.BOLD));
g2d.setColor(Color.BLACK);
g2d.fillRect(0, 0, screenSize.width, screenSize.height);
//当前列
int currentColumn = 0;
for (int x = 0; x < screenSize.width; x += gap) {
int endPos = posArr[currentColumn];
g2d.setColor(Color.CYAN);
g2d.drawString(String.valueOf(getChr()), x, endPos * gap);
int cg = 0;
for (int j = endPos - 15; j < endPos; j++) {
//颜色渐变
cg += 20;
if (cg > 255) {
cg = 255;
}
g2d.setColor(new Color(0, cg, 0));
g2d.drawString(String.valueOf(getChr()), x, j * gap);
}
//每放完一帧,当前列上雨点的位置随机下移1~5行
posArr[currentColumn] += random.nextInt(5);
//当雨点位置超过屏幕高度时,重新产生一个随机位置
if (posArr[currentColumn] * gap > getHeight()) {
posArr[currentColumn] = random.nextInt(lines);
}
currentColumn++;
}
}
}
private class KeyPressListener extends KeyAdapter {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
System.exit(0);
}
}
}
public static void main(String[] args) {
new Rain();
}
}
2019年11月20日 18点11分 17
@苒冉然 求问这个怎么转
2019年11月20日 18点11分
@我妻好萌 @苒冉然 求问这个怎么转
2019年11月20日 18点11分
level 1

var img;
var balls = [];
var radiusLow = 10;
var radiusHigh = 20;
var rangeLow = .5;
var rangeHigh = 1;
function preload(){
img = loadImage("venom.jpg");
}
function setup() {
createCanvas(img.width, img.height);
background(255);
textAlign(CENTER);
text("なぞって!", width/2, height/2);
}
function draw(){
//var c = color(img.get(current.location.x, current.location.y));
//var greyscale = round(red(c) * 0.222 + green(c) * 0.707 + blue(c) * 0.071);
for (var i = 0; i < balls.length; i++){
balls[i].draw();
balls[i].update();
balls[i].changeColour();
}
for (var i = 0; i < balls.length; i++){
if (balls[i].radius < 0){
balls.splice(i, 1);
}
}
if (mouseIsPressed){
for (var i = 0; i < 5; i++){
balls.push(new Ball(mouseX, mouseY, color(img.get(mouseX+random(2), mouseY+random(2)))));
}
}
}
class Ball{
//start where the user clicks
//move up from where the user has clicked
//become smaller as it moves up
//be drawn to the screem
constructor(mX, mY, c){
this.location = createVector(mX, mY);
this.radius = random(10, 20);
this.r = red(c);
this.g = green(c);
this.b = blue(c);
this.xOff = 0.0;
this.yOff = 0.0;
this.radiusLow;
this.radiusHigh;
this.rangeLow;
this.rangeHigh
}
update(){
this.radius -= random(0.15, 0.25);
this.xOff = this.xOff + random(-.5, .5);
this.nX = noise(this.location.x) * this.xOff;
this.yOff = this.yOff + random(-.5, .5);
this.nY = noise(this.location.y) * this.yOff;
this.location.x += this.nX;
this.location.y += this.nY;
}
changeColour(){
this.c = color(img.get(this.location.x, this.location.y));
this.r = red(this.c);
this.g = green(this.c);
this.b = blue(this.c);
}
draw(){
noStroke();
fill(this.r, this.g, this.b);
ellipse(this.location.x, this.location.y, this.radius, this.radius);
}
}
2021年06月06日 09点06分 18
@苒冉然
2021年06月06日 09点06分
1