11use crate :: {
22 consts:: {
3- CIRCLE_TOLERANCE , GRID_CELL_H , GRID_CELL_W , GRID_SIZE_X , GRID_SIZE_Y , SCREEN_H , SCREEN_W ,
4- VECTOR_SCALE , VECTOR_WIDTH ,
3+ GRID_CELL_H , GRID_CELL_W , GRID_SIZE_X , GRID_SIZE_Y , SCREEN_H , SCREEN_W , VECTOR_SCALE ,
54 } ,
65 visualizer:: { Visualizer , VisualizerParams } ,
76} ;
8- use ggez:: {
9- graphics:: { Color , DrawMode , Mesh , MeshBuilder } ,
10- Context ,
11- } ;
127use log:: info;
8+ use macroquad:: prelude:: * ;
139use svg:: node:: element;
1410
1511type Point2 < T > = [ T ; 2 ] ;
@@ -91,31 +87,10 @@ impl Visualizer for Circles {
9187 }
9288 }
9389
94- fn build_mesh ( & self , ctx : & mut Context ) -> Option < Mesh > {
95- let mut circle_mesh_builder = MeshBuilder :: new ( ) ;
96- let color = Color :: new ( 1.0 , 1.0 , 1.0 , 1.0 ) ;
97-
98- for circle in self . circles . iter ( ) {
99- let [ x, y] = circle. location ;
100-
101- circle_mesh_builder
102- . circle (
103- DrawMode :: stroke ( VECTOR_WIDTH as f32 ) ,
104- [ x as f32 , y as f32 ] ,
105- circle. radius as f32 ,
106- CIRCLE_TOLERANCE ,
107- color,
108- )
109- . unwrap ( ) ;
110- }
111-
112- circle_mesh_builder. build ( ctx) . ok ( )
113- }
114-
11590 fn build_svg_document_from_state ( & self ) -> svg:: Document {
11691 let doc = svg:: Document :: new ( ) . set ( "viewBox" , ( 0 , 0 , SCREEN_W , SCREEN_H ) ) ;
11792
118- let mut group = svg :: node :: element:: Group :: new ( )
93+ let mut group = element:: Group :: new ( )
11994 . set ( "fill" , "none" )
12095 . set ( "stroke" , "black" )
12196 . set ( "stroke-width" , "0.3mm" ) ;
@@ -132,7 +107,7 @@ impl Visualizer for Circles {
132107 group = group. add ( path) ;
133108 }
134109
135- let bounding_rect = svg :: node :: element:: Rectangle :: new ( )
110+ let bounding_rect = element:: Rectangle :: new ( )
136111 . set ( "width" , SCREEN_W )
137112 . set ( "height" , SCREEN_H )
138113 . set ( "fill" , "none" )
@@ -141,4 +116,12 @@ impl Visualizer for Circles {
141116
142117 doc. add ( group) . add ( bounding_rect)
143118 }
119+
120+ fn render ( & self ) {
121+ for circle in self . circles . iter ( ) {
122+ let [ x, y] = circle. location ;
123+
124+ draw_circle ( x as f32 , y as f32 , circle. radius as f32 , WHITE ) ;
125+ }
126+ }
144127}
0 commit comments