pull/2/head
jaysunxiao 2022-07-06 17:16:25 +08:00
parent 91a3583e5b
commit 8ee59ef450
2 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,5 @@
# 1. CanvasItem之draw和update
![Image text](image/canvas1.png) ![Image text](image/canvas1.png)
![Image text](image/canvas2.png) ![Image text](image/canvas2.png)
![Image text](image/canvas3.png) ![Image text](image/canvas3.png)

View File

@ -19,16 +19,31 @@ var colorArray: PoolColorArray = PoolColorArray([Color(1,1,1,1),Color(1,1,1,1),C
# For Draw_String # For Draw_String
var dynamic_font = DynamicFont.new() var dynamic_font = DynamicFont.new()
var texture: Texture = null
func _ready() -> void: func _ready() -> void:
# For Draw_String # For Draw_String
dynamic_font.font_data = load("res://scene/demo09_canvas/BarlowCondensed-Bold.ttf") dynamic_font.font_data = load("res://scene/demo09_canvas/BarlowCondensed-Bold.ttf")
dynamic_font.size = 64 dynamic_font.size = 64
texture = load("res://icon.png")
var count = 0
func _draw() -> void: func _draw() -> void:
print("start drawing")
draw_circle(Vector2(100,100), circleRadius, whiteColor) draw_circle(Vector2(100,100), circleRadius, whiteColor)
draw_line(Vector2(0,0),Vector2(100,100),whiteColor) draw_line(Vector2(0,0),Vector2(100,100),whiteColor)
draw_multiline(multiLine, whiteColor) draw_multiline(multiLine, whiteColor)
draw_rect(rect, whiteColor, false) # filled is false draw_rect(rect, whiteColor, false) # filled is false
draw_primitive(pointsArray,colorArray, pointsArray) draw_primitive(pointsArray,colorArray, pointsArray)
draw_string(dynamic_font, Vector2(600,500), 'I draw good!') draw_string(dynamic_font, Vector2(600,500), 'I draw good!')
if count >= 90:
draw_texture(texture, Vector2(400,400))
# For Draw_String # For Draw_String
func _process(delta):
count += 1
if count == 90:
# draw_texture(texture, Vector2(400,400))
update()