MCPcopy Create free account
hub / github.com/JetBrains/skija / drawLinearCS

Method drawLinearCS

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

Source from the content-addressed store, hash-verified

168 }
169
170 private void drawLinearCS(Canvas canvas) {
171 for (ColorSpace cs: new ColorSpace[] {null, ColorSpace.getSRGB(), ColorSpace.getSRGBLinear()}) {
172 canvas.save();
173
174 int[][] colors = new int[][] {
175 new int[] {0xFFFF0000, 0xFF00FF00},
176 new int[] {0xFFFF0000, 0xFF0000FF},
177 new int[] {0xFFFF0000, 0xFF00FFFF},
178 new int[] {0xFF0000FF, 0xFF00FF00},
179 new int[] {0xFF00FFFF, 0xFFFF00FF},
180 new int[] {0xFF00FF00, 0xFFFF00FF},
181 new int[] {0xFF000000, 0xFFFFFFFF},
182 new int[] {0xFF555555, 0xFFAAAAAA},
183 };
184
185 try (Paint fill = new Paint()) {
186 for (int[] pair: colors) {
187 try (var shader = linearCS(31, 0, 129, 0, pair[0], pair[1], cs, 10)) {
188 fill.setColor(pair[0]);
189 canvas.drawRect(Rect.makeXYWH(0, 0, 30, 30), fill);
190
191 fill.setShader(shader);
192 canvas.drawRect(Rect.makeXYWH(31, 0, 98, 30), fill);
193 fill.setShader(null);
194
195 fill.setColor(pair[1]);
196 canvas.drawRect(Rect.makeXYWH(130, 0, 30, 30), fill);
197
198 canvas.translate(170, 0);
199 }
200 }
201 }
202
203 canvas.restore();
204 canvas.translate(0, 40);
205 }
206 }
207
208 private void drawBlending(Canvas canvas) {
209 int pink = 0xFFFF0080;

Callers 1

drawMethod · 0.95

Calls 10

getSRGBMethod · 0.95
getSRGBLinearMethod · 0.95
linearCSMethod · 0.95
makeXYWHMethod · 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