diff options
author | Prajwal Mohan <prajwal.karur.mohan@intel.com> | 2012-04-27 15:45:31 -0700 |
---|---|---|
committer | Prajwal Mohan <prajwal.karur.mohan@intel.com> | 2012-04-27 15:45:31 -0700 |
commit | b7ef78844736699e9b96ecfb89853b0ceb6133f9 (patch) | |
tree | 69c7f426404fc2dfbe020984a4722fcbf1a61114 /nyancat | |
download | clutter-toys-b7ef78844736699e9b96ecfb89853b0ceb6133f9.tar.gz clutter-toys-b7ef78844736699e9b96ecfb89853b0ceb6133f9.tar.bz2 clutter-toys-b7ef78844736699e9b96ecfb89853b0ceb6133f9.zip |
Initial Import
Diffstat (limited to 'nyancat')
-rw-r--r-- | nyancat/Makefile | 83 | ||||
-rw-r--r-- | nyancat/nyan.json | 1204 | ||||
-rw-r--r-- | nyancat/nyancat.c | 181 | ||||
-rw-r--r-- | nyancat/star.png | bin | 0 -> 1538 bytes |
4 files changed, 1468 insertions, 0 deletions
diff --git a/nyancat/Makefile b/nyancat/Makefile new file mode 100644 index 0000000..ac0e1ab --- /dev/null +++ b/nyancat/Makefile @@ -0,0 +1,83 @@ +# A generic buildfiles to build single executable directory projects depending +# only on pkg-config ability to build. It automatically names the project on +# the toplevel directory you're in. +# +# Setting additional CFLAGS like $ export CFLAGS=-Wall -Werror # can help you +# track issues down better after compilation. +# +# 20071008 +# Øyvind Kolås (c) 2007 <pippin@gimp.org> placed in the Public Domain. +## + +PKGMODULES = clutter-1.0 + +# you only need to change the following if you want to change where the +# generated tarball gets scp'd to: + +SCP_DESTINATION= + +BINARY=$(shell basename `pwd`)# +PACKAGE=../$(BINARY).tar.bz2 # you can use both .gz and .bz2 as extension here + + +## +# end of template configuration. +# + +# This makefile uses the current directory as the only target binary, and +# expects a single of the .c files to contain a main function. + + + +all: $(BINARY) + +# The help available also contains brief information about the different +# build rules supported. +help: + @echo '' + @echo 'Available targets in this make system' + @echo '' + @echo ' (none) builds $(BINARY)' + @echo ' dist create $(PACKAGE)' + @echo ' clean rm *.o *~ and foo and bar' + @echo ' run ./$(BINARY)' + @echo ' gdb gdb ./$(BINARY)' + @echo ' gdb2 gdb ./$(BINARY) --g-fatal-warnings' + @echo ' scp scp $(PACKAGE) $(SCP_DESTINATION)' + @echo ' help this help' + @echo '' + + +LIBS= $(shell pkg-config --libs $(PKGMODULES)) +INCS= $(shell pkg-config --cflags $(PKGMODULES)) + +CFLAGS+=-Wall +CFILES = $(wildcard *.c) +OBJECTS = $(subst ./,,$(CFILES:.c=.o)) +HFILES = $(wildcard *.h) +%.o: %.c $(HFILES) + $(CC) -g $(CFLAGS) $(INCS) -c $< -o$@ +$(BINARY): $(OBJECTS) + $(CC) -o $@ $(LIBS) $(OBJECTS) +test: run +run: $(BINARY) + ./$(BINARY) + +../$(BINARY).tar.gz: clean $(CFILES) $(HFILES) + cd ..;tar czvhf $(BINARY).tar.gz $(BINARY)/* + @ls -slah ../$(BINARY).tar.gz +../$(BINARY).tar.bz2: clean $(CFILES) $(HFILES) + cd ..;tar cjvhf $(BINARY).tar.bz2 $(BINARY)/* + @ls -slah ../$(BINARY).tar.bz2 + +dist: $(PACKAGE) + echo $(PACKAGE) +scp: dist + scp $(PACKAGE) $(SCP_DESTINATION) + +gdb: all + gdb --args ./$(BINARY) +gdb2: all + gdb --args ./$(BINARY) -demo --g-fatal-warnings +clean: + rm -fvr *.o $(BINARY) *~ *.patch diff --git a/nyancat/nyan.json b/nyancat/nyan.json new file mode 100644 index 0000000..f52eda8 --- /dev/null +++ b/nyancat/nyan.json @@ -0,0 +1,1204 @@ +[ + { + "type":"ClutterGroup", + "id":"nyancat", + "x":300, + "y":100, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"body", + "x":0, + "y":0, + "width":200, + "height":125, + "depth":-1.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#FAD695", + "border-color":"#000000ff", + "border-width":5, + "has-border":true + }, + { + "type":"ClutterGroup", + "id":"head", + "x":100, + "y":25, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"back_head", + "x":0, + "y":0, + "width":170, + "height":100, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true + }, + { + "type":"ClutterRectangle", + "id":"left_cheek", + "x":30, + "y":60, + "width":15, + "height":15, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F7A4A3", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"right_cheek", + "x":130, + "y":60, + "width":15, + "height":15, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F7A4A3", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterGroup", + "id":"left_eye", + "x":50, + "y":40, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"back_left_eye", + "x":0, + "y":0, + "width":15, + "height":15, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#000000", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"front_left_eye", + "x":0, + "y":0, + "width":7, + "height":7, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#ffffff", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + } + ] + }, + { + "type":"ClutterGroup", + "id":"right_eye", + "x":110, + "y":40, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"back_right_eye", + "x":0, + "y":0, + "width":15, + "height":15, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#000000", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"front_right_eye", + "x":0, + "y":0, + "width":7, + "height":7, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#ffffff", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + } + ] + }, + { + "type":"ClutterGroup", + "id":"mounth", + "x":50, + "y":70, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"left_lip", + "x":0, + "y":0, + "width":8, + "height":15, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#000000", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"right_lip", + "x":67, + "y":0, + "width":8, + "height":15, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#000000", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"middle_lip", + "x":35, + "y":5, + "width":8, + "height":10, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#000000", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"bottom_lip", + "x":0, + "y":15, + "width":75, + "height":5, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#000000", + "border-color":"#000000ff", + "border-width":0, + "has-border":false + } + ] + } + ] + }, + { + "type":"ClutterGroup", + "id":"legs", + "x":-20, + "y":0, + "width":0, + "height":0, + "depth":-3.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"back_leg1", + "x":0, + "y":140, + "width":50, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":-45.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true + }, + { + "type":"ClutterRectangle", + "id":"back_leg2", + "x":50, + "y":140, + "width":50, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":-45.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true + }, + { + "type":"ClutterRectangle", + "id":"front_leg1", + "x":150, + "y":105, + "width":50, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":45.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true + }, + { + "type":"ClutterRectangle", + "id":"front_leg2", + "x":200, + "y":105, + "width":50, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":45.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true + } + ] + }, + { + "type":"ClutterGroup", + "id":"tail", + "x":-60, + "y":50, + "width":0, + "height":0, + "depth":-2.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"tail1", + "x":0, + "y":0, + "width":30, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true, + "clip": [ 0, 0, 25, 30 ] + }, + { + "type":"ClutterRectangle", + "id":"tail2", + "x":20, + "y":0, + "width":30, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true, + "clip": [ 5, 0, 20, 30 ] + }, + { + "type":"ClutterRectangle", + "id":"tail3", + "x":40, + "y":0, + "width":30, + "height":30, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#A7A5AA", + "border-color":"#000000ff", + "border-width":5, + "has-border":true, + "clip": [ 5, 0, 20, 30 ] + } + ] + }, + { + "type":"ClutterGroup", + "id":"rainbow", + "x":-380, + "y":0, + "width":0, + "height":0, + "depth":-4.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterGroup", + "id":"rainbow1", + "x":0, + "y":0, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"rainbow_brick_red1", + "x":0, + "y":0, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#D91A12", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_orange1", + "x":0, + "y":20, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8960B", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_yellow1", + "x":0, + "y":40, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8E501", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_green1", + "x":0, + "y":60, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#54FE01", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_lightblue1", + "x":0, + "y":80, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#3BAAF2", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_darkblue1", + "x":0, + "y":100, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#6D3DF4", + "has-border":false + } + ] + }, + { + "type":"ClutterGroup", + "id":"rainbow2", + "x":100, + "y":10, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"rainbow_brick_red2", + "x":0, + "y":0, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#D91A12", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_orange2", + "x":0, + "y":20, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8960B", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_yellow2", + "x":0, + "y":40, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8E501", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_green2", + "x":0, + "y":60, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#54FE01", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_lightblue2", + "x":0, + "y":80, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#3BAAF2", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_darkblue2", + "x":0, + "y":100, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#6D3DF4", + "has-border":false + } + ] + }, + { + "type":"ClutterGroup", + "id":"rainbow3", + "x":200, + "y":0, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"rainbow_brick_red3", + "x":0, + "y":0, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#D91A12", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_orange3", + "x":0, + "y":20, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8960B", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_yellow3", + "x":0, + "y":40, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8E501", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_green3", + "x":0, + "y":60, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#54FE01", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_lightblue3", + "x":0, + "y":80, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#3BAAF2", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_darkblue3", + "x":0, + "y":100, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#6D3DF4", + "has-border":false + } + ] + }, + { + "type":"ClutterGroup", + "id":"rainbow4", + "x":300, + "y":10, + "width":0, + "height":0, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "children":[ + { + "type":"ClutterRectangle", + "id":"rainbow_brick_red4", + "x":0, + "y":0, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#D91A12", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_orange4", + "x":0, + "y":20, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8960B", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_yellow4", + "x":0, + "y":40, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#F8E501", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_green4", + "x":0, + "y":60, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#54FE01", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_lightblue4", + "x":0, + "y":80, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#3BAAF2", + "has-border":false + }, + { + "type":"ClutterRectangle", + "id":"rainbow_brick_darkblue4", + "x":0, + "y":100, + "width":100, + "height":20, + "depth":0.000, + "opacity":255, + "scale-x":1.000, + "scale-y":1.000, + "rotation-angle-z":0.000, + "anchor-x":0.000, + "anchor-y":0.000, + "color":"#6D3DF4", + "has-border":false + } + ] + } + ] + } + ] + }, + { + "type":"ClutterState", + "id":"legs-tail-states", + "duration":200, + "transitions":[ + { + "source":null, + "target":"legs-up", + "keys":[ + [ + "rainbow1", + "y", + "linear", + 10.0, + 0.000000, + 0.000000 + ], + [ + "rainbow2", + "y", + "linear", + -10.000, + 0.000000, + 0.000000 + ], + [ + "rainbow3", + "y", + "linear", + 10.000, + 0.000000, + 0.000000 + ], + [ + "rainbow4", + "y", + "linear", + -10.000, + 0.000000, + 0.000000 + ], + [ + "legs", + "y", + "linear", + -10.000, + 0.000000, + 0.000000 + ], + [ + "tail2", + "y", + "linear", + 10.000, + 0.000000, + 0.000000 + ], + [ + "tail1", + "y", + "linear", + 20.000, + 0.000000, + 0.000000 + ] + ] + }, + { + "source":null, + "target":"legs-down", + "keys":[ + [ + "rainbow1", + "y", + "linear", + -10.0, + 0.000000, + 0.000000 + ], + [ + "rainbow2", + "y", + "linear", + 10.000, + 0.000000, + 0.000000 + ], + [ + "rainbow3", + "y", + "linear", + -10.000, + 0.000000, + 0.000000 + ], + [ + "rainbow4", + "y", + "linear", + 10.000, + 0.000000, + 0.000000 + ], + [ + "legs", + "y", + "linear", + 0.000, + 0.000000, + 0.000000 + ], + [ + "tail2", + "y", + "linear", + -10.000, + 0.000000, + 0.000000 + ], + [ + "tail1", + "y", + "linear", + -20.000, + 0.000000, + 0.000000 + ] + ] + } + ] + }, + { + "type":"ClutterState", + "id":"head-states", + "duration":100, + "transitions":[ + { + "source":null, + "target":"head-up", + "keys":[ + [ + "head", + "x", + "linear", + 100.0, + 0.000000, + 0.000000 + ], + [ + "head", + "y", + "linear", + 25.0, + 0.000000, + 0.000000 + ] + ] + }, + { + "source":null, + "target":"head-right", + "keys":[ + [ + "head", + "x", + "linear", + 110.0, + 0.000000, + 0.000000 + ], + [ + "head", + "y", + "linear", + 30.0, + 0.000000, + 0.000000 + ] + ] + }, + { + "source":null, + "target":"head-down", + "keys":[ + [ + "head", + "x", + "linear", + 100.0, + 0.000000, + 0.000000 + ], + [ + "head", + "y", + "linear", + 35.0, + 0.000000, + 0.000000 + ] + ] + }, + { + "source":null, + "target":"head-left", + "keys":[ + [ + "head", + "x", + "linear", + 90.0, + 0.000000, + 0.000000 + ], + [ + "head", + "y", + "linear", + 30.0, + 0.000000, + 0.000000 + ] + ] + } + ] + } +] diff --git a/nyancat/nyancat.c b/nyancat/nyancat.c new file mode 100644 index 0000000..8fde7b8 --- /dev/null +++ b/nyancat/nyancat.c @@ -0,0 +1,181 @@ +#include <string.h> + +#include <clutter/clutter.h> + +#define SCALE_X_VARIANCE 0.3 +#define SCALE_Y_VARIANCE 0.2 +#define ROT_Z_VARIANCE 0.1 +#define ALPHA_VARIANCE 0.5 +#define ANIM_LENGTH 10000 +#define ANIM_VARIANCE 0.3 +#define OPACITY 0.60 +#define OPACITY_VARIANCE 0.33 +#define HEIGHT 0.85 +#define HEIGHT_VARIANCE 0.2 +#define HEIGHT_DROP 1.7 + +static void +legs_state_completed (ClutterState *state, gpointer data) +{ + const gchar *state_name = clutter_state_get_state (state); + + if (!strcmp (state_name, "legs-up")) + clutter_state_set_state (state, "legs-down"); + else + clutter_state_set_state (state, "legs-up"); +} + +static void +head_state_completed (ClutterState *state, gpointer data) +{ + const gchar *state_name = clutter_state_get_state (state); + + if (!strcmp (state_name, "head-up")) + clutter_state_set_state (state, "head-right"); + else if (!strcmp (state_name, "head-right")) + clutter_state_set_state (state, "head-down"); + else if (!strcmp (state_name, "head-down")) + clutter_state_set_state (state, "head-left"); + else if (!strcmp (state_name, "head-left")) + clutter_state_set_state (state, "head-up"); +} + +static inline gdouble +get_variance (gdouble value, gdouble constant) +{ + return value + value * (2.0 * g_random_double () - 1.0) * constant; +} + +static gboolean +create_cloud(ClutterActor *cloud_texture) +{ + ClutterPerspective perspective; + ClutterAnimator *animator; + ClutterTimeline *timeline; + guint8 opacity; + gfloat cloud_width; + gfloat stage_width, stage_height; + + ClutterActor *stage = clutter_stage_get_default (); + ClutterActor *cloud = clutter_clone_new (cloud_texture); + + stage_width = clutter_actor_get_width (stage); + stage_height = clutter_actor_get_height (stage); + cloud_width = clutter_actor_get_width (cloud); + + clutter_actor_set_scale_with_gravity (cloud, + get_variance (1, SCALE_X_VARIANCE), + get_variance (1, SCALE_Y_VARIANCE), + CLUTTER_GRAVITY_CENTER); + clutter_actor_set_z_rotation_from_gravity (cloud, + get_variance (360, ROT_Z_VARIANCE), + CLUTTER_GRAVITY_CENTER); + clutter_actor_set_y (cloud, + g_random_double_range (-clutter_actor_get_height (cloud), + stage_height)); + + clutter_container_add_actor (CLUTTER_CONTAINER (stage), cloud); + clutter_actor_lower_bottom (cloud); + + clutter_actor_show (cloud); + + clutter_stage_get_perspective (CLUTTER_STAGE (stage), &perspective); + + animator = clutter_animator_new(); + opacity = (guint8)(get_variance (OPACITY, OPACITY_VARIANCE) * 255.0); + clutter_animator_set (animator, + cloud, "x", CLUTTER_LINEAR, 0.0, stage_width, + cloud, "opacity", CLUTTER_LINEAR, 0.0, 0, + cloud, "opacity", CLUTTER_EASE_IN_CUBIC, 0.15, opacity, + cloud, "opacity", CLUTTER_LINEAR, 0.85, opacity, + cloud, "opacity", CLUTTER_EASE_OUT_CUBIC, 1.0, 0, + cloud, "x", CLUTTER_LINEAR, 1.0, -cloud_width, + NULL); + + clutter_animator_set_duration (animator, + get_variance (ANIM_LENGTH, ANIM_VARIANCE)); + timeline = clutter_animator_get_timeline (animator); + g_signal_connect_swapped (timeline, "completed", + G_CALLBACK (clutter_actor_destroy), cloud); + + g_object_weak_ref (G_OBJECT (cloud), (GWeakNotify)g_object_unref, animator); + + clutter_animator_start (animator); + + return TRUE; +} + +int +main (int argc, char *argv[]) +{ + ClutterColor stage_color = { 0x1C, 0x41, 0x70, 0xff }; + ClutterActor *nyancat, *stage, *cloud; + ClutterState *legs_states, *head_states; + ClutterScript *script; + guint source; + GError *error = NULL; + + if (argc < 2) + { + g_warning ("%s file.json", argv[0]); + return 1; + } + + if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) + return 1; + + stage = clutter_stage_get_default (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Clutter Nyan Cat"); + clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + clutter_actor_set_size (stage, 800, 600); + + script = clutter_script_new (); + + clutter_script_load_from_file (script, argv[1], &error); + if (error) + { + g_warning ("Error while loading '%s': %s", argv[1], error->message); + g_error_free (error); + return 1; + } + + /**/ + nyancat = CLUTTER_ACTOR (clutter_script_get_object (script, "nyancat")); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), nyancat); + clutter_actor_raise_top (nyancat); + legs_states = CLUTTER_STATE (clutter_script_get_object (script, + "legs-tail-states")); + head_states = CLUTTER_STATE (clutter_script_get_object (script, + "head-states")); + g_signal_connect (legs_states, "completed", + G_CALLBACK (legs_state_completed), NULL); + g_signal_connect (head_states, "completed", + G_CALLBACK (head_state_completed), NULL); + + /**/ + if (!(cloud = clutter_texture_new_from_file ("star.png", &error))) + { + g_warning ("Error loading image: %s", error->message); + g_error_free (error); + return -1; + } + clutter_actor_set_position (cloud, + -clutter_actor_get_width (cloud), + -clutter_actor_get_height (cloud)); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), cloud); + + source = g_timeout_add_full (CLUTTER_PRIORITY_REDRAW, 1000, + (GSourceFunc)create_cloud, + cloud, NULL); + + clutter_actor_show_all (stage); + + clutter_state_set_state (legs_states, "legs-up"); + clutter_state_set_state (head_states, "head-up"); + + clutter_main (); + + g_source_remove (source); + + return 0; +} diff --git a/nyancat/star.png b/nyancat/star.png Binary files differnew file mode 100644 index 0000000..c614e79 --- /dev/null +++ b/nyancat/star.png |