-
Notifications
You must be signed in to change notification settings - Fork 639
Extending
Vilius edited this page Feb 18, 2018
·
8 revisions
miniPaint can be extended, modified by adding:
- modules - extra functionality accessed from menu.
- tools - extra tool in left sidebar. It can be accessed fast and easy, but GUI has limited numbers of space there.
- Register new menu on src/js/config-menu.js (example:
<li><a class="trn" data-target="effects/example.functionName" href="#">Title</a>
) - Create module file in src/js/modules/effects/example.js.
- Add class with method
functionName
, which will be called on new menu click. - Add your functionality. You can check existing examples to help you.
- Test.
- Register your new tool in src/js/config.js, on variable
config.TOOLS
. - Create new file src/js/tools/example.js.
- Add class with methods
load
(will be called on app load one time) andrender
(will be called every time when app needs to re-render canvas). - Add your functionality. You can check existing examples to help you.
- Test.
- To include files, for example something.js, use:
import config from './something.js';
(path must be related). Most common included files will be src/js/config.js, src/js/core/base-layers.js. - Don't forget to export yourclass, for example:
export default Example_class;
- Make sure your code works with all types of objects. To test all types, open
images/json-test.json
file with miniPaint. - You also can access some global objects after onload event:
window.Layers
,window.AppConfig
.
Related: Examples, Base_layers_class