Hexagons and stuff
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Hexagons and stuff
That's clever stuff!
Although:
1. I'm not sure if that provides the whole image in hex tiles.
2. It needs quite a bit of modification to chop up any image an end-user imports into the stack.
Although:
1. I'm not sure if that provides the whole image in hex tiles.
2. It needs quite a bit of modification to chop up any image an end-user imports into the stack.
Last edited by richmond62 on Thu Jul 26, 2018 8:28 am, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Hexagons and stuff
Code: Select all
import snapshot from grc "hex"
set the name of the last control to ("r"&tRow&"c"&(tCol))
set the left of img ("r"&tRow&"c"&(tCol)) to (10 + KOUNT)
Re: Hexagons and stuff
Correct, I was just demonstrating the process. A more robust solution would allow configuration of the hex size and then automatically split any image. I will check out your mods this evening.richmond62 wrote: ↑Thu Jul 26, 2018 8:03 amThat's clever stuff!
Although:
1. I'm not sure if that provides the whole image in hex tiles.
2. It needs quite a bit of modification to chop up any image an end-user imports into the stack.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Hexagons and stuff
I've updated the button to use the red rectangle as the bounds for the slicing. There is also a variable to set the desired side length of the tile and everything adjusts accordingly.
Download the stack here: https://milby.us/lc/HexSplit2.livecode
(I couldn't post here - kept getting a message that it was too large)
Download the stack here: https://milby.us/lc/HexSplit2.livecode
(I couldn't post here - kept getting a message that it was too large)
Code: Select all
on mouseUp pMouseButton
local tColOffset, tCols, tHeight, tLeft, tMargin, tMaxX, tMaxY
local tName, tRowOffset, tRows, tSide, tTop, tTopOffset, tWidth
put 20 into tSide
put 2 * tSide into tWidth
put sqrt(3) * tSide into tHeight
put tWidth - tHeight into tMargin
put tWidth + tSide + tMargin into tColOffset
put tHeight + tMargin/2 into tRowOffset
set the width of grc "hex" to tWidth
set the height of grc "hex" to tWidth
put the width of grc "border" / (tSide*3/2) into tCols
put the height of grc "border" / tHeight into tRows
put the right of grc "border" into tMaxX
put the bottom of grc "border" into tMaxY
put round(tMaxY + tHeight) into tTopOffset
set the visible of grc "border" to false
repeat with tCol = 1 to tCols step 2
lock screen
repeat with tRow = 1 to tRows
put "r" & tRow & "c" & (tCol) into tName
put (tCol-1)/2 * (tSide*3) into tLeft
put (tRow-1) * tHeight into tTop
export snapshot from rect tLeft,tTop,tLeft+tWidth,tTop+tWidth \
of this card to img "box"
set the backPattern of grc "hex" to the ID of img "box"
import snapshot from grc "hex"
set the name of the last control to tName
set the left of img tName to (tCol-1)/2 * tColOffset
set the top of img tName to tTopOffset + (tRow-1) * tRowOffset
put "r" & tRow & "c" & (tCol+1) into tName
put tLeft + tSide*3/2 into tLeft
if tLeft > tMaxX then next repeat
put tTop + tHeight/2 into tTop
if tTop > tMaxY then next repeat
export snapshot from rect tLeft,tTop,tLeft+tWidth,tTop+tWidth \
of this card to img "box"
set the backPattern of grc "hex" to the ID of img "box"
import snapshot from grc "hex"
set the name of the last control to tName
set the left of img tName to (tCol-1)/2 * tColOffset + tColOffset/2
set the top of img tName to tTopOffset + (tRow-1) * tRowOffset + tHeight/2
end repeat
unlock screen
end repeat
set the visible of grc "border" to true
end mouseUp
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Hexagons and stuff
Clever as far as it goes (meaning that this weekend I'll try to "get down and dirty"
with the code and see if I can effect things in a slightly different way), but,
even before downloading your stack:
- -
My green crosses point out where there are problems.
with the code and see if I can effect things in a slightly different way), but,
even before downloading your stack:
- -
My green crosses point out where there are problems.
Re: Hexagons and stuff
Stack updated. Still need to work with it a bit more to be sure it captures the entire image.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Hexagons and stuff
Might want to remove any images left over from earlier uses of the DO IT button
Place that code before
Jim Lambert
Code: Select all
-- remove earlier tiles if any
repeat with x = the number of images down to 1
put the short name of img x into adad
if matchtext(the short name of img x, "r[0-9]+c[0-9]+") then delete img x
end repeat
Code: Select all
repeat with tCol = 1 to tCols step 2
Re: Hexagons and stuff
Thanks. I’ll add that and repost. I’ve been doing it by hand each time
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: Hexagons and stuff
I've posted an update that does the auto-cleanup.
https://milby.us/lc/HexSplit3.livecode
UPDATED: Code now has more comments. Adjusted code to only capture one column at a time. I left the previous version up and added a new version.
I've also move the tile size to a field.
https://milby.us/lc/HexSplit3.livecode
UPDATED: Code now has more comments. Adjusted code to only capture one column at a time. I left the previous version up and added a new version.
I've also move the tile size to a field.
Yeah... I was actually thinking that I should code the tile cleanup, but wanted to do the other logic stuff first.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Hexagons and stuff
I don't think I'd bother with a cleanup code as I'd export the hexagons
to an external file as PNG images so they could be used anywhere.
to an external file as PNG images so they could be used anywhere.
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Hexagons and stuff
-
"That's not Rockabilly, that's Swing!"
Hope to get some "Rockabilly" together this weekend.
Part of my further posting might be stated like this:
"Why have DAZ been so STUPID as to do nothing about making Bryce 7 available for any MacOS past 10.6 ?"
"That's not Rockabilly, that's Swing!"
Hope to get some "Rockabilly" together this weekend.
Part of my further posting might be stated like this:
"Why have DAZ been so STUPID as to do nothing about making Bryce 7 available for any MacOS past 10.6 ?"
-
- Livecode Opensource Backer
- Posts: 9450
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Hexagons and stuff
Ooh: Gosh; a new, boring interface.
-
Possibly; but getting more like something that imports
an image and chops it up into hexagonal png images and exports them.
- -
the inevitable sticky patch . . .
- -
but getting Somewhere.