logo
down
shadow

Indent even rows of hexagons in CSS


Indent even rows of hexagons in CSS

By : user2955400
Date : November 22 2020, 10:40 AM
With these it helps Here's a solution that uses javascript to add the necessary transformations to the elements.
CSS:
code :
.container {
    padding-top: 80px;
    width: 65%;
    margin-left: auto;
    margin-right: auto;
}

.floatBox {
    margin-left: 15px;
    margin-right: 15px;
}

.floatBox div {
    display: inline-block;

}
.floatBox div.odd {
    margin-left: 67px;
}
var floatBox = $(".floatBox");
var elements = floatBox.children();
var numElements = elements.length;

//reset all styles so they don't compound
elements.removeClass("odd");
elements.css("transform", "translateY(0)");
elements.css("-ms-transform", "translateY(0)");
elements.css("-webkit-transform", "translateY(0)");

var width = $(window).width() *.65;
var evenRowWidth = Math.floor(width / 135);
var oddRowWidth = Math.max(evenRowWidth - 1, 1);
var numberOfRows = 0;

var floatBoxWidth = evenRowWidth *138;
var delta = Math.floor((width-floatBoxWidth)/2);
floatBox.css("margin-left", delta);
floatBox.css("margin-right", delta);

var test = numElements;
var j = 2;
while (test > 0)
{
    if (j % 2 == 0)
    {
        test -= evenRowWidth;
    }
    else
    {
        test -= oddRowWidth;
    }
    numberOfRows++;
    j++;
}

j = 0;
var actionRow = 2;
var rowCount = 1;
var first = true;
for (var i = evenRowWidth; i < numElements; i++)
{
    var translationAmt = -37*(actionRow-1);
    if (actionRow % 2 == 0 && first)
    {
        first = true;
    }
    if (first)
    {
        $(elements.get(i)).addClass("odd");
        first = false;
    }
    $(elements.get(i)).css("transform", "translateY(" + translationAmt + "px)");
    $(elements.get(i)).css("-ms-transform", "translateY(" + translationAmt + "px)");
    $(elements.get(i)).css("-webkit-transform", "translateY(" + translationAmt + "px)");

    if (actionRow % 2 == 0)
    {
        if (rowCount == oddRowWidth)
        {
            actionRow++;
            rowCount = 0;
        }
    }
    else
    {
        if (rowCount == evenRowWidth)
        {
            actionRow++;
            rowCount = 0;
            first = true;
        }
    }
    rowCount++;
}
<div class="container">
    <div class="floatBox">

        <div>
            <span>
                <img src="image.png">
            </span>
        </div>
        ...
    </div>
</div>


Share : facebook icon twitter icon
Number of hexagons and position of hexagons saved in .plist file. How can I retrieve the first item and assign it to a C

Number of hexagons and position of hexagons saved in .plist file. How can I retrieve the first item and assign it to a C


By : user3848770
Date : March 29 2020, 07:55 AM
hope this fix your issue If you are talking about creating dynamically named variables hexagon1, hexagon2 etc during runtime, I don't think it's possible. However, you can generate those names as strings and use them as the keys to a dictionary that will contain your sprites. Something like:
code :
hexagonSprites_ = [[NSMutableDictionary alloc] init];
NSArray *hexPositions = [[itemPositions valueForKey:myString] valueForKey:@"hexposition"];
int hexCount = [hexPositions count];

for (int i = 0; i < hexCount; i++) {
    NSString *key = [NSString stringWithFormat:@"hexagon%d",i];

    CCSprite *sprite = .... // generate sprite here

    [hexagonSprites_ setObject:sprite forKey:key];
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>level1</key>
    <dict>
        <key>hexposition</key>
        <array>
            <string>{105,160}</string>
            <string>{172.5,199.5}</string>
            <string>{240,238}</string>
            <string>{307.5,199.5}</string>
        </array>
    </dict>
</dict>
</plist>
CGPoint location = CGPointFromString([hexPositions objectAtIndex:i]);
How can I indent all rows in a TableView except the first one?

How can I indent all rows in a TableView except the first one?


By : doj
Date : March 29 2020, 07:55 AM
I hope this helps . You can implement your -tableView:cellForRowAtIndexPath: method like this:
code :
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //get the reference of cell by dequeueing and do any configuration as required
    cell.indentationLevel = indexPath.row == 0 ? 0 : 1;
    cell.indentationWidth = 20.0; //or any width you like
    return cell;
}
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath {
    return indexPath.row  == 0 ? 0 : 1;
}
Indent n rows n times

Indent n rows n times


By : user2251154
Date : March 29 2020, 07:55 AM
may help you . You could combine block selection with what you're already doing i.e.
V5j5>
Split/separate rows in to columns by indent

Split/separate rows in to columns by indent


By : Андрей Бес
Date : March 29 2020, 07:55 AM
it helps some times I have a large .csv file where the column variables are nested/indented rows: , It is better to have a reproducible example. Here's one to start:
code :
df <- data.frame(x=c('a', ' b', '  c', ' d', 'e'), y = 1:5, stringsAsFactors=F)
df
    x y
1   a 1
2   b 2
3   c 3
4   d 4
5   e 5
spaces <- gregexpr('\\s', df$x)
counts <- lapply(spaces, attr, which='match.length')
indx <- lapply(counts, function(x) length(x[x > 0]))
df$z <- indx
df
    x y z
1   a 1 0
2   b 2 1
3   c 3 2
4   d 4 1
5   e 5 0
newdf <- data.frame(x=c(rep('a', 4), 'e'), 
                    one= c(NA,'b', 'b', 'd',NA), 
                    two= c(NA, NA, 'c', NA, NA), y=1:5)
newdf
  x  one  two y
1 a <NA> <NA> 1
2 a    b <NA> 2
3 a    b    c 3
4 a    d <NA> 4
5 e <NA> <NA> 5
Replacing hexagons with destroyed hexagons

Replacing hexagons with destroyed hexagons


By : user3143947
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I want to replace the destroyed hexagons with other standing hexagons. Existing hexagons should fall from the top. For example if I destroy (0,2) positioned hexagon in the picture below, the top left hexagon which position of that hexagon is (0,0) should be moved to (0,2) position and i should create a new hexagon and put it on (0,0) which is empty now because we moved the hexagon on (0,0) to (0,2) earlier. , Explanation for code is in comments:
code :
void HexagonFall(GameObject[,] hexArray)
{
    // Handle fall for base columns and for offset columns
    for (int offset = 0 ; offset < 2 ; offset++)
    {
        // Handle fall for each column at current offset
        for (int x = 0 ; x < hexArray.GetLength(0) ; x++)
        {
            int bottomYIndex = hexArray.GetLength(1) - offset - 1;

            // List of indices of where each hexagon in that column will come from.
            // We will fill from bottom to top.
            List<Vector2Int> sourceIndices = new List<Vector2Int>();

            for (int y = bottomYIndex ; y >= 0 ; y-=2)
            {
                // HexExists returns true if the hex isn't empty. 
                // Something along the lines of ` return input!=null; `
                // depending on what "empty" hexes look like in the array

                if (HexExists(hexArray[x,y]))
                {
                    sourceIndices.Add(new Vector2Int(x,y));
                }
            }

            // We have a list of where to get each bottom hexes from, now do the move/create
            for (int y = bottomYIndex; y >= 0 ; y-=2)
            {
                if (sourceIndices.Count > 0)
                {
                    // If we have any available hexes in column,
                    // use the bottommost one (at index 0)
                    hexArray[x,y] = hexArray[sourceIndices[0].x, sourceIndices[0].y];

                    // We have now found a home for hex previously at sourceIndices[0].
                    // Remove that index from list so hex will stay put.
                    sourceIndices.RemoveAt(0);
                }
                else 
                {
                    // Otherwise, we need to generate a new hex
                    hexArray[x,y] = MakeNewHexAt(new Vector2Int(x,y));
                }

                // Tell the hex about its new home
                hexArray[x,y].GetComponent<HexCoordinates>().Coordinates = new Vector2Int(x, y);
                hexArray[x,y].transform.name = "X: " + x + " | Y: " + y;
            }            
        }
    }
}
List<Vector2Int> HexToBeDestroyed = new List<Vector2Int>();

// ...

if (MatchedColors == 2)
{
    if(!HexToBeDestroyed.Contains(new Vector2Int(x, y))
        HexToBeDestroyed.Add(new Vector2Int(x, y));

    if (!HexToBeDestroyed.Contains(new Vector2Int(x - 1, y))
        HexToBeDestroyed.Add(new Vector2Int(x - 1, y));

    if (!HexToBeDestroyed.Contains(new Vector2Int(x - 1, y - 1)))
        HexToBeDestroyed.Add(new Vector2Int(x - 1, y - 1));
}

// ...

foreach (Vector2Int V in HexToBeDestroyed)
{
    if (Hexagons[V.x,V.y] != null)
    {
        Destroy(Hexagons[V.x,V.y]);
        Hexagons[V.x,V.y] = null;
    }
}
float fallSpeed = 0.5f;

Vector2 goalWorldPosition = GS.CalcWorldPos(Coordinates);

transform.position = Vector2.MoveTowards(transform.position, goalWorldPosition, fallSpeed * Time.deltaTime);
Related Posts Related Posts :
  • RouterLink is not working properly dynamically in angular 6
  • Simple HTML rendering issue
  • Best Approach to separate Form sections
  • How to Organize Phonegap HTML Files
  • Wrap a long single word using CSS
  • I am trying to implement a hover effect using CSS3 Transitions
  • How can I avoid hard coding line height while vertically centering element in a div?
  • Bootstrap3 - Removed container-fluid
  • Bootstrap framework not responsive for asp.net webform
  • How to align two inner divs inside outer absolute positioned div that has fixed width in which both divs have the same w
  • Div to ignore html tags
  • Prevent caching and stale content with a static web site
  • Is there a way to change the whole document with one selector in CSS?
  • why cant I click om my navigationbar links?
  • Is there a CSS/HTML way to cut multiple shapes out of the top/bottom of a div?
  • css border around multiple links/images
  • 'No data was received in the uploaded file', but file is not empty
  • How input boxes save previous entries
  • AMP carousel direction change
  • Bootstrap multiple carousel not working on thumbnails click
  • Is there a way to put a permanent space into an input field?
  • Html boxes not displaying properly
  • How can I change a variable in Jekyll _config.yml dynamically?
  • How can I prevent DIVs from overlapping a right floated image?
  • Eclipse and .tml files highlighting not working
  • Footer is not in the bottom of the window, (phonegap jquery mobile app for windows mobile)
  • How to put div over another
  • How to use glyphicons in bootstrap 3.0
  • Wordpress page links not working
  • How Do I Use CSS to Set the Color of An ALink?
  • Webpage doesn't scroll smoothly on screen
  • YouTube iframe, browser looks for file locally
  • html displaying inline image
  • Font acting differently on IE and Firefox
  • Encoding and decoding of the character references
  • An Image Button navigate to another site html/css
  • IE8 "Save Target as ..." won't display for block elements
  • Image hover transition for span - CSS
  • How to apply min and max on textarea?
  • How to draw multiple horizontal lines (Notebook Paper effect) using css?
  • Table Printing Issue: Gaps in top and Bottom Border of th Elements
  • grouping elements with div and applying stylesheet for that group
  • Click <div> to expand, then click again to shrink - Its expanding, just not shrinking
  • CSS - How can I center a <script>'s output?
  • Django's template variable gets interpreted as HTML
  • ngx datatable vertical scroll with rowheight set to auto
  • How to make input text border with CSS when it's OnFocus
  • Anyone know of a calendar web widget for my website I could use?
  • How does Bootstrap manage to use fixed positioning for navbar on iOS?
  • Centered text in fully clickable table cell
  • Compare HTML and HTML5
  • steps of creating webpage in bangla
  • css root element margin
  • What is the point of using absolute positioning in CSS?
  • Responsive solution for long URLs (that exceed the device width)
  • Divs don't collapse as they should - media queries
  • QTreeWidgetItem display html
  • Testing html/css image on local from jfiddle
  • long attribute value of HTML
  • Why my svg picture is truncated at the bottom when embedded in html
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org