本文整理汇总了Java中processing.core.PMatrix2D类的典型用法代码示例。如果您正苦于以下问题:Java PMatrix2D类的具体用法?Java PMatrix2D怎么用?Java PMatrix2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PMatrix2D类属于processing.core包,在下文中一共展示了PMatrix2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateShapesData
import processing.core.PMatrix2D; //导入依赖的package包/类
protected void updateShapesData(){
if(particle_num == 0){
return;
}
final PMatrix2D mat = new PMatrix2D();
for (int i = 0, ipos = 0, icol = 0; i < particle_num; i++) {
// position
float pos_x = buf_pos[ipos++];
float pos_y = buf_pos[ipos++];
// velocity
// float vel_x = buf_vel[ivel++];
// float vel_y = buf_vel[ivel++];
// tint
int tint = DwUtils.createColorARGB(buf_col, icol); icol += 4;
mat.reset();
mat.translate(pos_x, pos_y);
mat.scale(particle_rad_world);
// mat.rotate((float)Math.atan2(vel_y, vel_x));
PShape shp = shp_particles.getChild(i);
shp.resetMatrix();
// mat.translate(pos_x, pos_y);
// mat.scale(particle_rad_world);
shp.applyMatrix(mat);
shp.setTint(tint);
}
}
示例2: createStrokedPath
import processing.core.PMatrix2D; //导入依赖的package包/类
/**
* Constructs a solid <code>LinePath</code> with the specified attributes.
*
* @param src
* the original path to be stroked
* @param weight
* the weight of the stroked path
* @param cap
* the decoration of the ends of the segments in the path
* @param join
* the decoration applied where path segments meet
* @param miterlimit
* @param transform
*
*/
static public LinePath createStrokedPath(LinePath src, float weight,
int caps, int join,
float miterlimit, PMatrix2D transform) {
final LinePath dest = new LinePath();
strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
@Override
public void moveTo(int x0, int y0, int c0) {
dest.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0), c0);
}
@Override
public void lineJoin() {
}
@Override
public void lineTo(int x1, int y1, int c1) {
dest.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1), c1);
}
@Override
public void close() {
dest.closePath();
}
@Override
public void end() {
}
});
return dest;
}
示例3: strokeTo
import processing.core.PMatrix2D; //导入依赖的package包/类
private static void strokeTo(LinePath src, float width, int caps, int join,
float miterlimit, PMatrix2D transform,
LineStroker lsink) {
lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
FloatToS15_16(miterlimit),
transform == null ? identity : transform);
PathIterator pi = src.getPathIterator();
pathTo(pi, lsink);
}
示例4: preRender
import processing.core.PMatrix2D; //导入依赖的package包/类
public void preRender(PApplet p) {
update();
p.pushMatrix();
double[] matrix = new double[6];
getTransformMatrix().getMatrix(matrix);
PMatrix m = new PMatrix2D((float)matrix[0], (float)matrix[2], (float)matrix[4], (float)matrix[1], (float)matrix[3], (float)matrix[5]);
p.applyMatrix(m);
}
示例5: setShape
import processing.core.PMatrix2D; //导入依赖的package包/类
@Override
public void setShape(PShape shape){
shp_particle = shape;
shp_transform = new PMatrix2D();
updateShapePosition();
}
示例6: getUnitDiskMatrix
import processing.core.PMatrix2D; //导入依赖的package包/类
public PMatrix2D getUnitDiskMatrix(){
PMatrix2D mat = new PMatrix2D();
mat.scale(1.0f/rad);
mat.translate(-pos[0], -pos[1]);
return mat;
}
示例7: applyMatrix
import processing.core.PMatrix2D; //导入依赖的package包/类
public void applyMatrix(PMatrix2D source) {
currentGraphics.applyMatrix(source);
}
示例8: setMatrix
import processing.core.PMatrix2D; //导入依赖的package包/类
public void setMatrix(PMatrix2D source) {
currentGraphics.setMatrix(source);
}
示例9: getMatrix
import processing.core.PMatrix2D; //导入依赖的package包/类
public PMatrix2D getMatrix(PMatrix2D target) {
return currentGraphics.getMatrix(target);
}
示例10: MarkerSvg
import processing.core.PMatrix2D; //导入依赖的package包/类
public MarkerSvg(int id, PMatrix2D matrix, PVector size) {
this.id = id;
this.size = size.get();
this.matrix = matrix.get();
}
示例11: getMatrix
import processing.core.PMatrix2D; //导入依赖的package包/类
public PMatrix2D getMatrix() {
return matrix;
}
示例12: getMarkersFromSVG
import processing.core.PMatrix2D; //导入依赖的package包/类
static public MarkerList getMarkersFromSVG(XML xml) {
float pageHeight = computeSize(xml.getString("height"));
// System.out.println("Height : " + pageHeight);
PShape svg = new PShapeSVGExtended(xml);
ArrayList<PShape> markersSVG = new ArrayList<>();
findMarkers((PShapeSVGExtended) svg, markersSVG);
// ArrayList<MarkerSvg> markers = new ArrayList<>();
MarkerList markers = new MarkerList();
float sheetWidth = computeSize(xml.getString("width")) * pixelToMm();
float sheetHeight = computeSize(xml.getString("height")) * pixelToMm();
markers.setSheetSize(sheetWidth, sheetHeight);
for (PShape markerSvg : markersSVG) {
int id = Integer.parseInt(markerSvg.getName().substring(6));
float[] params = markerSvg.getParams();
PVector size = new PVector(params[2], params[3]);
// SVG standard has a going down Y axis.
PMatrix2D matrix = (PMatrix2D) getMatrix(markerSvg);
matrix.scale(1, -1);
// matrix.translate(0, -size.y);
matrix.m02 = matrix.m02 * pixelToMm();
matrix.m12 = matrix.m12 * pixelToMm();
// matrix.m12 = (pageHeight - matrix.m12) * pixelToMm();
size.x = size.x * pixelToMm();
size.y = size.y * pixelToMm();
MarkerSvg marker = new MarkerSvg(id, matrix.get(), size);
marker.corners[0] = new PVector(matrix.m02, matrix.m12);
matrix.translate(size.x, 0);
marker.corners[1] = new PVector(matrix.m02, matrix.m12);
matrix.translate(0, -size.y);
marker.corners[2] = new PVector(matrix.m02, matrix.m12);
matrix.translate(-size.x, 0);
marker.corners[3] = new PVector(matrix.m02, matrix.m12);
marker.cornersSet = true;
markers.put(id, marker);
}
return markers;
}
示例13: setParameters
import processing.core.PMatrix2D; //导入依赖的package包/类
/**
* Sets the parameters of this <code>LineStroker</code>.
*
* @param lineWidth
* the desired line width in pixels, in S15.16 format.
* @param capStyle
* the desired end cap style, one of <code>CAP_BUTT</code>,
* <code>CAP_ROUND</code> or <code>CAP_SQUARE</code>.
* @param joinStyle
* the desired line join style, one of <code>JOIN_MITER</code>,
* <code>JOIN_ROUND</code> or <code>JOIN_BEVEL</code>.
* @param miterLimit
* the desired miter limit, in S15.16 format.
* @param transform
* a <code>Transform4</code> object indicating the transform that has
* been previously applied to all incoming coordinates. This is
* required in order to produce consistently shaped end caps and
* joins.
*/
public void setParameters(int lineWidth, int capStyle, int joinStyle,
int miterLimit, PMatrix2D transform) {
this.m00 = LinePath.FloatToS15_16(transform.m00);
this.m01 = LinePath.FloatToS15_16(transform.m01);
this.m10 = LinePath.FloatToS15_16(transform.m10);
this.m11 = LinePath.FloatToS15_16(transform.m11);
this.lineWidth2 = lineWidth >> 1;
this.scaledLineWidth2 = ((long) m00 * lineWidth2) >> 16;
this.capStyle = capStyle;
this.joinStyle = joinStyle;
this.m00_2_m01_2 = (double) m00 * m00 + (double) m01 * m01;
this.m10_2_m11_2 = (double) m10 * m10 + (double) m11 * m11;
this.m00_m10_m01_m11 = (double) m00 * m10 + (double) m01 * m11;
double dm00 = m00 / 65536.0;
double dm01 = m01 / 65536.0;
double dm10 = m10 / 65536.0;
double dm11 = m11 / 65536.0;
double determinant = dm00 * dm11 - dm01 * dm10;
if (joinStyle == LinePath.JOIN_MITER) {
double limit = (miterLimit / 65536.0) * (lineWidth2 / 65536.0)
* determinant;
double limitSq = limit * limit;
this.miterLimitSq = (long) (limitSq * 65536.0 * 65536.0);
}
this.numPenSegments = (int) (3.14159f * lineWidth / 65536.0f);
if (pen_dx == null || pen_dx.length < numPenSegments) {
this.pen_dx = new int[numPenSegments];
this.pen_dy = new int[numPenSegments];
this.penIncluded = new boolean[numPenSegments];
this.join = new int[2 * numPenSegments];
}
for (int i = 0; i < numPenSegments; i++) {
double r = lineWidth / 2.0;
double theta = i * 2 * Math.PI / numPenSegments;
double cos = Math.cos(theta);
double sin = Math.sin(theta);
pen_dx[i] = (int) (r * (dm00 * cos + dm01 * sin));
pen_dy[i] = (int) (r * (dm10 * cos + dm11 * sin));
}
prev = LinePath.SEG_CLOSE;
rindex = 0;
started = false;
lineToOrigin = false;
}
示例14: applyMatrix
import processing.core.PMatrix2D; //导入依赖的package包/类
@Override
public void applyMatrix(PMatrix2D source) {
transform(MATRIX, source.m00, source.m01, source.m02,
source.m10, source.m11, source.m12);
}
示例15: LineStroker
import processing.core.PMatrix2D; //导入依赖的package包/类
/**
* Constructs a <code>LineStroker</code>.
*
* @param output
* an output <code>LineStroker</code>.
* @param lineWidth
* the desired line width in pixels, in S15.16 format.
* @param capStyle
* the desired end cap style, one of <code>CAP_BUTT</code>,
* <code>CAP_ROUND</code> or <code>CAP_SQUARE</code>.
* @param joinStyle
* the desired line join style, one of <code>JOIN_MITER</code>,
* <code>JOIN_ROUND</code> or <code>JOIN_BEVEL</code>.
* @param miterLimit
* the desired miter limit, in S15.16 format.
* @param transform
* a <code>Transform4</code> object indicating the transform that has
* been previously applied to all incoming coordinates. This is
* required in order to produce consistently shaped end caps and
* joins.
*/
public LineStroker(LineStroker output, int lineWidth, int capStyle, int joinStyle,
int miterLimit, PMatrix2D transform) {
setOutput(output);
setParameters(lineWidth, capStyle, joinStyle, miterLimit, transform);
}