Thursday, April 28, 2016

Checking to see if two periods of time overlap/interfere with each other.

Here are all possible cases/scenerios of two periods T1 and T2

Case 1
T1 |------|
T2          |------|

Case 2
T1 |------|
T2     |------|

Case 3
T1 |---------|
T2   |-----|

Case 4
T1   |----|
T2 |---------|

Case 5
T1    |------|
T2 |------|

Case 6
T1        |------|
T2 |-----|

In these cases, if we carefully observe we see that in Case 2,3,4 and 5 the periods overlap each other.  Where case 1 and case 6 do not.

If we carefully look at all 4 cases that overlap we will notice that for these cases this condition happens (T1.start < T2.end) AND (T1.end > T2.start)so to check for overlap we simply apply the above bolded check.

Monday, April 25, 2016

A GIMP script-fu to generate randomly rotated characters characters to fill your selection

(define (script-fu-random-font image layer 
            font
            font-size  
            characters   
         )
 
  (let* 
     (
     (width (car (gimp-image-width image)))
     (height (car (gimp-image-height image)))
     (count 0)
     (text-layer 0)
     (layer-width 0)
     (layer-height 0)
     (x 0)
     (y 0)
     (layer-count 0)
     (layer-counter 0)
     (layers 0)
     (layer 0)
     (alphabet '("a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
 "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" 
"y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" 
"M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"))
     )
   ;(gimp-image-undo-disable image); DN = NO UNDO
   
   (gimp-image-undo-group-start image);undo-group in one step
   
   
   (set! layer-count (car (gimp-image-get-layers image)))
   (set! layers (cadr (gimp-image-get-layers image)))
   ;make all layers invisible
   (set! layer-counter 0)
   (while (< layer-counter layer-count)
    (set! layer (vector-ref layers layer-counter))
    (gimp-item-set-visible layer FALSE)
    (set! layer-counter (+ layer-counter 1))
   )
   
   
   (while (< count characters)
       (set! x (rand width))
    (set! y (rand height))
    (if (> (car (gimp-selection-value image x y)) 0)
        (begin
    
     (gimp-context-set-foreground (list 
                                  (rand 256)(rand 256)(rand 256))
     )
     (set! text-layer (car (gimp-text-layer-new image 
                            (list-ref alphabet (rand 52)
                           )
              font
              font-size
              0
            )
          )
     )
     (gimp-image-insert-layer image text-layer 0 0)
     (gimp-item-transform-rotate text-layer 
                (/(*(*(rand 360)2)3.1415) 360)
                 TRUE 0 0
     )
     (set! layer-width 
           (/ (car (gimp-drawable-width text-layer)) 2)
     )
     (set! layer-height 
           (/ (car (gimp-drawable-height text-layer)) 2)
     )
     (gimp-layer-translate text-layer (- x layer-width) 
                                      (- y layer-height)
     )
     (set! count (+ count 1))
     )
     (begin
     )
    )
   )
   (set! text-layer (car (gimp-image-merge-visible-layers image 0)))
   (gimp-image-set-active-layer image text-layer)
   (gimp-selection-invert image)
   (gimp-edit-cut text-layer)
   (gimp-selection-invert image)
   ;make all original layers visible
   (set! layer-counter 0)
   (while (< layer-counter layer-count)
    (set! layer (vector-ref layers layer-counter))
    (gimp-item-set-visible layer TRUE)
    (set! layer-counter (+ layer-counter 1))
   )
   
   
     ;(gimp-image-undo-enable image) ;DN = NO UNDO
   (gimp-image-undo-group-end image)                     ;undo group in one step
   (gimp-displays-flush)
     )
 
 
    
) ;end of define
(script-fu-register
  "script-fu-random-font"         ;function name
  "/Script-Fu/Create New/Random Font ...";menu register
  "Creates A random font background";description
  "Tin Tran"                      ;author name
  "copyright info and description";copyright info or description
  "2016"                          ;date
  "RGB*, GRAY*"                        ;mode
  SF-IMAGE      "Image" 0                   
  SF-DRAWABLE   "Layer" 0
  SF-FONT "Font" "Sans"
  SF-ADJUSTMENT "Font Size(pixels)" '(50 10 8000 1 10 0 0)
  SF-ADJUSTMENT "Characters to generate" '(200 10 8000 1 10 0 0)
)

----------This GIMP Script Fu can be found here on GIMPCHAT.COM forum.

Sunday, April 24, 2016

Design/Print your own stardard envelopes (for free)

I thought i would design a standard size envelope that fits on 8.5"x11" sheet of paper so people could print out then fold and glue to create their own envelopes.

Here's the design (72ppi).
right click then view image to see actual size
I also created this in GIMP. so if you want you can download the .xcf (gimp file) to help you redesign yourself.  The file has many layers and a path used to stroke the fold/cutting lines.  You can just turn on/off each layer and add your own layers to the design.  Here's the .xcf file:
download .xcf file

For Christmas, you could use something like this design
right click then view image to see actual size
For Valentines, you could use something like this design
right click then view image to see actual size
Is it great or what? Now if you have access to a color printer, some 8.5"x11" sheet of paper, some scissors and some glue, you can create your own envelopes.

The content of this blog post is also posted at (other locations):
gimpchat.com's forum
quora.com


 UPDATE (redesign of red and blue).
right click then view image to see actual size
updated .xcf
download updated .xcf file

for those who think the red and blue pattern is too fine for the envelope, there's this variation:
right click then view image to see actual size
and here's another variation for Christmas envelope theme.
right click then view image to see actual size
here's an envelope using repeated altered Canada Post logo.
right click then view image to see actual size

and now i have enough designs for an envelope blinking lights animation :D
WARNING: below image might cause seizure because of quick blinking lights

Friday, April 8, 2016

Beginner's taste of bliss.

A couple of days ago while laying down, chanting Amida Buddha's name, I fell into a state of mind that is hard to describe.  After which point I got up to go pee, I realized that state of mind is magnitudes better than even a great orgasm.  It's better than anything i have felt before in my life.
I have been chanting Amida Buddha's name in Vietnamese (Namo A Di Da Phat) every night for about 15 minutes before falling asleep since my grandmother passed which is a little more than 3 years ago.
An orgasm is good while it lasts but then it's over.  This state of mind seemed endless and when i got out of it...i kept hoping that it would happen again but it hasn't.  My uncle told me that it will occur more often as I chant more..and one day, one can fully live in that state of mind 24/7.
I am guessing it's just a beginner's taste of bliss, not pure bliss, even so, it is greater and uncomparable to anything else i had ever felt.
I thought to myself no wonder Buddhist text tells of the Buddha how he spent 3 days in pure bliss after reaching full enlightenment before starting to preach to anyone.
I am very hopeful that this state of mind returns to me in the future as my chanting is not in vain.  After a little over 3 years, I have tasted a little of bliss.  I think the state of mind was so great it's all worth it.  Everything else pales in comparison to this taste of bliss.