@@ -107,6 +107,7 @@ func _enter_tree() -> void:
107107 checkerboard .expand_mode = TextureRect .EXPAND_IGNORE_SIZE
108108 checkerboard .stretch_mode = TextureRect .STRETCH_TILE
109109 checkerboard .texture_filter = TEXTURE_FILTER_NEAREST
110+ checkerboard .clip_contents = true
110111 var zoom_shader_material := ShaderMaterial .new ()
111112 zoom_shader_material .shader = preload ("res://src/shaders/zoom_shader.gdshader" )
112113 checkerboard .material = zoom_shader_material
@@ -188,7 +189,7 @@ func _texture_update() -> void:
188189 var image_zoom := 1.0 if view_rasterized and camera_zoom > 1.0 else camera_zoom
189190 var pixel_size := 1 / image_zoom
190191
191- # Translate to canvas coords .
192+ # Expand by pixel_size * 2 so external colors can affect it .
192193 var display_rect := texture_view_rect .grow (pixel_size * 2 )
193194 display_rect .position = display_rect .position .snapped (Vector2 (pixel_size , pixel_size )).maxf (0.0 )
194195 display_rect .size = display_rect .size .snapped (Vector2 (pixel_size , pixel_size ))
@@ -199,14 +200,14 @@ func _texture_update() -> void:
199200 if cached_inner_markup .is_empty ():
200201 cached_inner_markup = SVGParser .get_inner_markup_with_percentages_converted (root_element )
201202
203+ # Translate to canvas coords.
202204 var svg_text := SVGParser .root_cutout_to_markup (root_element , display_rect .size ,
203205 Rect2 (root_element .world_to_canvas (display_rect .position ),
204206 display_rect .size / root_element .canvas_transform .get_scale ()), cached_inner_markup )
205207
206208 # TODO Necessary workaround to Godot ignoring position changes below a treshold.
207209 display_texture .position = Vector2 (NAN , NAN )
208210 display_texture .position = display_rect .position
209-
210211 display_texture .size = display_rect .size
211212 display_texture .texture = DPITexture .create_from_string (svg_text , image_zoom )
212213
@@ -307,8 +308,11 @@ func set_zoom(new_zoom: float, offset := Vector2(0.5, 0.5)) -> void:
307308
308309# Top left corner.
309310func set_view (new_center : Vector2 ) -> void :
310- camera_center = new_center .clamp (limit_top_left , limit_bottom_right )
311+ new_center = new_center .clamp (limit_top_left , limit_bottom_right )
312+ if new_center == camera_center :
313+ return
311314
315+ camera_center = new_center
312316 var stripped_left := maxf (camera_center .x - size .x / camera_zoom / 2.0 , 0.0 )
313317 var stripped_top := maxf (camera_center .y - size .y / camera_zoom / 2.0 , 0.0 )
314318 var stripped_right := minf (camera_center .x + size .x / camera_zoom / 2.0 , root_element .width )
0 commit comments