MCPcopy Create free account
hub / github.com/a-e-k/canvas_ity / example_smiley

Function example_smiley

test/test.cpp:1909–1950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1907}
1908
1909void example_smiley( canvas &that, float width, float height )
1910{
1911 float center_x = 0.5f * width;
1912 float center_y = 0.5f * height;
1913 float radius = min( width, height ) * 0.4f;
1914 that.set_radial_gradient( fill_style,
1915 center_x, center_y, 0.0f,
1916 center_x, center_y, radius );
1917 that.add_color_stop( fill_style, 0.0f, 1.0f, 0.9f, 0.2f, 1.0f );
1918 that.add_color_stop( fill_style, 0.95f, 0.95f, 0.65f, 0.15f, 1.0f );
1919 that.add_color_stop( fill_style, 1.0f, 0.9f, 0.55f, 0.0f, 1.0f );
1920 that.arc( center_x, center_y, radius, 0.0f, 6.28318531f );
1921 that.fill();
1922 that.set_linear_gradient( fill_style,
1923 center_x, center_y - 0.95f * radius,
1924 center_x, center_y );
1925 that.add_color_stop( fill_style, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f );
1926 that.add_color_stop( fill_style, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f );
1927 that.begin_path();
1928 that.arc( center_x, center_y - 0.15f * radius, 0.8f * radius,
1929 0.0f, 6.28318531f );
1930 that.fill();
1931 that.set_color( stroke_style, 0.0f, 0.0f, 0.0f, 0.95f );
1932 that.set_line_width( 0.2f * radius );
1933 that.line_cap = circle;
1934 that.begin_path();
1935 that.move_to( center_x - 0.2f * radius, center_y - 0.5f * radius );
1936 that.line_to( center_x - 0.2f * radius, center_y - 0.2f * radius );
1937 that.move_to( center_x + 0.2f * radius, center_y - 0.5f * radius );
1938 that.line_to( center_x + 0.2f * radius, center_y - 0.2f * radius );
1939 that.stroke();
1940 that.set_color( fill_style, 0.0f, 0.0f, 0.0f, 0.95f );
1941 that.begin_path();
1942 that.move_to( center_x - 0.6f * radius, center_y + 0.1f * radius );
1943 that.bezier_curve_to( center_x - 0.3f * radius, center_y + 0.8f * radius,
1944 center_x + 0.3f * radius, center_y + 0.8f * radius,
1945 center_x + 0.6f * radius, center_y + 0.1f * radius);
1946 that.bezier_curve_to( center_x + 0.3f * radius, center_y + 0.3f * radius,
1947 center_x - 0.3f * radius, center_y + 0.3f * radius,
1948 center_x - 0.6f * radius, center_y + 0.1f * radius);
1949 that.fill();
1950}
1951
1952void example_knot( canvas &that, float width, float height )
1953{

Callers

nothing calls this directly

Calls 12

set_radial_gradientMethod · 0.80
add_color_stopMethod · 0.80
arcMethod · 0.80
fillMethod · 0.80
set_linear_gradientMethod · 0.80
begin_pathMethod · 0.80
set_colorMethod · 0.80
set_line_widthMethod · 0.80
move_toMethod · 0.80
line_toMethod · 0.80
strokeMethod · 0.80
bezier_curve_toMethod · 0.80

Tested by

no test coverage detected