PHPackages                             a1essandro/diamond-and-square - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. a1essandro/diamond-and-square

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

a1essandro/diamond-and-square
=============================

Algorithm for generating heightmaps

v2.3.0(9y ago)21199MITPHPPHP &gt;=5.3.0

Since Oct 26Pushed 8y ago3 watchersCompare

[ Source](https://github.com/A1essandro/Diamond-And-Square)[ Packagist](https://packagist.org/packages/a1essandro/diamond-and-square)[ RSS](/packages/a1essandro-diamond-and-square/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

Diamond And Square (PHP)
========================

[](#diamond-and-square-php)

[![Build Status](https://camo.githubusercontent.com/879c9fb2fd0131681cf84c54ca378d516a615d46f51f37e87d3702e707770fc7/68747470733a2f2f7472617669732d63692e6f72672f4131657373616e64726f2f4469616d6f6e642d416e642d5371756172652e737667)](https://travis-ci.org/A1essandro/Diamond-And-Square) [![Coverage Status](https://camo.githubusercontent.com/fb79ac73f9806d0424d7adf2e10262ac6a3080452a4209872da81e897da4bbc2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f4131657373616e64726f2f4469616d6f6e642d416e642d5371756172652f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/A1essandro/Diamond-And-Square?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/a82a0ca91dfd319da1fbfef3e2fb2d1927549e269df69cd7d04e32319fa57243/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6469616d6f6e642d616e642d7371756172652f762f737461626c65)](https://packagist.org/packages/a1essandro/diamond-and-square) [![Total Downloads](https://camo.githubusercontent.com/09990ada545110068eec672898892a97bf47eb6099a929c074dd79eb62ddb0a1/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6469616d6f6e642d616e642d7371756172652f646f776e6c6f616473)](https://packagist.org/packages/a1essandro/diamond-and-square) [![Latest Unstable Version](https://camo.githubusercontent.com/1e4f66549eeffa9b467a757999137da23871dc403a9cc9c2ee00fbb716d8dec6/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6469616d6f6e642d616e642d7371756172652f762f756e737461626c65)](https://packagist.org/packages/a1essandro/diamond-and-square) [![License](https://camo.githubusercontent.com/c6ed59af54d82a45699a8d218982ad1d7ae6cd8db37b93cc703a9f5d33fe100c/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6469616d6f6e642d616e642d7371756172652f6c6963656e7365)](https://packagist.org/packages/a1essandro/diamond-and-square)

Algorithm for generating heightmaps on PHP.

See also [Perlin-Noise algorithm](https://github.com/A1essandro/perlin-noise-generator) with the similar API.

Algorithm
---------

[](#algorithm)

### Steps

[](#steps)

[![Steps](https://camo.githubusercontent.com/4e0bea1691e4ac064f636051d33ae890e10b4153021a120bb56f491964bcdfb5/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f622f62662f4469616d6f6e645f5371756172652e7376672f3134393970782d4469616d6f6e645f5371756172652e7376672e706e67)](https://camo.githubusercontent.com/4e0bea1691e4ac064f636051d33ae890e10b4153021a120bb56f491964bcdfb5/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f622f62662f4469616d6f6e645f5371756172652e7376672f3134393970782d4469616d6f6e645f5371756172652e7376672e706e67)

*[Image source](https://en.wikipedia.org/wiki/Diamond-square_algorithm)*

See more about diamond-square algorithm on [wiki](https://en.wikipedia.org/wiki/Diamond-square_algorithm)

Requirements
------------

[](#requirements)

This package is only supported on PHP 5.3 and up.

Installing
----------

[](#installing)

### Installing via Composer

[](#installing-via-composer)

See more [getcomposer.org](http://getcomposer.org).

Execute command

```
composer require a1essandro/diamond-and-square ~2.0

```

Usage example
-------------

[](#usage-example)

### Standart

[](#standart)

```
$gen = new DiamondAndSquare();
$gen->setSize(7); //real size equal 2 ^ 7 + 1, i.e. 129
$gen->setPersistence(1.7);
$gen->setMapSeed("1hCaHs5hZ");

$map = $gen->generate();
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~96 days

Total

10

Last Release

3408d ago

Major Versions

v1.0.3 → v2.0.02015-12-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/f54bc66315e4f47b9b435c908356a913db282dd15994a049ac37e217703fdf3b?d=identicon)[A1essandro](/maintainers/A1essandro)

---

Top Contributors

[![A1essandro](https://avatars.githubusercontent.com/u/4727083?v=4)](https://github.com/A1essandro "A1essandro (45 commits)")

---

Tags

algorithmdiamond-squarediamond-square-algorithmgenerating-heightmapsheightmapheightmaps

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/a1essandro-diamond-and-square/health.svg)

```
[![Health](https://phpackages.com/badges/a1essandro-diamond-and-square/health.svg)](https://phpackages.com/packages/a1essandro-diamond-and-square)
```

###  Alternatives

[infection/include-interceptor

Stream Wrapper: Include Interceptor. Allows to replace included (autoloaded) file with another one.

3124.2M5](/packages/infection-include-interceptor)[jeroen/rewindable-generator

Provides a simple adapter to make generators rewindable

1655.4k1](/packages/jeroen-rewindable-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
