Download the PHP package szczyglis/php-ulam-spiral-generator without Composer

On this page you can find all versions of the php package szczyglis/php-ulam-spiral-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-ulam-spiral-generator

Release: 1.2.3 | build: 2024.08.26 | PHP: ^7.2.5|^8.0

Ulam Spiral Generator

A mathematical Ulam spiral generator and renderer with programmable callbacks written in PHP.

Live Demo: https://szczyglis.dev/ulam-spiral-generator

What is Ulam spiral?

from https://en.wikipedia.org/wiki/Ulam_spiral:

The Ulam spiral or prime spiral is a graphical depiction of the set of prime numbers, devised by mathematician Stanisław Ulam in 1963 and popularized in Martin Gardner's Mathematical Games column in Scientific American a short time later. It is constructed by writing the positive integers in a square spiral and specially marking the prime numbers. [...]

300px-Ulam_1

How to install

Features

Usage example

You can use any PHP array filled with numbers or characters in the $ulam->dataset. All values from the array will be placed in the spiral.

After executing $ulam->buildMatrix(), the matrix created by this method will be available in the $ulam->matrix array. The x and y coordinates corresponding to the values placed in the spiral will be available in the $ulam->coords array. You can access the matrix using the $ulam->getMatrix() method.

Screenshots

CSS-styled version:

gggg

Raw version:

spiral_raw

Repository includes

Configuration

You can configure the generator by creating a $config array and passing it into the constructor.

All keys in the array are described below:

Defining custom callbacks

Number Highlighting

You can create your own marker callback to highlight specific numbers (e.g., prime numbers, even numbers, numbers greater than a specified value, etc.). The callback takes one argument, which is the current number, and must return an HTML color code to use for highlighting. If the callback returns null or false, the number will not be affected. You can create as many markers as you like, each for a different type of number.

The following example demonstrates how to create a marker callback for even numbers:

Screenshot with Even Numbers highlighted

mark_even

Screenshot with Prime Numbers highlighted

mark_prime

Number Counters per Row/Column

Counter callbacks are used for creating counters in the spiral headers (horizontal and vertical). Counters can count specific numbers in a row or column and display the result in the row or column header. There are two types of counters: count and sum. You can choose the behavior in the config.

The first type - count - counts all occurrences of a specified type of number in a row or column. The second type - sum - displays the sum of their values. If the callback returns true, then the number will be affected by the counter. You can create as many counters as you like, each for a different type of number.

The following example shows how to create a counter callback for even numbers:

Screenshot with Even Numbers counted in header

count_even

Screenshot with Prime Numbers counted in header

nnnn

Highlighting Rows, Columns, and Crosses on Mouse Hover

hhhhhh

Changelog


Ulam Spiral Generator is free to use, but if you like it, you can support my work by buying me a coffee ;)

https://www.buymeacoffee.com/szczyglis

Enjoy!

MIT License | 2022 Marcin 'szczyglis' Szczygliński

https://github.com/szczyglis-dev/php-ulam-spiral-generator

https://szczyglis.dev/ulam-spiral-generator

Contact: [email protected]


All versions of php-ulam-spiral-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2.5|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package szczyglis/php-ulam-spiral-generator contains the following files

Loading the files please wait ....