Here is an example written in Python. You should be able to convert it to C code pretty easily.

```
##### startup script #####
#!/opt/bin/lv_micropython -i
import lvgl as lv
import display_driver
import math
##### main script #####
CANVAS_WIDTH = 420
CANVAS_HEIGHT = 320
LV_COLOR_SIZE = 32
#
# Draw a line to the canvas
#
# Create a buffer for the canvas
cbuf = bytearray((LV_COLOR_SIZE // 8) * CANVAS_WIDTH * CANVAS_HEIGHT)
# Create a canvas and initialize its palette
canvas = lv.canvas(lv.scr_act())
canvas.set_buffer(cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, lv.COLOR_FORMAT.NATIVE)
canvas.fill_bg(lv.color_hex3(0xccc), lv.OPA.COVER)
canvas.center()
ldsc1 = lv.draw_line_dsc_t()
ldsc1.init()
ldsc1.color = lv.palette_main(lv.PALETTE.RED)
ldsc1.width = 10
ldsc1.round_end = 0
ldsc1.round_start = 0
ldsc1.p1.x = 50;
ldsc1.p1.y = 50;
ldsc1.p2.x = 100;
ldsc1.p2.y = 100;
ldsc2 = lv.draw_line_dsc_t()
ldsc2.init()
ldsc2.color = lv.palette_main(lv.PALETTE.RED)
ldsc2.width = 10
ldsc2.round_end = 0
ldsc2.round_start = 0
ldsc2.p1.x = 150;
ldsc2.p1.y = 75;
ldsc2.p2.x = 100;
ldsc2.p2.y = 100;
layer = lv.layer_t()
canvas.init_layer(layer);
lv.draw_line(layer, ldsc1)
lv.draw_line(layer, ldsc2)
p1 = lv.point_t()
def _get_angle(x1, y1, x2, y2):
return math.degrees(math.atan2(y1 - y2, x1 - x2))
def _point_on_circle(degree, center_x, center_y, radius):
radians = math.radians(degree)
x = int(round(center_x + (radius * math.cos(radians))))
y = int(round(center_y + (radius * math.sin(radians))))
p = lv.point_t()
p.x = x
p.y = y
return p
if ldsc2.p1.x == ldsc1.p1.x and ldsc2.p1.y == ldsc1.p1.y:
p1.x = ldsc2.p1.x
p1.y = ldsc2.p1.y
angle1 = _get_angle(p1.x, p1.y, ldsc1.p2.x, ldsc1.p2.y)
angle2 = _get_angle(p1.x, p1.y, ldsc2.p2.x, ldsc2.p2.y)
elif ldsc2.p2.x == ldsc1.p2.x and ldsc2.p2.y == ldsc1.p2.y:
p1.x = ldsc2.p2.x
p1.y = ldsc2.p2.y
angle1 = _get_angle(p1.x, p1.y, ldsc1.p1.x, ldsc1.p1.y)
angle2 = _get_angle(p1.x, p1.y, ldsc2.p1.x, ldsc2.p1.y)
elif ldsc2.p2.x == ldsc1.p1.x and ldsc2.p2.y == ldsc1.p1.y:
p1.x = ldsc2.p2.x
p1.y = ldsc2.p2.y
angle1 = _get_angle(p1.x, p1.y, ldsc1.p2.x, ldsc1.p2.y)
angle2 = _get_angle(p1.x, p1.y, ldsc2.p1.x, ldsc2.p1.y)
else:
raise RuntimeError('no matching ends')
angle_dif = angle2 - angle1
print(angle_dif)
radius1 = ldsc1.width / 2
radius2 = ldsc2.width / 2
# this is to make an adjustment caused by floating point math.
if angle_dif == 90:
radius1 += 2
radius2 += 2
elif angle_dif > 90:
radius2 += 1
p2 = _point_on_circle(angle1 + 90, p1.x, p1.y, radius1)
p3 = _point_on_circle(angle2 - 90, p1.x, p1.y, radius2)
print(p2.x, p2.y)
print(p3.x, p3.y)
tdsc = lv.draw_triangle_dsc_t()
tdsc.init()
tdsc.p = [p1, p2, p3]
tdsc.bg_color = lv.palette_main(lv.PALETTE.RED)
tdsc.bg_opa = lv.OPA.COVER
lv.draw_triangle(layer, tdsc)
canvas.finish_layer(layer)
```

This is using version 9.0 so if you are using version 8.x then you will need to make some code changes to make it work.

You can paste the code above into the simulator. Here is a link to the simulator, just overwrite the code in it and press the “restart” button at the top

https://sim.lvgl.io/v9.0/micropython/ports/javascript/index.html

You will have to tweak the code so it will support both positive and negative angles but that shouldn’t be that hard to do.