Hexagons and stuff

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Thu Jul 26, 2018 8:03 am

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.
Last edited by richmond62 on Thu Jul 26, 2018 8:28 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Thu Jul 26, 2018 8:26 am

done.png
-
HexSplit MOD.livecode.zip
(253.65 KiB) Downloaded 341 times
-

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)
-
8)

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Hexagons and stuff

Post by bwmilby » Thu Jul 26, 2018 2:02 pm

richmond62 wrote:
Thu Jul 26, 2018 8:03 am
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.
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.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Hexagons and stuff

Post by bwmilby » Fri Jul 27, 2018 4:09 am

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)

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

hexsplit2.jpg
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Fri Jul 27, 2018 8:40 am

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:
-
hexsplit2Crit.jpg
hexsplit2Crit.jpg (64.81 KiB) Viewed 12825 times
-
My green crosses point out where there are problems.

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Hexagons and stuff

Post by bwmilby » Fri Jul 27, 2018 2:33 pm

Stack updated. Still need to work with it a bit more to be sure it captures the entire image.
hexsplit2a.jpg
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Hexagons and stuff

Post by jiml » Fri Jul 27, 2018 7:54 pm

Might want to remove any images left over from earlier uses of the DO IT button

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
   
Place that code before

Code: Select all

 repeat with tCol = 1 to tCols step 2
Jim Lambert

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Hexagons and stuff

Post by jiml » Fri Jul 27, 2018 7:55 pm

Ooops

delete line

Code: Select all

  put the short name of img x into adad

Unnecessary.

JimL

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Hexagons and stuff

Post by bwmilby » Fri Jul 27, 2018 7:59 pm

Thanks. I’ll add that and repost. I’ve been doing it by hand each time :D
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Hexagons and stuff

Post by bogs » Fri Jul 27, 2018 9:19 pm

bwmilby wrote:
Fri Jul 27, 2018 7:59 pm
I’ve been doing it by hand each time :D
OMG, it is just as I feared, my methods are infecting Brian! Wait till the spots stop spinning Brian! Hold out for help!!

:twisted:
Image

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Hexagons and stuff

Post by bwmilby » Fri Jul 27, 2018 11:38 pm

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.
hexsplit2b.jpg
bogs wrote:
Fri Jul 27, 2018 9:19 pm
OMG, it is just as I feared, my methods are infecting Brian! Wait till the spots stop spinning Brian! Hold out for help!!

:twisted:
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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Sun Jul 29, 2018 9:37 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Mon Jul 30, 2018 2:59 pm


richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Fri Aug 03, 2018 9:00 pm

Screen Shot 2018-08-03 at 10.58.35 pm.png
-
"That's not Rockabilly, that's Swing!"


Hope to get some "Rockabilly" together this weekend. 8)

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 ?"

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hexagons and stuff

Post by richmond62 » Sat Aug 04, 2018 1:26 pm

H4.png
-
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.
-
stickyPatch.png
-
the inevitable sticky patch . . .
-
HexSplit4.livecode.zip
Here's the stack.
(35.02 KiB) Downloaded 311 times
-
but getting Somewhere. 8)

Post Reply

Return to “Games”