-
Notifications
You must be signed in to change notification settings - Fork 0
/
aquarelle.php
76 lines (68 loc) · 2.96 KB
/
aquarelle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Partial: aquarelle.php
*
* @package: WordPress
* @sub-package: maat-or-the-improved-bootstrap
*
* Aquarelle Library Sample
?>
<?php
/**
* Enqueue additional scripts
*/
/*
add this to functions.php:
function petjmaatFpScripts() {
wp_enqueue_script( 'three.js', get_template_directory_uri() . 'bower_components/three.js/build/three.js', array(), '1.0.0', true );
wp_enqueue_script( 'Aquarelle.js', get_template_directory_uri() . 'bower_components/aquarelle/Aquarelle.js', array(), '1.0.0', true );
wp_enqueue_script( 'EffectComposer.js', get_template_directory_uri() . 'bower_components/three.js/examples/js/postprocessing/EffectComposer.js', array(), '1.0.0', true );
wp_enqueue_script( 'ClearPass.js', get_template_directory_uri() . 'bower_components/three.js/examples/js/postprocessing/ClearPass.js', array(), '1.0.0', true );
wp_enqueue_script( 'AquarellePass.js', get_template_directory_uri() . 'bower_components/aquarelle/AquarellePass.js', array(), '1.0.0', true );
wp_enqueue_script( 'Shaderpass.js', get_template_directory_uri() . 'bower_components/three.js/examples/js/postprocessing/ShaderPass.js', array(), '1.0.0', true );
wp_enqueue_script( 'CopyShader.js', get_template_directory_uri() . 'bower_components/three.js/examples/js/shaders/CopyShader.js', array(), '1.0.0', true );
// the last one should be a local copy ...
wp_enqueue_script( 'GeomContour.js', 'https://bl.ocks.org/mbostock/raw/4241134/d3.geom.contour.min.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'petjmaatFpScripts' );
*/
?>
<H3>Aquarelle</H3>
<p>Here's a JavaScript Plugin</p>
<div id="animeret">
<img class="aquarelleImg" src="<?php bloginfo('template_url')?>/images/multimusen.png"><!-- watercolor effect image -->
</div>
<h5>Specificaitons </h5>
<ul>
<li>Enqueue scripts (funcitons.php)</li>
<li>Template parts (aquarelle.php)</li>
<li>Use template parts (index.php)</li>
</ul>
<!-- for the aquarelle animation -->
<script>
/**
* Billedet som skal manipuleres fra DOM
*/
var image = document.getElementsByTagName('img')[1]; // nb: address the correct image here ...
//var image = document.getElementsByClass('aquarelleImg')['0'];
/**
* Billede og maske kombineres
*/
var aquarelle = new Aquarelle(
'<?php bloginfo('template_url')?>/images/multimusen.png',
'<?php bloginfo('template_url')?>/images/mask.png', {
autoplay: true,
loop: false
}); // loop (false: holder op, true: looper)
/**
* Eventlistener
* Renser og genskaber canvas
* = animation
*/
aquarelle.addEventListener('created', function() {
var canvas = this.getCanvas(); // skaber canvas
canvas.removeAttribute('style'); // fjerner en attribut
image.parentNode.insertBefore(canvas, image.nextSibling); // næste billedinstans indsættes
image.parentNode.removeChild(image); // fjerner unødvendigt billede
});
</script>