我能够将图像复制到该位置,但无法镜像它。我缺少什么?
PImage img;
float srcY;
float srcX;
int destX;
int destY;
img = loadImage("http://oldpalmgolfclub.com/wp-content/uploads/2012/02/Palm- Beach-State-College2-e1329949470871.jpg");
size(img.width, img.height * 2);
image(img, 0, 0);
image(img, 0, 330);
int num_pixels = img.width * img.height;
int copiedWidth = 319 - 254;
int copiedHeight = 85 - 22;
int startX = (width / 2) - (copiedWidth / 2);
int startY = (height / 2) - (copiedHeight / 2);
Run Code Online (Sandbox Code Playgroud) 在应用透视变换之前,我需要在着色器中翻转纹理。我修改了vert.glsl中的vertTexCoord ,但我不知道在swap.glsl中哪里使用它。这样做的方式就像
gl_FragColor = texture2D(texture, vertTexCoord );
Run Code Online (Sandbox Code Playgroud)
不起作用,因为我还需要在透视上修改纹理。
垂直.glsl:
#define PROCESSING_COLOR_SHADER
uniform mat4 transform;
uniform mat4 texMatrix;
attribute vec4 vertex;
attribute vec4 color;
attribute vec2 texCoord;
varying vec4 vertColor;
varying vec4 vertTexCoord;
void main() {
gl_Position = transform * vertex;
vertColor = color;
vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
交换.glsl:
#ifdef GL_ES
precision highp float;
#endif
// General parameters
uniform sampler2D from;
uniform sampler2D to;
uniform float progress;
uniform vec2 resolution;
uniform float …Run Code Online (Sandbox Code Playgroud) 将数字从一个范围重新映射到另一个范围。
例如
int ans = map(5, 0, 10, 0, 100);
Run Code Online (Sandbox Code Playgroud)
ans将是50和之间5的中间位置和 之间的中间位置是。010010050
如果没有内置函数,我该如何编写自己的函数?
我在处理 3.3.6 中有以下代码片段:
menuBarButtons.add(new TextButton("File", 0, 0, 20, menuBarHeight, (() -> println("Test")) ));
但是,处理给出了错误
Lambda expressions are allowed only at source level 1.8 or above
通过更改构建路径/运行配置中的 JRE,这在任何普通的 Java IDE 中都很容易修复,但我在设置中找不到任何选项。我尝试将更新的 JRE 复制粘贴到处理文件夹中,但无济于事。
我想在 P5.js 中用圆圈制作一个戒指。我希望圆圈彼此之间具有相同的大小并完成环,但圆圈的数量可以更改为任何值。
for(var i = 0; i < 13; i++){
xCircle = middle + cos(i/3) * 200;
yCircle = middle - sin(i/3) * 200;
}
Run Code Online (Sandbox Code Playgroud)
这只会启动戒指,但不会完成它。我知道某个地方必须是圈子的总数,但我不知道在哪里。
我只想问一个简单的问题,如何加载图像并将其作为我的 html5 画布中的背景
var bg;
function setup() {
createCanvas(600,400)
bg = loadImage("https://mcdn.wallpapersafari.com/medium/1/92/T1iecJ.jpg")
}
function draw() {
background(bg)
}
Run Code Online (Sandbox Code Playgroud)
我试过那个方法,但屏幕只显示白屏,我已经搜索过了,但我找不到解决方案。
我还是 OOP 编程和编写紧凑代码的新手,所以我可能忽略了一些东西,我试图找出一种方法来检查井字游戏中的垂直赢和对角赢,我已经有了水平。
如果可能的话,有没有办法将其他两种方式合并到我已经拥有的东西中?
#creates the gameboard that stores if spaces are open or not
game_board = [ [0,0,0], [0, 0, 0], [0, 0, 0,] ]
#0 = open space
#1 = O
#2 = X
#check for winners horizontaly
def find_winner():
# y represents the y axis
for y in range(3):
if game_board[y][0] == game_board[y][1] == game_board[y][2] != 0:
#returns if the X or 0 has won
return game_board[y][0]
#returns 0 if no-one has won
return 0
Run Code Online (Sandbox Code Playgroud) 在我当前的项目中,我有一个PVList的ArrayList,它存储3d点的xyz坐标.我将ArrayList传递给另一个操作它的类,但是,这样做时我得到一个NullPointerException.我假设其中一个PVectors为null,但我通过将任何空对象分配给(0,0,0)并且我仍然收到错误来检查这一点.此外,拥有一系列PVectors或一个ArrayList of PVectors更有效吗?无论哪种方式,我仍然得到错误.这是产生它的线.
trip.pass(pointCoordinates);
Run Code Online (Sandbox Code Playgroud)
这是主要课程
import org.openkinect.*;
import org.openkinect.processing.*;
Kinect kinect;
Trip trip;
boolean tripOn;
int w = 640;
int h = 480;
int distance = 5;
float[] depthLookUp = new float[2048];
ArrayList pointCoordinates = new ArrayList();
float factor = 400;
float a = 0;
float angle = 0;
float frequency = .05;
void setup() {
size(800,600,P3D);
kinect = new Kinect(this);
kinect.start();
kinect.enableDepth(true);
kinect.processDepthImage(false);
stroke(255);
for (int i = 0; i < depthLookUp.length; i++) {
depthLookUp[i] = rawDepthToMeters(i);
}
for(int …Run Code Online (Sandbox Code Playgroud) 如果我想使用Processing 2.0(Java)创建一个"发光的光晕效果",我该怎么做?
是否有任何内置的方法/转换可以应用于我的对象以使它们发光?
如果没有,是否有任何视觉技巧可以达到同样的效果?
processing ×10
javascript ×3
p5.js ×3
java ×2
c++ ×1
canvas ×1
glsl ×1
graphics ×1
image ×1
java-8 ×1
lambda ×1
mirroring ×1
opengl ×1
python ×1
tic-tac-toe ×1