This commit is contained in:
Jocelyn Fiat
2024-06-17 09:09:33 +02:00
commit 6dde6425c2
560 changed files with 81728 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
note
description: "[
A widget drawn as an anchor.
]"
author: "Jimmy J. Johnson"
class
ANCHOR
inherit
EV_MODEL_POLYGON
redefine
default_create
end
create
default_create
feature {NONE} -- Initialization
default_create
-- Create an intance
do
Precursor {EV_MODEL_POLYGON}
extend_point (create {EV_COORDINATE}.make_precise (0, 0))
extend_point (create {EV_COORDINATE}.make_precise (-2.2222222222222285, -1.3333333333333286))
extend_point (create {EV_COORDINATE}.make_precise (-4, -5.7777777777777857))
extend_point (create {EV_COORDINATE}.make_precise (-3.5555555555555571, -9.3333333333333286))
extend_point (create {EV_COORDINATE}.make_precise (-1.3333333333333286, -12))
extend_point (create {EV_COORDINATE}.make_precise (2.6666666666666714, -13.777777777777786))
extend_point (create {EV_COORDINATE}.make_precise (7.5555555555555571, -14.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (11.1111111111111, -13.333333333333329))
extend_point (create {EV_COORDINATE}.make_precise (13.777777777777771, -9.3333333333333286))
extend_point (create {EV_COORDINATE}.make_precise (14.666666666666671, -4.8888888888888857))
extend_point (create {EV_COORDINATE}.make_precise (11.358024691358025, 0.52674897119338482))
extend_point (create {EV_COORDINATE}.make_precise (43.999999999999986, 0.44444444444444287))
extend_point (create {EV_COORDINATE}.make_precise (44.806584362139901, -1.1851851851851904))
extend_point (create {EV_COORDINATE}.make_precise (45.59670781893, 0.39506172839504927))
extend_point (create {EV_COORDINATE}.make_precise (48.625514403292172, 0.79012345679011275))
extend_point (create {EV_COORDINATE}.make_precise (48.8888888888889, 4.4444444444444429))
extend_point (create {EV_COORDINATE}.make_precise (45.860082304526699, 4.7407407407407334))
extend_point (create {EV_COORDINATE}.make_precise (44.938271604938265, 6.3209876543209731))
extend_point (create {EV_COORDINATE}.make_precise (44.279835390946474, 4.4773662551440196))
extend_point (create {EV_COORDINATE}.make_precise (8.5925925925925952, 4.7407407407407334))
extend_point (create {EV_COORDINATE}.make_precise (9.5144032921810577, 95.736625514403258))
extend_point (create {EV_COORDINATE}.make_precise (14.650205761316855, 102.18930041152258))
extend_point (create {EV_COORDINATE}.make_precise (20.31275720164605, 101.53086419753082))
extend_point (create {EV_COORDINATE}.make_precise (24.444444444444443, 99.999999999999986))
extend_point (create {EV_COORDINATE}.make_precise (29.333333333333329, 96.888888888888872))
extend_point (create {EV_COORDINATE}.make_precise (34.666666666666671, 93.777777777777786))
extend_point (create {EV_COORDINATE}.make_precise (38.222222222222214, 90.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (42.222222222222214, 86.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (46.222222222222214, 81.777777777777786))
extend_point (create {EV_COORDINATE}.make_precise (49.777777777777757, 76.444444444444443))
extend_point (create {EV_COORDINATE}.make_precise (51.522633744855952, 71.901234567901199))
extend_point (create {EV_COORDINATE}.make_precise (52.312757201646022, 68.082304526748928))
extend_point (create {EV_COORDINATE}.make_precise (52.971193415637813, 65.448559670781847))
extend_point (create {EV_COORDINATE}.make_precise (52.8888888888889, 63.1111111111111))
extend_point (create {EV_COORDINATE}.make_precise (50.666666666666671, 63.999999999999986))
extend_point (create {EV_COORDINATE}.make_precise (54.02469135802464, 60.444444444444443))
extend_point (create {EV_COORDINATE}.make_precise (55.341563786008223, 57.283950617283935))
extend_point (create {EV_COORDINATE}.make_precise (55.999999999999986, 53.333333333333329))
extend_point (create {EV_COORDINATE}.make_precise (57.580246913580211, 58.864197530864161))
extend_point (create {EV_COORDINATE}.make_precise (57.185185185185148, 62.814814814814795))
extend_point (create {EV_COORDINATE}.make_precise (56.444444444444443, 67.999999999999986))
extend_point (create {EV_COORDINATE}.make_precise (55.555555555555557, 72.444444444444443))
extend_point (create {EV_COORDINATE}.make_precise (53.777777777777757, 76.888888888888872))
extend_point (create {EV_COORDINATE}.make_precise (50.995884773662524, 82.041152263374428))
extend_point (create {EV_COORDINATE}.make_precise (47.308641975308618, 86.386831275720127))
extend_point (create {EV_COORDINATE}.make_precise (43.555555555555557, 90.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (39.999999999999986, 94.222222222222186))
extend_point (create {EV_COORDINATE}.make_precise (33.777777777777757, 99.1111111111111))
extend_point (create {EV_COORDINATE}.make_precise (29.92592592592591, 102.05761316872425))
extend_point (create {EV_COORDINATE}.make_precise (24.395061728395049, 104.82304526748966))
extend_point (create {EV_COORDINATE}.make_precise (18.469135802469125, 106.79835390946495))
extend_point (create {EV_COORDINATE}.make_precise (13.728395061728392, 108.5102880658436))
extend_point (create {EV_COORDINATE}.make_precise (9.9094650205761212, 111.67078189300408))
extend_point (create {EV_COORDINATE}.make_precise (7.6707818930040759, 114.56790123456786))
extend_point (create {EV_COORDINATE}.make_precise (4.8888888888888999, 118.22222222222219))
extend_point (create {EV_COORDINATE}.make_precise (3.1111111111111001, 114.66666666666664))
extend_point (create {EV_COORDINATE}.make_precise (0.44444444444444287, 111.55555555555553))
extend_point (create {EV_COORDINATE}.make_precise (-3.1111111111111001, 108.88888888888887))
extend_point (create {EV_COORDINATE}.make_precise (-8.4444444444444429, 107.1111111111111))
extend_point (create {EV_COORDINATE}.make_precise (-16, 103.99999999999999))
extend_point (create {EV_COORDINATE}.make_precise (-21.777777777777771, 101.33333333333333))
extend_point (create {EV_COORDINATE}.make_precise (-26.222222222222214, 97.777777777777786))
extend_point (create {EV_COORDINATE}.make_precise (-31.1111111111111, 93.777777777777786))
extend_point (create {EV_COORDINATE}.make_precise (-34.666666666666671, 90.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (-38.222222222222214, 85.333333333333329))
extend_point (create {EV_COORDINATE}.make_precise (-40.444444444444443, 82.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (-43.1111111111111, 77.333333333333329))
extend_point (create {EV_COORDINATE}.make_precise (-44.888888888888886, 72.888888888888872))
extend_point (create {EV_COORDINATE}.make_precise (-46.666666666666671, 67.1111111111111))
extend_point (create {EV_COORDINATE}.make_precise (-47.55555555555555, 61.333333333333329))
extend_point (create {EV_COORDINATE}.make_precise (-46.666666666666671, 55.1111111111111))
extend_point (create {EV_COORDINATE}.make_precise (-44.872427983539112, 60.31275720164605))
extend_point (create {EV_COORDINATE}.make_precise (-43.160493827160508, 63.604938271604922))
extend_point (create {EV_COORDINATE}.make_precise (-40.444444444444443, 66.666666666666643))
extend_point (create {EV_COORDINATE}.make_precise (-43.423868312757222, 66.370370370370338))
extend_point (create {EV_COORDINATE}.make_precise (-41.448559670781904, 73.481481481481481))
extend_point (create {EV_COORDINATE}.make_precise (-38.666666666666671, 78.666666666666643))
extend_point (create {EV_COORDINATE}.make_precise (-36.181069958847743, 82.567901234567856))
extend_point (create {EV_COORDINATE}.make_precise (-32.888888888888886, 86.666666666666643))
extend_point (create {EV_COORDINATE}.make_precise (-29.333333333333329, 90.222222222222214))
extend_point (create {EV_COORDINATE}.make_precise (-24.8888888888889, 94.666666666666643))
extend_point (create {EV_COORDINATE}.make_precise (-20.444444444444443, 97.333333333333329))
extend_point (create {EV_COORDINATE}.make_precise (-15.555555555555557, 99.999999999999986))
extend_point (create {EV_COORDINATE}.make_precise (-10.222222222222229, 101.77777777777779))
extend_point (create {EV_COORDINATE}.make_precise (-4.8888888888888999, 103.55555555555553))
extend_point (create {EV_COORDINATE}.make_precise (1.3333333333333286, 95.999999999999986))
extend_point (create {EV_COORDINATE}.make_precise (1.744855967078152, 5.0041152263374471))
extend_point (create {EV_COORDINATE}.make_precise (-34.469135802469154, 5.0041152263374471))
extend_point (create {EV_COORDINATE}.make_precise (-35.52263374485598, 6.7160493827160366))
extend_point (create {EV_COORDINATE}.make_precise (-36.181069958847743, 4.8724279835390831))
extend_point (create {EV_COORDINATE}.make_precise (-39.1111111111111, 4.8888888888888857))
extend_point (create {EV_COORDINATE}.make_precise (-39.1111111111111, 1.3333333333333286))
extend_point (create {EV_COORDINATE}.make_precise (-36.312757201646107, 0.52674897119338482))
extend_point (create {EV_COORDINATE}.make_precise (-35.654320987654316, -1.0534979423868407))
extend_point (create {EV_COORDINATE}.make_precise (-34.600823045267518, 0.79012345679011275))
end
end

View File

@@ -0,0 +1,177 @@
note
description: "[
An arrow widget
]"
author: "Jimmy J. Johnson"
class
ARROW
inherit
VITP_WIDGET
redefine
default_create,
target_imp,
build_widgets,
paint
end
create
default_create
feature {NONE} -- Initialization
default_create
-- Initialize attributes
do
-- create head_dot
create nock
create shaft
create head
Precursor {VITP_WIDGET}
end
build_widgets
-- Create the widgets that make up Current
local
t: EV_MODEL_TRANSFORMATION
do
-- Use the `dot' as reference point to build the arrow (the center of the nock).
-- The EV_MODEL_DOT and EV_MODEL_LINE do not scale nicely, so use circle and
-- rectangle to build the parts of the arrow.
create t.make_zero
t.translate (width // 2, 0)
dot.transform (t)
direction := North
build_nock
build_shaft
build_head
end
build_nock
-- Create the end of the arrow opposite the head
-- A circle slightly bigger than the shaft, centered on `dot'
local
p1, p2: EV_COORDINATE
r: INTEGER
do
r := (width // 2) + (width // 4)
create p1.make_precise (dot.x - r, dot.y - r)
create p2.make_precise (dot.x + r, dot.y + r)
create nock.make_with_points (p1, p2)
extend (nock)
end
build_shaft
-- Create the shaft as a rectangle `width' wide with an arrow on the
-- end. Assume the arrow tip ends `Default_length' away from `dot'.
local
p: EV_COORDINATE
len, wid: INTEGER
do
io.put_string ("ARROW.build_shaft -- fix me! Add a pointed tip. %N")
len := length
wid := width // 2
create shaft
create p.make_precise (dot.x - wid, dot.y)
shaft.extend_point (p)
create p.make_precise (dot.x + wid, dot.y)
shaft.extend_point (p)
create p.make_precise (dot.x + wid, dot.y + len)
shaft.extend_point (p)
create p.make_precise (dot.x - wid, dot.y + len)
shaft.extend_point (p)
extend (shaft)
end
build_head
-- Create the point (or retical) end of the arrow
local
p: EV_COORDINATE
do
create head
end
feature -- Access
direction: INTEGER
-- The direction the arrow is pointing if not targetting a unit
width: INTEGER
-- The size of the `shaft'
do
Result := 100
end
length: INTEGER
-- The length of the `shaft' calculated from the distance between the
-- two widgets or as a percentage of the size of the `unit_widget'
local
xd, yd: INTEGER
do
Result := 500
end
feature -- Basic operations
fill_widgets
-- Nothing to do here.
do
end
paint
-- Set the colors of the sub-widgets
do
Precursor {VITP_WIDGET}
-- if attached unit_widget as uw then
-- if attached targetted_widget as tw then
-- if uw.unit.nationality = US then
-- nock.set_foreground_color (adjusted_color (US_retical_color))
-- nock.set_background_color (adjusted_color (US_retical_color))
-- shaft.set_foreground_color (adjusted_color (US_retical_color))
-- shaft.set_background_color (adjusted_color (US_retical_color))
-- else
-- nock.set_foreground_color (adjusted_color (Japanese_retical_color))
-- nock.set_background_color (adjusted_color (Japanese_retical_color))
-- shaft.set_foreground_color (adjusted_color (Japanese_retical_color))
-- shaft.set_background_color (adjusted_color (Japanese_retical_color))
-- end
-- else
-- -- there is no target
-- nock.set_foreground_color (adjusted_color (arrow_color))
-- nock.set_background_color (adjusted_color (arrow_color))
-- shaft.set_foreground_color (adjusted_color (arrow_color))
-- shaft.set_background_color (adjusted_color (arrow_color))
--io.put_string ("ARROW.paint -- fix me! Hide/show the retical %N")
-- end
-- end
end
feature {NONE} -- Implementation
target_imp: detachable ATTACK_UNIT
-- Anchor for `target'
nock: EV_MODEL_ELLIPSE
-- Shows the end opposite the head
shaft: EV_MODEL_POLYGON
-- The shaft of the arrow
head: EV_MODEL_POLYGON
-- The point of the arrow
-- head: RETICAL
-- Gun sight retical
North: INTEGER = 1
South: INTEGER = 2
East: INTEGER = 3
West: INTEGER = 4
North_east: INTEGER = 5
South_east: INTEGER = 6
North_west: INTEGER = 7
South_west: INTEGER = 8
end

View File

@@ -0,0 +1,236 @@
note
description: "[
Builds a raised border for placement on an {ATTACK_UNIT_WIDGET}
]"
author: "Jimmy J. Johnson"
class
BORDER
inherit
EV_MODEL_WORLD
redefine
create_interface_objects
end
create
make
create {BORDER}
list_make
feature {NONE} -- Initialization
create_interface_objects
-- Initialize attributes
do
Precursor {EV_MODEL_WORLD}
create color
create borders.make_filled (create {LINKED_LIST [EV_MODEL_POLYGON]}.make, 1, 4)
end
-- make (a_size: REAL_64)
make (a_width, a_height, a_edge_size: REAL_64)
-- Create Current setting the `width' and `height'
-- If `a_width' and `a_height' is the size of the widget on
-- which to place the border, then the border steps will be
-- placed over the edge of the widget, not surrounding the
-- widget. (This seems preferred, so that the size of the
-- bordered widget is not bigger than planned.)
require
width_big_enough: a_width >= 30 -- arbitrary
height_big_enough: a_height >= 30
edge_size_big_enough: a_edge_size >= 10
local
i: INTEGER
do
default_create
create borders.make_filled (create {LINKED_LIST [EV_MODEL_POLYGON]}.make, 1, 4)
from i := Left
until i > Bottom
loop
borders [i] := create {LINKED_LIST [EV_MODEL_POLYGON]}.make
i := i + 1
end
-- size := a_size
width := a_width
height := a_height
edge_size := a_edge_size
build_edges
end
feature -- Access
color: EV_COLOR
-- The color from which to `paint' Current.
width: REAL_64
-- The width from which to build Current.
height: REAL_64
-- The height from which to build Current.
-- size: REAL_64
-- The width [and length] from which to build Current.
feature -- Element change
set_color (a_color: EV_COLOR)
-- Change the `color'.
do
color := a_color
paint
end
feature -- Basic operations
paint
-- Set the colors for the boarder polygons based on the
-- color of the background color of the `tile'
local
i: INTEGER
do
-- Color each edge in order: Left, Top, Right, Bottom
from i := Left
until i > Bottom
loop
paint_edge (i)
i := i + 1
end
end
feature {NONE} -- Implementation
paint_edge (a_index: INTEGER)
-- Paint the `a_index'th edge
require
index_big_enough: a_index >= 1
index_small_enough: a_index <= 4
local
fad: COLOR_FADER
polys: LINKED_LIST [EV_MODEL_POLYGON]
p: EV_MODEL_POLYGON
c: EV_COLOR
i: INTEGER
do
polys := borders [a_index]
create fad.make_with_color_and_count (color, polys.count)
from polys.start
until polys.exhausted
loop
p := polys.item
i := polys.count - polys.index + 1
if a_index <= 2 then
c := fad.i_th_lighter (i)
else
c := fad.i_th_darker (i)
end
p.set_background_color (c)
p.set_foreground_color (c)
polys.forth
end
end
build_edges
-- Create the polygons that simulate a raised boarder
local
-- Short variable names to make equations shorter
p, p2, p3, p4: EV_COORDINATE
poly: EV_MODEL_POLYGON
w, h: REAL_64
ss: REAL_64
c: INTEGER
i: INTEGER
do
-- Each boarder is one-tenth the width of the `box'. We then determine
-- the number of times 2 will go into this width and use that as the
-- number of color steps to make on each boarder.
-- The right and bottom boarders should fade-to-black; the top and left
-- boarders should fade-to-white then fade-to-grey.
-- This should give the appearance of a light source up and left.
ss := step_size
w := width
h := height
c := step_count
from i := 1
until i > c
loop
-- right
create p.make_precise (w - i * ss, i * ss)
create p2.make_precise ((w - (i - 1) * ss), (i - 1) * ss)
create p3.make_precise (w - (i - 1) * ss, h - (i - 1) * ss)
create p4.make_precise (w - i * ss, h - i * ss)
create poly
poly.extend_point (p)
poly.extend_point (p2)
poly.extend_point (p3)
poly.extend_point (p4)
borders [Right].extend (poly)
extend (poly)
-- left
create p.make_precise (i * ss, i * ss)
create p2.make_precise (i * ss, h - i * ss)
create p3.make_precise ((i - 1) * ss, h - (i - 1) * ss)
create p4.make_precise ((i - 1) * ss, (i - 1) * ss)
create poly
poly.extend_point (p)
poly.extend_point (p2)
poly.extend_point (p3)
poly.extend_point (p4)
borders [Left].extend (poly)
extend (poly)
-- bottom
create p.make_precise (i * ss, h - i * ss)
create p2.make_precise ((w - i * ss), h - i * ss)
create p3.make_precise (w - (i - 1) * ss, h - (i - 1) * ss)
create p4.make_precise ((i - 1) * ss, h - (i - 1) * ss)
create poly
poly.extend_point (p)
poly.extend_point (p2)
poly.extend_point (p3)
poly.extend_point (p4)
borders [Bottom].extend (poly)
extend (poly)
-- top
create p.make_precise ((i - 1) * ss, (i - 1) * ss)
create p2.make_precise (w - (i - 1) * ss, (i - 1) * ss)
create p3.make_precise (w - i * ss, i * ss)
create p4.make_precise (i * ss, i * ss)
create poly
poly.extend_point (p)
poly.extend_point (p2)
poly.extend_point (p3)
poly.extend_point (p4)
borders [Top].extend (poly)
extend (poly)
i := i + 1
end
end
borders: ARRAY [LINKED_LIST [EV_MODEL_POLYGON]]
-- Contains the four edges
edge_size: REAL_64
-- The size of each edge calculated from the smaller of
-- the `width' or `height'
-- do
---- Result := size / 10
-- Result := width.min (height) / 10
-- end
step_count: INTEGER
-- The number of incremental colors into which each edge is broken
do
Result := (edge_size / step_size).rounded
end
step_size: REAL_64 = 2.0
-- The logical width of each polygon in the edges
Left: INTEGER = 1
Top: INTEGER = 2
Right: INTEGER = 3
Bottom: INTEGER = 4
end

View File

@@ -0,0 +1,251 @@
note
description: "[
Draws the circular control markers for VITP.
]"
author: "Jimmy J. Johnson"
class
CONTROL_MARKER
inherit
FONT_AND_COLOR_CONSTANTS
undefine
default_create
end
DIMABLE
redefine
default_create
end
EV_MODEL_WORLD
redefine
default_create,
create_interface_objects
end
create
make
create {CONTROL_MARKER}
list_make
feature {NONE} -- Initialization
default_create
-- Set up Current
do
Precursor {DIMABLE}
Precursor {EV_MODEL_WORLD}
build_widgets
end
make (a_location: LOCATION)
-- Set up Current
do
location_imp := a_location
default_create
end
create_interface_objects
-- Create attributes
local
p1, p2: EV_COORDINATE
s: REAL_64
offset: REAL_64
t: EV_MODEL_TRANSFORMATION
do
Precursor {EV_MODEL_WORLD}
create circle
create sun
create star
create anchor
end
build_widgets
-- Construct and add widgets to Current.
do
build_circle
build_sun
build_star
build_anchor
star.scale (0.8)
anchor.set_x_y (anchor.x + 90, anchor.y + 62)
star.set_x_y (star.x + 96, star.y + 96)
sun.set_x_y (sun.x + 20, sun.y + 30)
paint
end
build_circle
-- Create the marker
local
p1, p2: EV_COORDINATE
s: REAL_64
do
extend (circle)
create p1.make_precise (0, 0)
create p2.make_precise (Initial_size, Initial_size)
circle.set_point_a (p1)
circle.set_point_b (p2)
end
build_sun
-- Create the "Japanese" rising `sun'
local
p1, p2: EV_COORDINATE
s: REAL_64
offset: REAL_64
do
extend (sun)
-- create a circle that is slightly small than `circle'
-- and offset it a little
s := Initial_size * 0.7
create p1.make_precise (0, 0)
create p2.make_precise (s, s)
sun.set_point_a (p1)
sun.set_point_b (p2)
offset := Initial_size / 12
-- offset a little
-- translate_widget (sun, offset, offset)
end
build_star
-- Create the star
do
extend (star)
-- translate_widget (star, -Initial_size/12, -Initial_size/12)
-- scale_widget (star, 1.2)
-- fix center on ... dot is not positioned yet by `initialize'
-- star.set_x_y (dot.x, dot.y)
end
build_anchor
-- Create an anchor
do
extend (anchor)
-- scale_widget (anchor, 2.0)
-- translate_widget (anchor, -Initial_size/12, -Initial_size/12)
-- fix center on ... dot is not positioned yet by `initialize'
end
feature -- Access
location: LOCATION
-- The location (e.g. a PORT or a chart) to which
-- this marker belongs
require
has_location: has_location
do
check attached location_imp as loc then
Result := loc
end
end
set_location (a_location: like location)
-- Change the `location'
do
location_imp := a_location
end
feature {NONE} -- Implementation
location_imp: detachable like location
-- Implementation for `location'
feature -- Status report
has_location: BOOLEAN
-- Has a location been assigned?
do
Result := attached location_imp
end
is_boarder_shown: BOOLEAN
-- Should the outline of the flag show?
feature -- Status setting
show_boarder
-- Make the outline of the flag visible
do
is_boarder_shown := true
end
hide_boarder
-- Make the outline of the flag NOT visible
do
is_boarder_shown := false
end
feature -- Basic operations
hide_anchor
-- Make the anchor no show.
-- Required for non-major ports.
do
anchor.hide
end
paint
-- Set the colors of the sub-widgets
local
fc: EV_COLOR
do
circle.show
if location.is_allied then
circle.set_foreground_color (adjusted_color (US_unit_color))
circle.set_background_color (adjusted_color (US_unit_color))
sun.hide
star.show
-- star.paint
else
sun.show
star.hide
circle.set_foreground_color (adjusted_color (White))
circle.set_background_color (adjusted_color (White))
end
-- Hide or show boarder color?
if location.nationality = {NATIONALITY_CONSTANTS}.japanese then
fc := japanese_unit_color
else
fc := allied_unit_boarder_color
end
if is_boarder_shown then
circle.set_foreground_color (adjusted_color (fc))
end
anchor.set_foreground_color (adjusted_color (Black))
anchor.set_background_color (adjusted_color (Black))
sun.set_foreground_color (adjusted_color (Japanese_unit_color))
sun.set_background_color (adjusted_color (Japanese_unit_color))
end
feature {NONE} -- Implementation
circle: EV_MODEL_ELLIPSE
-- The main figure
sun: EV_MODEL_ELLIPSE
-- The sun on Japanese markers
star: STAR
-- The star on US widgets
anchor: ANCHOR
-- The anchor on major port control markers
internal_scale_factor_small: DOUBLE = 0.05
-- Used to scale `internal_size'
internal_scale_factor_medium: DOUBLE = 0.07
-- Used to scale `internal_size'
internal_scale_factor_large: DOUBLE = 0.09
-- Used to scale `internal_size'
Initial_size: REAL_64 = 200.0
-- Used internally to build the figure
invariant
end

View File

@@ -0,0 +1,641 @@
note
description: "[
A base class for building the Japanese or US flag
]"
author: "Jimmy J. Johnson"
class
FLAG
inherit
FONT_AND_COLOR_CONSTANTS
undefine
default_create
end
DIMABLE
redefine
default_create
end
EV_MODEL_WORLD
redefine
default_create,
create_interface_objects
end
create
make
create {FLAG}
list_make
feature {NONE} -- Initialization
default_create
-- Set up Current
do
Precursor {DIMABLE}
Precursor {EV_MODEL_WORLD}
build_widgets
end
make (a_location: like location)
-- Set up Current
do
location_imp := a_location
default_create
end
create_interface_objects
-- Create attributes
do
Precursor {EV_MODEL_WORLD}
create field
create border.make (width, height, border_size)
background_coordinates := [create {EV_COORDINATE}, create {EV_COORDINATE}]
create background
create charge
create rising_sun
create canton
create canton_imp
create stars.make
end
build_widgets
-- Create the widget and associate it with `a_location'
do
build_field
build_us_charge
build_japanese_charge
build_canton
build_border
scale (0.07)
end
build_border
-- Add the border on top of other widgets in Current
do
extend (border)
end
build_field
-- Create the flags background
local
p1, p2: EV_COORDINATE
do
create field
extend (field)
-- create p1.make_precise (0.0, 0.0)
-- create p2.make_precise (width, height)
create p1.make_precise (border_size, border_size)
create p2.make_precise (width - border_size, height - border_size)
create background.make_with_points (p1, p2)
-- Save the points
background_coordinates := [p1, p2]
field.extend (background)
end
build_us_charge
-- Build the `charge', sizing it relative to the `background' rectangle.
-- Create the red stripes. (The white is background.)
local
i: INTEGER
x1, y1, x2, y2: REAL_64
h: REAL_64
stripe: EV_MODEL_POLYGON
do
create charge
field.extend (charge)
x1 := background_coordinates.point_1.x + 2
y1 := background_coordinates.point_1.y + 2
x2 := background_coordinates.point_2.x - 2
y2 := background_coordinates.point_2.y - 2
h := (y2 - y1) / 13
from i := 1
until i > 13
loop
if i \\ 2 = 1 then
create stripe
stripe.extend_point (create {EV_COORDINATE}.make_precise (x1, y1 + (i - 1) * h))
stripe.extend_point (create {EV_COORDINATE}.make_precise (x2, y1 + (i - 1) * h))
stripe.extend_point (create {EV_COORDINATE}.make_precise (x2, y1 + i * h))
stripe.extend_point (create {EV_COORDINATE}.make_precise (x1, y1 + i * h))
charge.extend (stripe)
end
i := i + 1
end
end
build_japanese_charge
-- Create the sun and rays for the Japanese flag
local
p1: EV_MODEL_POLYGON
os: REAL_64
clipper: POLYGON_CLIPPER
ang, ang_step: REAL_64
mid: EV_COORDINATE
ray: EV_MODEL_POLYGON
do
build_rising_sun
rising_sun.scale_x (1.8)
rising_sun.scale_y (1.4)
field.extend (rising_sun)
-- Must move the charge a bit to line up with the background
rising_sun.set_x_y (165, 100)
-- center_widget_on_other (rising_sun, field)
-- create japanese_charge
-- field.extend (japanese_charge)
-- -- Build the `japanese_charge' inside a square so the angles at which the rays
-- -- radiate from the sun can be uniformly spaced around a circle. After
-- -- the rays are build the `charge' is scaled to match the flag's `width'
-- -- and `height'.
-- -- Create a polygon slightly smaller than the `field'
-- os := width / 10.0
-- create p1
-- p1.extend_point (create {EV_COORDINATE}.make_precise (os, os))
-- p1.extend_point (create {EV_COORDINATE}.make_precise (width - os, os))
-- p1.extend_point (create {EV_COORDINATE}.make_precise (width - os, width - os))
-- p1.extend_point (create {EV_COORDINATE}.make_precise (os, width - os))
-- -- Each of the 16 "rays" immenating from the sun is built as a triangle centered
-- -- at the midpoint, extending beyond the boundaries of `p1'. Each ray is then
-- -- clipped against `p1'
-- create clipper
-- ang := (2.0 * Pi) / 16.0
-- create mid.make_precise (width / 2.0, width / 2.0)
-- from i := 1
-- until i > 16
-- loop
-- create ray.default_create
-- ray.extend_point (mid)
-- ax := delta_x (ang * i, width)
-- ay := delta_y (ang * i, width)
-- ray.extend_point (create {EV_COORDINATE}.make_precise (ax, ay))
-- ax := delta_x (ang * (i + 1), width)
-- ay := delta_y (ang * (i + 1), width)
-- ray.extend_point (create {EV_COORDINATE}.make_precise (ax, ay))
-- ray := clipper.clipped (ray, p1)
-- field.extend (ray)
-- i := i + 1
-- end
end
-- build_canton
-- -- Create the union on US flag.
-- -- This contains the [50] stars (should be 48).
-- local
-- p1, p2: EV_COORDINATE
-- s: STAR
-- i, j: INTEGER
-- a, b: REAL_64
-- c, d: REAL_64
-- e, f, g, h: REAL_64
-- k: REAL_64
-- ax, ay: REAL_64
-- t: EV_MODEL_TRANSFORMATION
-- do
-- create t.make_zero
-- create canton
-- field.extend (canton)
-- a := height
-- b := width
-- c := a * 7/13
-- d := b * 2/5
-- e := c / 10
-- f := c / 10
-- g := d / 12
-- h := d / 12
-- k := a * 0.0616
-- create p1.make_precise (0.0, 0.0)
-- create p2.make_precise (d, c)
---- create canton_imp.make_with_points (p1, p2)
---- create canton_imp
-- canton_imp.extend_point (create {EV_COORDINATE}.make_precise (0.0, 0.0))
-- canton_imp.extend_point (create {EV_COORDINATE}.make_precise (d, 0.0))
-- canton_imp.extend_point (create {EV_COORDINATE}.make_precise (d, c))
-- canton_imp.extend_point (create {EV_COORDINATE}.make_precise (0.0, c))
-- canton.extend (canton_imp)
-- -- A star is created, scaled and then its center point is moved to
-- -- (0, 0). From there the star is positioned based on the algorithm.
-- -- Add the 6 x 5 set of stars
-- from i := 1
-- until i > 6
-- loop
-- ax := (i - 1) * (2 * h) + g
-- from j := 1
-- until j > 5
-- loop
-- create s
---- s.set_target (location)
-- s.scale (0.0616)
-- canton.extend (s)
-- stars.extend (s)
-- t.translate (-s.dot.point.x, -s.dot.point.y)
-- s.transform (t)
-- ay := (j - 1) * (2 * f) + e
-- t.translate (ax, ay)
-- s.transform (t)
-- j := j + 1
-- end
-- i := i + 1
-- end
-- -- Add the remaining stars, the 5 x 4 set
-- from i := 1
-- until i > 5
-- loop
-- ax := i * (2 * h) - h + g
-- from j := 1
-- until j > 4
-- loop
-- create s
---- s.set_target (location)
-- s.scale (0.0616)
-- canton.extend (s)
-- t.translate (-s.dot.point.x, -s.dot.point.y)
-- s.transform (t)
-- ay := j * (2 * f) - f + e
-- t.translate (ax, ay)
-- s.transform (t)
-- j := j + 1
-- end
-- i := i + 1
-- end
-- end
build_canton
-- Create the 48-star union on US flag.
-- The dimensions were estimated based on the 50-star version.
local
-- p1, p2: EV_COORDINATE
s: STAR
i, j: INTEGER
a, b: REAL_64
c, d: REAL_64
e, f, g, h: REAL_64
k: REAL_64
ax, ay: REAL_64
marg: REAL_64 -- margin to account for boarder
t: EV_MODEL_TRANSFORMATION
x1, y1, x2, y2: REAL_64
do
create t.make_zero
create canton
field.extend (canton)
x1 := background_coordinates.point_1.x + 2
y1 := background_coordinates.point_1.y + 2
x2 := background_coordinates.point_2.x - 2
y2 := background_coordinates.point_2.y - 2
-- a := height - 2 * border_size
-- b := width - 2 * border_size
a := y2 - y1
b := x2 - x1
c := a * 7/13
d := b * 2/5
e := c / 7 -- divided by number of rows + 1
f := c / 7 -- divided by number of rows + 1
g := d / 9 -- divided by number of columns + 1
h := d / 9 -- divided by number of columns + 1
k := a * 0.0616
-- create p1.make_precise (0.0, 0.0)
-- create p2.make_precise (d, c)
-- Create the blue background for the stars
canton_imp.extend_point (create {EV_COORDINATE}.make_precise (x1, y1))
canton_imp.extend_point (create {EV_COORDINATE}.make_precise (x1 + d, y1))
canton_imp.extend_point (create {EV_COORDINATE}.make_precise (x1 + d, y1 + c))
canton_imp.extend_point (create {EV_COORDINATE}.make_precise (x1, y1 + c))
canton.extend (canton_imp)
-- A star is created, scaled and then its center point is moved to
-- (0, 0). From there the star is positioned based on the algorithm.
-- Add the 6 x 5 set of stars
from i := 1
until i > 8
loop
-- ax := (i - 1) * (2 * h) + g
-- ax := (i - 1) * h + g/2
ax := x1 + (i - 1) * h + g
from j := 1
until j > 6
loop
create s
s.scale (0.0616)
canton.extend (s)
stars.extend (s)
-- t.translate (-s.dot.point.x, -s.dot.point.y)
-- s.transform (t)
s.set_x_y (0, 0)
-- ay := (j - 1) * (2 * f) + e
-- ay := (j - 1) * f + e/2
ay := y1 + (j - 1) * f + e
t.translate (ax, ay)
s.transform (t)
j := j + 1
end
i := i + 1
end
end
feature -- Access
location: LOCATION
-- The location (e.g. a PORT or a chart) to which
-- this marker belongs
require
has_location: has_location
do
check attached location_imp as loc then
Result := loc
end
end
set_location (a_location: like location)
-- Change the `location'
do
location_imp := a_location
end
feature {NONE} -- Implementation
location_imp: detachable like location
-- Implementation for `location'
feature -- Status report
has_location: BOOLEAN
-- Has a location been assigned?
do
Result := attached location_imp
end
is_outlined: BOOLEAN
-- Should the outline of the flag show?
-- If yes, change the foreground color to show a line around Current.
is_flat: BOOLEAN
-- Should Current be drawn as a flat picture?
feature -- Status setting
show_outline
-- Make the outline of the flag visible
do
is_outlined := true
end
hide_outline
-- Make the outline of the flag NOT visible
do
is_outlined := false
end
set_flat
-- Cause the widget to be painted as a flat tile
do
is_flat := True
paint
end
set_raised
-- Cause the widget to be painted as a 3-d tile
do
is_flat := False
paint
end
feature -- Basic operations
-- set_dimming_level (a_level: INTEGER)
-- -- Change the `dimming_level'
-- do
-- Precursor {DIMABLE} (a_level)
-- paint
-- end
paint
-- Set the colors of the sub-widgets
do
paint_field
paint_charge
paint_canton
paint_border
if is_flat then
border.hide
else
border.show
end
if location.is_allied then
field.show
charge.show
canton.show
rising_sun.hide
elseif location.nationality = {NATIONALITY_CONSTANTS}.japanese then
field.show
rising_sun.show
charge.hide
canton.hide
else
field.hide
charge.hide
canton.hide
rising_sun.hide
border.hide
end
end
feature {NONE} -- Implementation
paint_border
-- Set the color for the `border'
do
border.set_color (adjusted_color (White))
end
paint_field
-- Paint the `field'
local
c: EV_COLOR
do
c := us_flag_white_color
background.set_background_color (adjusted_color (c))
-- Set color for boarder around the background if shown.
-- This is just the line around the flag on the OA Charts.
if is_outlined then
if location.nationality = {NATIONALITY_CONSTANTS}.japanese then
c := japanese_unit_color
else
c := us_unit_color
end
end
background.set_foreground_color (adjusted_color (c))
end
paint_charge
-- Paint the `charge'
do
from charge.start
until charge.exhausted
loop
if attached {EV_MODEL_POLYGON} charge.item as s then
s.set_foreground_color (adjusted_color (US_flag_red_color))
s.set_background_color (adjusted_color (US_flag_red_color))
end
rising_sun.set_foreground_color (adjusted_color (Japanese_unit_color))
rising_sun.set_background_color (adjusted_color (Japanese_unit_color))
charge.forth
end
end
paint_canton
-- Paint the canton area (and stars)
local
s: STAR
do
canton_imp.set_background_color (adjusted_color (US_flag_blue_color))
canton_imp.set_foreground_color (adjusted_color (US_flag_blue_color))
-- Must paint each star (to dim or brighten them)
from stars.start
until stars.off
loop
s := stars.item
s.set_background_color (adjusted_color (white))
s.set_foreground_color (adjusted_color (white))
stars.forth
end
end
feature {NONE} -- Implementation
frozen height: REAL_64 = 200.0
-- The span of a flag down the side parallel to the flagpole
-- width: REAL_64 = 380.0
width: REAL_64 = 330.0
-- The span of the flag along the side at right angles to the flagpole
ratio: REAL_64
-- The ratio of the `width' / `height' (1.9 for US flags)
background_coordinates: TUPLE [point_1: EV_COORDINATE; point_2: EV_COORDINATE]
-- The corner points for the `background'.
-- Used EV_COORDINATE to be more precise (i.e. REAL_64, not INTEGER_32)
background: EV_MODEL_RECTANGLE
-- The background of Current (usually white)
border: BORDER
-- The borders around the `field', giving a raised appearance
border_size: REAL_64
-- Ratio of the size of the `border' to `width'
do
Result:= (height.min (width)) / 20
end
canton: EV_MODEL_WORLD
-- The upper hoist (left) quarter (contains the field of stars in US flag)
charge: EV_MODEL_WORLD
-- A figure or symbol appearing on the flag
rising_sun: EV_MODEL_POLYGON
-- The red sun and rays on the Japanese flag
field: EV_MODEL_WORLD
-- The top container for Current
canton_imp: EV_MODEL_POLYGON
-- The rectangle to make a blue canton
stars: LINKED_SET [STAR]
-- Keep track of all the stars in Current, so they can be dimmed
-- when `set_dimming_level' is called
build_rising_sun
-- Make the polygon
do
create rising_sun
-- Points generated by Grabber application
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0, 0))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (32.395061728395063, 39.308641975308639))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (35.358024691358025, 37.728395061728392))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (38.913580246913575, 35.55555555555555))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (20.938271604938265, 1.7777777777777786))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (33.777777777777771, 1.7777777777777786))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (43.851851851851848, 33.777777777777764))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (46.617283950617285, 33.58024691358024))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (49.97530864197531, 32.79012345679012))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (47.407407407407412, 1.5802469135802468))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (58.66666666666665, 1.9753086419753103))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (56.888888888888879, 33.185185185185176))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (59.851851851851841, 32.987654320987652))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (64.395061728395063, 33.975308641975303))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (74.074074074074048, 1.3827160493827169))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (87.111111111111114, 1.7777777777777786))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (69.925925925925895, 35.950617283950614))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (72.296296296296276, 37.92592592592591))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (74.271604938271594, 40.296296296296291))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (107.25925925925924, 0.98765432098765338))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (130.17283950617283, 1.1851851851851851))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (78.81481481481481, 44.444444444444436))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (80.790123456790099, 47.012345679012341))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (82.370370370370352, 50.962962962962955))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (168.09876543209876, 1.3827160493827169))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (167.90123456790118, 30.024691358024683))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (85.333333333333314, 55.506172839506164))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (85.925925925925895, 58.074074074074055))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (85.925925925925895, 62.222222222222207))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (167.90123456790118, 54.716049382716044))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (168.09876543209876, 76.246913580246883))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (85.925925925925895, 68.938271604938251))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (85.53086419753086, 72.098765432098759))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (85.135802469135797, 75.851851851851848))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (167.3086419753086, 100.34567901234567))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (166.71604938271602, 130.56790123456787))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (83.160493827160479, 80.592592592592581))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (81.382716049382708, 83.160493827160479))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (79.407407407407391, 85.728395061728378))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (130.56790123456787, 128.59259259259255))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (107.06172839506172, 129.38271604938268))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (75.259259259259238, 89.679012345679013))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (72.691358024691368, 92.049382716049365))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (69.53086419753086, 94.024691358024654))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (87.308641975308632, 128.98765432098762))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (74.074074074074048, 129.18518518518516))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (64.592592592592581, 96.395061728395035))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (61.432098765432094, 97.185185185185162))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (57.283950617283942, 97.185185185185162))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (60.049382716049372, 128.79012345679007))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (47.999999999999993, 128.79012345679007))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (50.37037037037036, 97.382716049382708))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (47.407407407407412, 97.185185185185162))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (44.049382716049372, 95.999999999999972))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (34.172839506172842, 128.98765432098762))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (19.950617283950621, 129.18518518518516))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (38.716049382716044, 94.024691358024654))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (35.358024691358025, 92.839506172839464))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (32.592592592592588, 90.469135802469111))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.39506172839506704, 128.59259259259255))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.39506172839506704, 109.43209876543207))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (28.839506172839513, 85.925925925925895))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (26.074074074074076, 83.358024691357997))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (24.493827160493822, 79.999999999999972))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.19753086419753174, 93.03703703703701))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.19753086419753174, 82.172839506172807))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (21.728395061728399, 75.061728395061692))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (21.728395061728399, 71.703703703703695))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (21.925925925925924, 68.34567901234567))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.39506172839506704, 70.123456790123441))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.39506172839506704, 61.234567901234563))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (21.728395061728399, 62.617283950617271))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (21.333333333333336, 59.061728395061728))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (22.320987654320987, 56.493827160493829))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.19753086419753174, 49.185185185185176))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0.39506172839506704, 37.530864197530853))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (24.691358024691361, 50.567901234567891))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (26.271604938271594, 47.012345679012341))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (28.444444444444436, 44.049382716049379))
rising_sun.extend_point (create {EV_COORDINATE}.make_precise (0, 20.938271604938272))
end
end

View File

@@ -0,0 +1,83 @@
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