Options
These globals are now defined:
double duration; // The requested duration of the animation. double frame; // A value in [0, 1] of where we are in the animation.
This global is now defined:
GrBackendRenderTarget backEndRenderTarget;
GrBackendTexture backEndTextureRenderTarget;
Optional source image
These globals are now defined:
SkBitmap source; sk_sp<SkImage> image; GrBackendTexture backEndTexture; // GPU Only.
Note:
Adding comments with SK_FOLD_START and SK_FOLD_END creates
foldable code blocks.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
xxxxxxxxxx
43
void draw(SkCanvas* canvas) {
// This fiddle draws 4 instances of a LinearGradient, demonstrating
// how the local matrix affects the gradient as well as the flag
// which controls unpremul vs premul color interpolation.
SkPaint strokePaint;
strokePaint.setStyle(SkPaint::kStroke_Style);
strokePaint.setColor(SK_ColorBLACK);
SkPaint p;
p.setStyle(SkPaint::kFill_Style);
SkColor transparentGreen = SkColorSetARGB(0, 0, 255, 255);
SkColor colors[] = { transparentGreen, SK_ColorBLUE, SK_ColorRED };
SkScalar positions[] = { 0.0, 0.65, 1.0 };
for (int i = 0; i < 4; i++) {
SkScalar blockX = (i % 2) * 100;
SkScalar blockY = (i / 2) * 100;
SkPoint pts[] = { {blockX, blockY}, {blockX + 50, blockY + 100} };
int flags = 0; // interpolate colors in unpremul
if (i % 2 == 1) {
// right column will have premul
flags = SkGradientShader::Flags::kInterpolateColorsInPremul_Flag;
}
SkMatrix matr = SkMatrix::I();
if (i / 2 == 1) {
// bottom row will be rotated 45 degrees.
matr.setRotate(45, blockX, blockY);
}
auto lgs = SkGradientShader::MakeLinear(
pts, colors, positions, 3, SkTileMode::kMirror,
flags, &matr);
p.setShader(lgs);
auto r = SkRect::MakeLTRB(blockX, blockY, blockX + 100, blockY + 100);
canvas->drawRect(r, p);
canvas->drawRect(r, strokePaint);
}
}
Compilation Warnings/Errors
Runtime Errors
Run Details
GL Version: OpenGL ES 3.0 SwiftShader 4.1.0.5 GL Vendor: Google Inc. GL Renderer: Google SwiftShader GL Extensions: GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_depth32 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_framebuffer_object GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_surfaceless_context GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_texture_3D GL_OES_vertex_array_object GL_OES_vertex_half_float GL_EXT_blend_minmax GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_draw_buffers GL_EXT_instanced_arrays GL_EXT_occlusion_query_boolean GL_EXT_read_format_bgra GL_EXT_texture_compression_dxt1 GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_ARB_texture_rectangle GL_ANGLE_framebuffer_blit GL_ANGLE_framebuffer_multisample GL_ANGLE_instanced_arrays GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_APPLE_texture_format_BGRA8888 GL_CHROMIUM_color_buffer_float_rgba GL_CHROMIUM_texture_filtering_hint GL_NV_depth_buffer_float2 GL_NV_fence GL_NV_framebuffer_blit GL_NV_read_depth GL_NV_read_depth_stencil GL_NV_read_stencil