19928/jj_vitp/Interface/widgets/other_widgets/star.e

84 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2024-06-17 07:09:33 +00:00
note
description: "[
A star widget
]"
author: "Jimmy J. Johnson"
class
STAR
inherit
FONT_AND_COLOR_CONSTANTS
undefine
default_create
end
EV_MODEL_POLYGON
redefine
default_create
end
create
default_create
feature {NONE} -- Initialization
default_create
-- Create an intance
do
Precursor {EV_MODEL_POLYGON}
build_widgets
end
build_widgets
-- Create the widget
local
d: REAL_64 -- the diameter of a circle that fits in box
r: REAL_64 -- the radius of above circle
r_small: REAL_64 -- the radius of a smaller circle
a: REAL_64 -- the current angle around a circle
delta_a: REAL_64 -- the amount to change `ang' as we go around circle
i: INTEGER
ax, ay: REAL_64
p: EV_COORDINATE
do
d := 200
r := d / 2.0
r_small := r / 3.0
delta_a := (2.0 * Pi) / (points_on_star_count * 2.0)
a := 0
from i := 1
until i > points_on_star_count * 2
loop
if i \\ 2 = 1 then
ax := delta_x (a, r_small)
ay := delta_y (a, r_small)
else
ax := delta_x (a, r)
ay := delta_y (a, r)
end
create p.make_precise (ax, ay)
extend_point (p)
a := a + delta_a
i := i + 1
end
-- Rotate star and move it to the center of its system.
rotate (0.3)
set_background_color (White)
set_foreground_color (White)
end
feature -- Basic operations
feature {NONE} -- Implementation
points_on_star_count: INTEGER = 5
-- The number of points the star has
invariant
end