Appreciate any help in coming up with a Livecode script chunk to draw and fill a group of equilateral triangles.
I'm working on an open source app that helps people create and share stories with a fractal pattern.
A key challenge is drawing triangles that will represent the following elements of a story:
- Attractor
- Challenge
- Opportunity (a state change to resolve the tension)
- Strategy
- Test
- Decision
Each of the six standard story elements above will be displayed in the app as an equilateral triangle. Each element, in turn, will be associated with a distinctive color – yellow, red, orange, purple, blue, or green.
I'd love for a Livecode script to draw six triangles that fit together – much like pie slices – to form a hexagon that represents the whole narrative.
The transparency (blendlevel) of each colored segment will indicate the degree to which the story's author(s) – or invited reviewers – consider that element of the story to be complete.
My hope is to come up with a script in Livecode that will:
rapidly draw six triangles to form a hexagonal shape
fill each triangle with its associated color (each color will have an initial blendlevel of an almost transparent 90 percent)
assign a unique short name to each of the six triangles, based on the name of its fill color
group the six triangles so that they can be dragged together to new locations on the screen.
Are there any scripts (or chunks) that can help on this? Deeply appreciate any sample code or links to help shorten my Livecode learning curve.
Best,
Mark Frazier
====== Progress Update! ====== [August 2nd, 6 pm Eastern]
I've just found and adapted a polygon-generating script by Lloyd Rieber of Univ. of Georgia that creates hexagons. Is there a way to tweak it, so that it can create an equilateral triangle that can then be copied and rotated to fill out the hexagon?
on mouseUp
global tpoints
if exists(grc "HexagonCanvas" of this card) then delete grc "HexagonCanvas"
lock screen
create grc "HexagonCanvas"
set the loc of grc "HexagonCanvas" to "140,140"
set the opaque of grc "HexagonCanvas" to true
-- resize the new grc
get the rect of grc "HexagonCanvas"
add 80 to item 4 of it
set the rect of grc "HexagonCanvas" to it
put the topleft of grc "HexagonCanvas" into TL
put the topright of grc "HexagonCanvas" into TR
put the bottomleft of grc "HexagonCanvas" into BL
put the bottomright of grc "HexagonCanvas" into BR
put the width of grc "HexagonCanvas" into twidth
put the height of grc "HexagonCanvas" into theight
put trunc(twidth/4) into twidthquart
put trunc(theight/2) into theighthalf
#=========set the points for the "free" hexagon polygon==================
put empty into tpoints
put (item 1 of TL + twidthquart, item 2 of TL) into tpoints
# for the first line of tpoints "put into"
put Cr& (item 1 of TL, item 2 of TL + theighthalf) after tpoints
put CR& (item 1 of BL + twidthquart, item 2 of BL) after tpoints
put CR& (item 1 of BR - twidthquart, item 2 of BR) after tpoints
put Cr& (item 1 of BR, item 2 of BR - theighthalf) after tpoints
put CR& (item 1 of TR - twidthquart, item 2 of TR) after tpoints
put CR& (item 1 of TL + twidthquart, item 2 of TL) after tpoints
set the points of grc "HexagonCanvas" to tpoints
set the style of grc "HexagonCanvas" to "polygon"
set the backgroundColor of grc "HexagonCanvas" to blue
set the blendlevel of grc "HexagonCanvas" to "60"
choose browse tool
end mouseUp