MCPcopy Create free account
hub / github.com/benfry/processing4 / setParameters

Method setParameters

core/src/processing/opengl/LineStroker.java:140–191  ·  view source on GitHub ↗

Sets the parameters of this LineStroker . @param lineWidth the desired line width in pixels, in S15.16 format. @param capStyle the desired end cap style, one of CAP_BUTT , CAP_ROUND or CAP_SQUARE . @param joinStyle

(int lineWidth, int capStyle, int joinStyle,
                            int miterLimit, PMatrix2D transform)

Source from the content-addressed store, hash-verified

138 * joins.
139 */
140 public void setParameters(int lineWidth, int capStyle, int joinStyle,
141 int miterLimit, PMatrix2D transform) {
142 this.m00 = LinePath.FloatToS15_16(transform.m00);
143 this.m01 = LinePath.FloatToS15_16(transform.m01);
144 this.m10 = LinePath.FloatToS15_16(transform.m10);
145 this.m11 = LinePath.FloatToS15_16(transform.m11);
146
147 this.lineWidth2 = lineWidth >> 1;
148 this.scaledLineWidth2 = ((long) m00 * lineWidth2) >> 16;
149 this.capStyle = capStyle;
150 this.joinStyle = joinStyle;
151
152 this.m00_2_m01_2 = (double) m00 * m00 + (double) m01 * m01;
153 this.m10_2_m11_2 = (double) m10 * m10 + (double) m11 * m11;
154 this.m00_m10_m01_m11 = (double) m00 * m10 + (double) m01 * m11;
155
156 double dm00 = m00 / 65536.0;
157 double dm01 = m01 / 65536.0;
158 double dm10 = m10 / 65536.0;
159 double dm11 = m11 / 65536.0;
160 double determinant = dm00 * dm11 - dm01 * dm10;
161
162 if (joinStyle == LinePath.JOIN_MITER) {
163 double limit = (miterLimit / 65536.0) * (lineWidth2 / 65536.0)
164 * determinant;
165 double limitSq = limit * limit;
166 this.miterLimitSq = (long) (limitSq * 65536.0 * 65536.0);
167 }
168
169 this.numPenSegments = (int) (3.14159f * lineWidth / 65536.0f);
170 if (pen_dx == null || pen_dx.length < numPenSegments) {
171 this.pen_dx = new int[numPenSegments];
172 this.pen_dy = new int[numPenSegments];
173 this.penIncluded = new boolean[numPenSegments];
174 this.join = new int[2 * numPenSegments];
175 }
176
177 for (int i = 0; i < numPenSegments; i++) {
178 double r = lineWidth / 2.0;
179 double theta = i * 2 * Math.PI / numPenSegments;
180
181 double cos = Math.cos(theta);
182 double sin = Math.sin(theta);
183 pen_dx[i] = (int) (r * (dm00 * cos + dm01 * sin));
184 pen_dy[i] = (int) (r * (dm10 * cos + dm11 * sin));
185 }
186
187 prev = LinePath.SEG_CLOSE;
188 rindex = 0;
189 started = false;
190 lineToOrigin = false;
191 }
192
193 private void computeOffset(int x0, int y0, int x1, int y1, int[] m) {
194 long lx = (long) x1 - (long) x0;

Callers 1

LineStrokerMethod · 0.95

Calls 3

FloatToS15_16Method · 0.95
cosMethod · 0.45
sinMethod · 0.45

Tested by

no test coverage detected