Coder Social home page Coder Social logo

dankan1890 / godot_vector_graphics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from poke1024/godot_vector_graphics

0.0 1.0 0.0 144 KB

Basic vector graphics in the Godot Editor

License: MIT License

Python 2.49% C++ 96.68% Objective-C 0.83%

godot_vector_graphics's Introduction

Vector Graphics for Godot.

  • This is an experiment
  • It's written in C++ 11, so it's editor-only
  • All vector graphics can be converted into MeshInstance2Ds
  • I have very little time to work on this

Live Demo:

https://www.youtube.com/watch?v=EsTSf5dytbs&feature=youtu.be

Install and build

  • Check out this repo as git clone --recurse-submodules https://github.com/poke1024/godot_vector_graphics
  • Rename the whole repo folder to vector_graphics and move it into your Godot /modules folder (i.e. as /modules/vector_graphics).
  • Build godot using scons platform=your_platform svg=patch.
  • The svg=patch part in the scons build instructs the vector_graphics module to apply a patch, so that you can drag and drop SVGs as vector graphics into Godot (see the SVG Import Patch section below to see what exactly is patched).

Basic usage in Godot

Drag and drop an SVG into the 2d canvas.

Or: add a new VGPath node in your scene (under a Node2D).

In the inspector, set its Renderer to a new VGAdaptiveRenderer. Now, in the toolbar at the top, click on the circle. Drag and drop on the canvas to draw a vector circle.

Select a VGPath and double click onto it (while having the arrow tool selected) to see and edit control points and curves.

You can add new control points by clicking on a curve.

Select a control point and hit the delete key to remove it.

Rendering quality can be changed by editing the VGAdaptiveRenderer's quality setting (lower number means less triangles). You can do this interactively in the Godot editor.

The SVG Import Patch

In order to be able to drag and drop SVG assets into the Godot editor as vector graphics, you need to make one patch in Godot; take a look at the accompanying patches/0001-tovegd-svg-support.patch, which is this:

In editor/canvas_item_editor_plugin.cpp, add

	Node *createVectorSprite(Ref<Resource> p_resource, Node *p_owner);

then replace

	child = memnew(Sprite); // default

with:

	child = createVectorSprite(texture, target_node);

After recompiling, you should now be able to drag and drop an SVG file into your Godot FileSystem. From there you can drag it into your scene, and all SVG paths should get converted into VGPaths.

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.