MCPcopy Create free account
hub / github.com/HumbleUI/Skija / drawLinearCS

Method drawLinearCS

examples/scenes/src/ShadersScene.java:201–237  ·  view source on GitHub ↗
(Canvas canvas)

Source from the content-addressed store, hash-verified

199 }
200
201 private void drawLinearCS(Canvas canvas) {
202 for (ColorSpace cs: new ColorSpace[] {null, ColorSpace.getSRGB(), ColorSpace.getSRGBLinear()}) {
203 canvas.save();
204
205 int[][] colors = new int[][] {
206 new int[] {0xFFFF0000, 0xFF00FF00},
207 new int[] {0xFFFF0000, 0xFF0000FF},
208 new int[] {0xFFFF0000, 0xFF00FFFF},
209 new int[] {0xFF0000FF, 0xFF00FF00},
210 new int[] {0xFF00FFFF, 0xFFFF00FF},
211 new int[] {0xFF00FF00, 0xFFFF00FF},
212 new int[] {0xFF000000, 0xFFFFFFFF},
213 new int[] {0xFF555555, 0xFFAAAAAA},
214 };
215
216 try (Paint fill = new Paint()) {
217 for (int[] pair: colors) {
218 try (var shader = linearCS(31, 0, 129, 0, pair[0], pair[1], cs, 10)) {
219 fill.setColor(pair[0]);
220 canvas.drawRect(Rect.makeXYWH(0, 0, 30, 30), fill);
221
222 fill.setShader(shader);
223 canvas.drawRect(Rect.makeXYWH(31, 0, 98, 30), fill);
224 fill.setShader(null);
225
226 fill.setColor(pair[1]);
227 canvas.drawRect(Rect.makeXYWH(130, 0, 30, 30), fill);
228
229 canvas.translate(170, 0);
230 }
231 }
232 }
233
234 canvas.restore();
235 canvas.translate(0, 40);
236 }
237 }
238
239 private void drawBlending(Canvas canvas) {
240 int pink = 0xFFFF0080;

Callers 1

drawMethod · 0.95

Calls 9

getSRGBMethod · 0.95
getSRGBLinearMethod · 0.95
linearCSMethod · 0.95
saveMethod · 0.80
drawRectMethod · 0.80
setShaderMethod · 0.80
restoreMethod · 0.80
setColorMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected