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

Function pattern

test/test.cpp:963–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

961}
962
963void pattern( canvas &that, float width, float height )
964{
965 unsigned char checker[ 256 ];
966 for ( int index = 0; index < 256; ++index )
967 checker[ index ] = static_cast< unsigned char >(
968 ( ( ( index >> 2 & 1 ) ^ ( index >> 5 & 1 ) ) |
969 ( ( index & 3 ) == 3 ) ) * 255 );
970 that.arc( 0.5f * width, 0.5f * height, 32.0f, 0.0f, 6.28318531f );
971 that.close_path();
972 that.set_line_width( 20.0f );
973 that.set_color( stroke_style, 0.0f, 0.0f, 0.0f, 1.0f );
974 that.set_pattern( stroke_style, 0, 8, 8, 32, repeat );
975 that.stroke();
976 that.set_line_width( 16.0f );
977 that.set_pattern( stroke_style, checker, 8, 8, 32, repeat );
978 that.stroke();
979 for ( float scale = 8.0f; scale >= 1.0f; scale /= 2.0f )
980 {
981 that.set_transform( 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f );
982 that.scale( scale, scale );
983 float size_x = 0.5f * width / scale;
984 float size_y = 0.5f * height / scale;
985 that.set_pattern( fill_style, checker, 8, 8, 32, no_repeat );
986 that.fill_rectangle( 0.0f, 0.0f, size_x, size_y );
987 that.set_pattern( fill_style, checker, 8, 8, 32, repeat_x );
988 that.fill_rectangle( size_x, 0.0f, size_x, size_y );
989 that.set_pattern( fill_style, checker, 8, 8, 32, repeat_y );
990 that.fill_rectangle( 0.0f, size_y, size_x, size_y );
991 that.set_pattern( fill_style, checker, 8, 8, 32, repeat );
992 that.fill_rectangle( size_x, size_y, size_x, size_y );
993 }
994}
995
996void begin_path( canvas &that, float width, float height )
997{

Callers

nothing calls this directly

Calls 9

arcMethod · 0.80
close_pathMethod · 0.80
set_line_widthMethod · 0.80
set_colorMethod · 0.80
set_patternMethod · 0.80
strokeMethod · 0.80
set_transformMethod · 0.80
scaleMethod · 0.80
fill_rectangleMethod · 0.80

Tested by

no test coverage detected