local draw = jupiter.draw local Vec2 = jupiter.Vec2

draw.line( x1, y1, x2, y2, color (u32), thickness (float) ) draw.rect( x1, y1, x2, y2, color (u32), thickness (float) )

draw.rect_filled( x1, y1, x2, y2, color (u32), rounding (float) )

draw.push_clip_rect( x1, y1, x2, y2, intersect ) draw.pop_clip_rect() draw.vertex_count()

draw.gradient( vert_start, vert_end, min (Vec2), max (Vec2), color1 (u32), color2 (u32) )

draw.rotate( vert_start, vert_end, rad, center ) draw.rotation_center( vert_start, vert_end )

Example (rotating crosshair with rainbow gradient):

jupiter.draw

Methods:

local enabled = true

local primary = jupiter.RainbowState.new(3, 0xff0000ff) local secondary = jupiter.RainbowState.new(3, 0x00ff00ff)

local rot = 0.0

function crosshair()

vert_start = jupiter.draw.vertex_count() primary:update() secondary:update()

local thickness = 3.0 local size = jupiter.display.width() * 0.005 local centerx = jupiter.display.width() * 0.5 local centery = jupiter.display.height() * 0.5

jupiter.draw.line(centerx - size, centery, centerx + size, centery, 0xffffffff, thickness) jupiter.draw.line(centerx, centery - size, centerx, centery + size, 0xffffffff, thickness)

vert_end = jupiter.draw.vertex_count() jupiter.draw.gradient(

vert_start, vert_end, -- vert range

jupiter.Vec2.new(centerx - size, centery - size), -- min jupiter.Vec2.new(centerx + size, centery + size), -- max

primary:color(), secondary:color()

)

jupiter.draw.rotate(vert_start, vert_end, 0.01 * rot, jupiter.draw.rotation_center(vert_start, vert_end))

rot = rot + 1.0

end

function on_render()

if jupiter.utility.is_key_pressed("t", false) then

enabled = not enabled

end if enabled then

crosshair()

end

end

jupiter.register_callback("render", on_render) local notif = jupiter.Notification.new() notif:set_title("Installed crosshair example")

notif:set_content("author: index\ndescription: lua crosshair example")

notif:push()

jupiter.draw.line(centerx, centery - size + (thickness * 0.5), centerx + size, centery - size + (thickness * 0.5), 0xffffffff, thickness) jupiter.draw.line(centerx + size - (thickness * 0.5), centery, centerx + size - (thickness * 0.5), centery + size, 0xffffffff, thickness) jupiter.draw.line(centerx, centery + size - (thickness * 0.5), centerx - size, centery + size - (thickness * 0.5), 0xffffffff, thickness) jupiter.draw.line(centerx - size + (thickness * 0.5), centery - size, centerx - size + (thickness * 0.5), centery, 0xffffffff, thickness)

© Copyright 2023. All rights reserved.