Coder Social home page Coder Social logo

Comments (2)

familiarcat avatar familiarcat commented on June 11, 2024

Updated your makefile to run with the local npm installed browserify and a global installation of inkscape

all: shapesVis.png game

game: out/gameBuilt.js game.html

.PHONY: all game

# All calls to `browserify` mean bundling all the dependencies into one file,
# for running in a browser or in `svg-pizzabase` into one file (because the
# Node.js `require`-function isn't available in them).

out/gameBuilt.js: game.js out/triangulatedShapes.json
	$$(npm bin)/browserify -o $@ $<

out/triangulatedShapes.json: out/shapes.json shapesToTriangles.js
	# Convert the shape JSON data into triangle JSON data
	node shapesToTriangles.js < out/shapes.json > $@

shapesVis.png : out/shapesVis.svg
	# Rasterise the SVG file to a PNG
	inkscape $(shell pwd)/$< --export-png=$(shell pwd)/$@ --export-area-drawing
	# Flip it vertically (because the y-coordinates we get out of potrace
	# increase in the other direction)
	mogrify -flip $@

out/shapesVis.svg : out/visShapesBuilt.js
	# Create an SVG image from the visualisation code
	$$(npm bin)/svg-pizzabase < $< > $@

out/visShapesBuilt.js: visShapes.js out/shapes.json
	# Create the Javascript to export to SVG
	$$(npm bin)/browserify -o $@ visShapes.js 

out/shapes.json: out/traced.ps convertToShapes.js
	# Parse the traced PostScript file and convert it to a JSON format of
	# shapes.
	node convertToShapes.js < out/traced.ps > $@

out/traced.ps: out/thresholded-alpha.ppm
	@mkdir -p out
	# Trace the thresholded image into a PostScript file, using the most
	# verbose, least-compressed options available.  This makes it easier to
	# parse later.
	potrace --longcoding --postscript --tight --alphamax=0 --cleartext --output=$@ $<

out/thresholded-alpha.ppm: out/alpha.png
	@mkdir -p out
	# Threshold and negate the alpha channel image.  Also convert to the
	# (extremely simple and text-based) PPM image format, because that's what
	# potrace understands.
	convert $< -threshold 75%% -negate $@

out/alpha.png: input.png
	@mkdir -p out
	# Extract the alpha channel into a separate image.
	convert $< -alpha extract $@

clean:
	@# Delete all automatically generated files.
	@rm -rf out/ shapesVis.png

from image-to-box2d-body.

anko avatar anko commented on June 11, 2024

Thanks for noticing!

  • As for locally-installed browserify: for some reason I only committed 8b387ec locally in 2016 and didn't push… 😰 That should fix that.

  • As for Inkscape, why do you suggest this change?:

     shapesVis.png : out/shapesVis.svg
     	# Rasterise the SVG file to a PNG
    -	inkscape $< --export-png=$@ --export-area-drawing
    +	inkscape $(shell pwd)/$< --export-png=$(shell pwd)/$@ --export-area-drawing
    +
     	# Flip it vertically (because the y-coordinates we get out of potrace
     	# increase in the other direction)
     	mogrify -flip $@

    Surely pwd is always the root directory of the project if make is run?

    Unless I am mistaken, the change would have no effect.

from image-to-box2d-body.

Related Issues (2)

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.