mirror of
https://github.com/Kindelia/Kind2.git
synced 2024-09-17 10:59:12 +03:00
updated to use shapes
This commit is contained in:
parent
fbfa202a2e
commit
232e8b3bd5
@ -89,7 +89,8 @@ App.GG.when.click_element(local: App.GG.State.local, mouse: Pair<U32, U32>): IO<
|
||||
case local@phase as phase {
|
||||
setup:
|
||||
let {x, y} = {mouse@fst / 4, mouse@snd / 4}
|
||||
switch Point_to_rectangle({x,y}) {
|
||||
let point = V2.new(U32.to_f64(x), U32.to_f64(y))
|
||||
switch Shape.Point.collision.rectangle(point) {
|
||||
App.GG.when.table:
|
||||
let x = x - (App.GG.draw.chips_starting_position@fst - (App.GG.draw.chip_size@fst/2))
|
||||
let y = y - (App.GG.draw.chips_starting_position@snd - (App.GG.draw.chip_size@snd/2))
|
||||
@ -110,27 +111,18 @@ App.GG.when.click_element(local: App.GG.State.local, mouse: Pair<U32, U32>): IO<
|
||||
}
|
||||
|
||||
|
||||
type Rectangle {
|
||||
new(x1: U32, x2: U32, y1: U32, y2: U32)
|
||||
}
|
||||
|
||||
Point_to_rectangle(point: Pair<U32, U32>, rect: Rectangle): Bool
|
||||
let {x1, x2} = {rect@x1, rect@x2}
|
||||
let {y1, y2} = {rect@y1, rect@y2}
|
||||
let {px, py} = point
|
||||
(px >=? x1) &&
|
||||
(px <=? x2) &&
|
||||
(py >=? y1) &&
|
||||
(py <=? y2)
|
||||
|
||||
App.GG.when.table: Rectangle
|
||||
|
||||
|
||||
App.GG.when.table: Shape.Rectangle
|
||||
let {x1, y1} = {(App.GG.draw.chips_starting_position@fst - (App.GG.draw.chip_size@fst/2)) (App.GG.draw.chips_starting_position@snd - (App.GG.draw.chip_size@snd/2))}
|
||||
let {vx, vy} = App.GG.draw.chips_variation
|
||||
let {cx, cy} = App.GG.draw.chip_size
|
||||
let {r, c } = App.GG.draw.chips_line_size
|
||||
let {x2, y2} = {x1 + ((cx + vx) * r), y1 + ((cy + vy) * c)}
|
||||
log(U32.show(x1) | " " | U32.show(x2) | " " | U32.show(y1) | " " | U32.show(y2))
|
||||
Rectangle.new(x1, x2, y1, y2)
|
||||
Shape.Rectangle.new(U32.to_f64(x1), U32.to_f64(x2), U32.to_f64(y1), U32.to_f64(y2))
|
||||
|
||||
|
||||
App.GG.when.chip(mouse_pos: Pair<U32, U32>): Maybe<Nat>
|
||||
|
72
base/VoxBox/Draw/circle.kind
Normal file
72
base/VoxBox/Draw/circle.kind
Normal file
@ -0,0 +1,72 @@
|
||||
VoxBox.Draw.circle(
|
||||
xc: I32
|
||||
yc: I32
|
||||
r: I32
|
||||
z: I32,
|
||||
col: Col32,
|
||||
img: VoxBox,
|
||||
): VoxBox
|
||||
|
||||
let z = I32.to_u32(z)
|
||||
let x = +0#32
|
||||
let y = r
|
||||
log(I32.show(r))
|
||||
let d = +3#32 - (+2#32 * r)
|
||||
let img = VoxBox.Draw.circle.all_sides(xc, yc, x, y, z, col, img)
|
||||
VoxBox.Draw.circle.go(x, y, d, xc, yc, z, col, img)
|
||||
|
||||
VoxBox.Draw.circle.go(
|
||||
x: I32
|
||||
y: I32
|
||||
d: I32
|
||||
xc: I32
|
||||
yc: I32
|
||||
z: U32
|
||||
col: Col32
|
||||
img: VoxBox
|
||||
): VoxBox
|
||||
if y >=? x then
|
||||
let {y, d} =
|
||||
if d >? 0 then
|
||||
log(" D: " | I32.show(d) | " X: "| I32.show(x) | " Y: " |I32.show(y))
|
||||
let d = d + (4 * (x - y)) + 10
|
||||
let y = y - 1
|
||||
{y, d}
|
||||
else
|
||||
log(" D: " | I32.show(d) | " X: "| I32.show(x) | " Y: " |I32.show(y))
|
||||
let d = d + (4 * x) + 6
|
||||
{y, d}
|
||||
let x = x + 1
|
||||
let img = VoxBox.Draw.circle.all_sides(xc, yc, x, y, z, col, img)
|
||||
VoxBox.Draw.circle.go(x, y, d, xc, yc, z, col, img)
|
||||
else
|
||||
img
|
||||
|
||||
|
||||
|
||||
// Function to put pixels
|
||||
// at subsequence points
|
||||
// xc = center x, yc = center y
|
||||
VoxBox.Draw.circle.all_sides(
|
||||
xc: I32
|
||||
yc: I32
|
||||
x: I32
|
||||
y: I32
|
||||
z: U32
|
||||
col: Col32
|
||||
img: VoxBox
|
||||
): VoxBox
|
||||
let f =
|
||||
(a: I32, b: I32, z: U32)
|
||||
Pos32.new(I32.to_u32(a), I32.to_u32(b), z)
|
||||
let img =
|
||||
let img = VoxBox.push(f(xc+x, yc+y, z), col, img)
|
||||
let img = VoxBox.push(f(xc-x, yc+y, z), col, img)
|
||||
let img = VoxBox.push(f(xc+x, yc-y, z), col, img)
|
||||
let img = VoxBox.push(f(xc-x, yc-y, z), col, img)
|
||||
let img = VoxBox.push(f(xc+y, yc+x, z), col, img)
|
||||
let img = VoxBox.push(f(xc-y, yc+x, z), col, img)
|
||||
let img = VoxBox.push(f(xc+y, yc-x, z), col, img)
|
||||
let img = VoxBox.push(f(xc-y, yc-x, z), col, img)
|
||||
img
|
||||
img
|
Loading…
Reference in New Issue
Block a user