Giter Site home page Giter Site logo

mitgobla / topograpy Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 27.3 MB

A Topograph Coordinate Generator in Python

Home Page: http://www.mitgobla.cf

License: MIT License

Python 100.00%
python python-3 python-3-5 heightmap topography coordinates generator windows windows-10

topograpy's Introduction

HitCount

TopograPy

A Height Map Coordinate Generator in Python. Windows Only. Please note: this program is being completely re-programmed to add more coordinate generation options to suit generation of height maps in different forms. As of the current version, it only supports being generated onto a 2D canvas that can't be rotated; I am planning on changing this in the future.

Installing Requirements

Pillow is the only requirement for this module and it is used for reading images. To install, use:

pip install pillow

Setup

ToporaPy is not available on PyPI yet, but you can still install the master branch through pip with the following command:

pip install -e git+https://github.com/mitgobla/TopograPy.git@master#egg=topograpy

Alternatively, you can get future versions that have not been release to the master branch by using the following:

pip install -e git+https://github.com/mitgobla/TopograPy.git@future#egg=topograpy

Example Usage

Here's a video of a render of a Grand Canyon height map, that used this module in line with PyOpenGL and PyGame. Click to watch on YouTube

Example Code

import topograpy

cross_section = topograpy.CrossSection()
graph = topograpy.SectionCalculation()

topograph = cross_section.calculate("height_map.png", graph)
coordinates = cross_section.return_coordinates()
image_size = coordinates[2] # Tuple of image x and y size
heights = graph.return_darkness() # The height of each line based on height % of image

To get the darkness (height factor) for a specific pixel:

>>> heights[x_coordinate][y_coordinate]
>>> heights[0][0]
25
# The higher the number, the 'taller' the pixel on the height map

Generator for creating two sets of coordinates to generate a line.

generated_coordinates = [[], []]
for x_coord in range(image_size[0]):
    for y_coord in range(image_size[1]):
        generated_coordinates[0].append((x_coord, heights[x_coord][y_coord], y_coord)
        generated_coordinates[1].append((x_coord, 0, y_coord))

This will generate a list with two lists xyz1 and xyz2

>>> generated_coordinates[0][0]
(0, 25, 0)
>>> generated_coordinates[1][0]
(0, 0, 0)

topograpy's People

Contributors

mitgobla avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

topograpy's Issues

Flipped Coordinates

Currently the coordinates are generated flipped. I cannot use reverse() since this rotates the coordinates.
E.g iteration from pixel X 1 Y 1 to pixel X 1028 Y 1 creates coordinates up to 1028 X and 1028 Y

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.