It is currently Fri Jun 28, 2024 11:43 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: LED Animation from Animation Plug-in
PostPosted: Thu Mar 30, 2023 2:58 pm  (#1) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3997
Location: Canada
Turn an existing animation (ie: https://giphy.com/gifs/animated-the-bea ... DP1YMziaQw) into a LED-animation like below
Image
Instructions:
1. Scale down an animation (animated gif) so that it's not too big (since each pixel will be treated as a LED bulb).
2. Scale up by 20 times (INTERPOLATION NONE)
3. Run plug-in below from /Python-Fu/LED Animation from Animation...
4. That's it, scale down to taste. and save as animated gif.
5. Enjoy
#!/usr/bin/env python
# LED-animation-from-animation.py
# Created by TT
#
# License: GPLv3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY# without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# To view a copy of the GNU General Public License
# visit: http://www.gnu.org/licenses/gpl.html
#
#
# ------------
#| Change Log |
# ------------
# Rel 1: Initial release

from gimpfu import *
import random
import math
def python_LED_animation_from_animation(image, layer):
   # pdb.gimp_image_undo_group_start(image)
   # pdb.gimp_context_push()
   #YOUR CODE BEGINS=======================
   ledsize = 20;
   led_image = pdb.gimp_image_new(image.width,image.height,RGB)
   pdb.gimp_display_new(led_image)

   #create led light cover layer, LED layer that gives LED effect
   num_patterns,pattern_list = pdb.gimp_patterns_get_list("")
   pdb.gimp_context_set_pattern(pattern_list[0]) #Clipboard
   led = pdb.gimp_layer_new(led_image,ledsize,ledsize,RGBA_IMAGE,"led",100,LAYER_MODE_NORMAL)
   pdb.gimp_image_insert_layer(led_image,led,None,0)
   pdb.gimp_context_set_foreground((0,0,0))
   pdb.gimp_edit_fill(led,FILL_FOREGROUND)
   pdb.gimp_image_select_ellipse(led_image,CHANNEL_OP_REPLACE,2,2,16,16)
   pdb.gimp_edit_clear(led)
   pdb.gimp_image_select_rectangle(led_image,CHANNEL_OP_REPLACE,0,0,ledsize,ledsize)
   pdb.gimp_edit_copy(led)
   pdb.gimp_layer_resize(led,led_image.width,led_image.height,0,0)
   pdb.gimp_selection_none(led_image)
   pdb.gimp_edit_clear(led)
   pdb.gimp_edit_fill(led,FILL_PATTERN)
   # for y in range(0,image.height):
      # for x in range(0,image.width):
         # if (random.randrange(0,100)<burnout):
         #    pdb.gimp_image_select_rectangle(new_image,CHANNEL_OP_REPLACE,x*ledsize,y*ledsize,ledsize,ledsize)
         #    pdb.gimp_edit_fill(led,FILL_FOREGROUND)
   pdb.gimp_selection_none(led_image)
   #animation of LED by altering existing image.
   for i in range(len(image.layers)-1,-1,-1):
      layer = image.layers[i]
      position = pdb.gimp_image_get_item_position(image,layer)
      led_frame = pdb.gimp_layer_new_from_drawable(led,image)
      pdb.gimp_image_insert_layer(image,led_frame,None,position)
      pdb.gimp_image_merge_down(image,led_frame,EXPAND_AS_NECESSARY)
      # if (random.randrange(0,100)<flicker):
      #    pdb.gimp_edit_fill(new_frame,FILL_FOREGROUND)


   #YOUR CODE ENDS ========================
   # pdb.gimp_context_pop()
   # pdb.gimp_image_undo_group_end(image)
   pdb.gimp_displays_flush()
    #return

register(
   "python_fu_LED_animation_from_animation",
   "LED sign animation from animation",
   "LED sign animation from animation",
   "TT",
   "TT",
   "March 30, 2023",
   "<Image>/Python-Fu/LED Animation from Animation...",
   "*",      # Create a new image, don't work on an existing one
   [
   #INPUT BEGINS
   # (PF_INT, "burnout", "Burnout/Broken (Bulbs) Percentage:", 0), # PF_INT8, PF_INT16, PF_INT32  similar but no difference in Python.   
   # (PF_INT, "flicker", "Flicker Percentage:", 0), # PF_INT8, PF_INT16, PF_INT32  similar but no difference in Python.   
   # #(PF_TOGGLE, "method",   "Gray/Method:", 1), # initially True, checked.  Alias PF_BOOL
   # (PF_SPINNER, "colors", "Number of Maximum Colors (randomly):", 16, (1, 32, 1)),
   # (PF_TOGGLE, "varysize",   "Vary up sizes:", 1), # initially True, checked.  Alias PF_BOOL
   # (PF_TOGGLE, "colorbackground",   "Color background randomly:", 0), # initially True, checked.  Alias PF_BOOL
   #(PF_SPINNER, "inc", "Increments (pixels):", 15, (1, 1000, 1)),
   #(PF_SPINNER, "outof", "Best out of:", 100, (1, 1000, 1)),
   #(PF_OPTION, "arrow_side", "Arrows Ends:", SIDE_END, SIDE_NAMES),
   #(PF_TOGGLE, "arrow_close", "Arrows Close:", 0),
   #(PF_SPINNER, "ignorelayers", "Ignore first (no of layers):", 2, (0, 200, 1)),
   #(PF_SPINNER, "shadow_offset_x", "Shadow Offset X:", 6, (-4096,4096,1)),
   #(PF_SPINNER, "shadow_offset_y", "Shadow Offset Y:", 6, (-4096,4096,1)),
   #(PF_SPINNER, "shadow_blur_radius", "Shadow Blur Radius:", 15, (0,1024,1)),
   #(PF_SPINNER, "shadow_opacity", "Shadow Opacity:", 100, (0,100,1)),
   #INPUT ENDS
   ],
   [],
   python_LED_animation_from_animation)

main()

#           (PF_INT, "p0", "_INT:", 0), # PF_INT8, PF_INT16, PF_INT32  similar but no difference in Python.
#           (PF_FLOAT, "p02", "_FLOAT:", 3.141),
#           (PF_STRING, "p03", "_STRING:", "foo"),  # alias PF_VALUE
#           (PF_TEXT, "p04", "TEXT:", "bar"),
#           # PF_VALUE
#           # Pick one from set of choices
#           (PF_OPTION,"p1",   "OPTION:", 0, ["0th","1st","2nd"]), # initially 0th is choice
#           (PF_RADIO, "p16", "RADIO:", 0, (("0th", 1),("1st",0))), # note bool indicates initial setting of buttons
#           # PF_RADIO is usually called a radio button group.
#           # SLIDER, ADJUSTMENT types require the extra parameter of the form (min, max, step).
#           (PF_TOGGLE, "p2",   "TOGGLE:", 1), # initially True, checked.  Alias PF_BOOL
#           # PF_TOGGLE is usually called a checkbox.
#           (PF_SLIDER, "p3", "SLIDER:", 0, (0, 100, 10)),
#           (PF_SPINNER, "p4", "SPINNER:", 21, (1, 1000, 50)),  # alias PF_ADJUSTMENT
#           # Pickers ie combo boxes ie choosers from lists of existing Gimp objects
#           (PF_COLOR, "p14", "_COLOR:", (100, 21, 40) ), # extra param is RGB triple
#           # PF_COLOUR is an alias by aussie PyGimp author lol
#           (PF_IMAGE, "p15", "IMAGE:", None), # should be type gimp.image, but None works
#           (PF_FONT, "p17", "FONT:", 0),
#           (PF_FILE, "p18", "FILE:", 0),
#           (PF_BRUSH, "p19", "BRUSH:", 0),
#           (PF_PATTERN, "p20", "PATTERN:", 0),
#           (PF_GRADIENT, "p21", "GRADIENT:", 0),
#           (PF_PALETTE, "p22", "PALETTE:", 0),
#           (PF_LAYER, "p23", "LAYER:", None),
#           (PF_CHANNEL, "p24", "CHANNEL:", None),  # ??? Usually empty, I don't know why.
#           (PF_DRAWABLE, "p25", "DRAWABLE:", None),
#           # Mostly undocumented, but work
#           (PF_VECTORS, "p26", "VECTORS:", None),
#           (PF_FILENAME, "p27", "FILENAME:", 0),
#           (PF_DIRNAME, "p28", "DIRNAME:", 0)
#           # PF_REGION might work but probably of little use.  See gimpfu.py.


_________________
TinT


Last edited by trandoductin on Sat Apr 01, 2023 6:24 am, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: LED Animation from Animation Plug-in
PostPosted: Thu Mar 30, 2023 4:25 pm  (#2) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3997
Location: Canada
Image

_________________
TinT


Top
 Post subject: Re: LED Animation from Animation Plug-in
PostPosted: Sat Apr 01, 2023 6:12 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
Hi Tim.
Small conflict: in two different plugins (LED Animation.py and LED Animation from Animation.py) You used an identical name for 'registry': "python_fu_LED_animation" (so only one plugin shows up in the menu) ;)


Attachments:
Bunny.gif
Bunny.gif [ 3.63 MiB | Viewed 1153 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: LED Animation from Animation Plug-in
PostPosted: Sat Apr 01, 2023 6:23 am  (#4) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3997
Location: Canada
cut and paste error :D

_________________
TinT


Top
 Post subject: Re: LED Animation from Animation Plug-in
PostPosted: Mon Apr 03, 2023 1:21 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
Pretty cool DMD effect as well, Tran. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: LED Animation from Animation Plug-in
PostPosted: Mon Apr 03, 2023 4:28 am  (#6) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3997
Location: Canada
had to look up DMD but Thanks!

_________________
TinT


Top
 Post subject: Re: LED Animation from Animation Plug-in
PostPosted: Tue Apr 04, 2023 1:11 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
Just a pinball player wannabee, Tran so know of such things as dot matrix displays. lol

:)

_________________
Lyle

Psalm 109:8

Image


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) LED-Animation Plug-in

9

No new posts Seamless Gif Animation plug-in

0

No new posts Attachment(s) Bring-in Animation Plug-in

23

No new posts Attachment(s) Sliding-into-Place Animation Plug-in

5

No new posts gif animation

12



* Login  



Powered by phpBB3 © phpBB Group