Skip to content

Commit

Permalink
ui: add missing ui/rectangle.v
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Dec 22, 2023
1 parent c0db5b1 commit f86dc44
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions ui/rectangle.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright(C) 2022 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module ui

import shy.lib as shy

@[heap]
pub struct Rectangle {
Item
pub mut:
// extra parts
stroke shy.Stroke
radius f32 // rounded corner radius. 0 = none
color shy.Color = shy.colors.shy.red
fills shy.Fill = .body | .stroke
}

// draw draws the `Rectangle` and/or any child nodes.
pub fn (mut r Rectangle) draw() {
vs := r.visual_state()
er := r.ui.easy.rect(
x: vs.x
y: vs.y
width: vs.width
height: vs.height
rotation: vs.rotation
scale: vs.scale
offset: vs.offset
origin: vs.origin
// easy rect config
stroke: r.stroke
radius: r.radius
color: r.color
fills: r.fills
)
er.draw()
// Draw rest of tree (children) on top
r.Item.draw()
}

0 comments on commit f86dc44

Please sign in to comment.