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

Function example_illusion

test/test.cpp:2047–2076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2045}
2046
2047void example_illusion( canvas &that, float width, float height )
2048{
2049 that.set_color( fill_style, 0.0f, 0.4f, 1.0f, 1.0f );
2050 that.fill_rectangle( 0.0f, 0.0f, width, height );
2051 that.set_color( fill_style, 0.8f, 0.8f, 0.0f, 1.0f );
2052 that.set_line_width( 0.4f );
2053 for ( float spot = 0.0f; spot < 240.0f; spot += 1.0f )
2054 {
2055 float angle = fmodf( spot * 0.61803398875f, 1.0f ) * 6.28318531f;
2056 float radius = spot / 240.0f * 0.5f * hypotf( width, height );
2057 float size = min( width, height ) * sqrtf( spot ) / 240.0f;
2058 that.set_transform( 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f );
2059 that.translate( 0.5f * width + radius * cosf( angle ),
2060 0.5f * height + radius * sinf( angle ) );
2061 that.rotate( angle - 1.3f );
2062 that.scale( 0.8f * size, 0.6f * size );
2063 that.rotate( 1.3f );
2064 that.begin_path();
2065 that.arc( 0.0f, 0.0f, 1.0f, 0.0f, 6.28318531f );
2066 that.fill();
2067 that.begin_path();
2068 that.arc( 0.0f, 0.0f, 1.0f, 0.0f, 3.14159265f );
2069 that.set_color( stroke_style, 1.0f, 1.0f, 1.0f, 1.0f );
2070 that.stroke();
2071 that.begin_path();
2072 that.arc( 0.0f, 0.0f, 1.0f, 3.14159265f, 6.28318531f );
2073 that.set_color( stroke_style, 0.0f, 0.0f, 0.0f, 1.0f );
2074 that.stroke();
2075 }
2076}
2077
2078void example_star( canvas &that, float width, float height )
2079{

Callers

nothing calls this directly

Calls 11

set_colorMethod · 0.80
fill_rectangleMethod · 0.80
set_line_widthMethod · 0.80
set_transformMethod · 0.80
translateMethod · 0.80
rotateMethod · 0.80
scaleMethod · 0.80
begin_pathMethod · 0.80
arcMethod · 0.80
fillMethod · 0.80
strokeMethod · 0.80

Tested by

no test coverage detected