#! /usr/bin/python3 # Last edited on 2021-09-14 00:34:58 by stolfi import math from gimpfu import * def my_cut_marks (img lyr mrg fld): # Adds cut and spine fold lines on image. # {img} the image. # {lyr} layer on which to draw the lines. # {mrg} cut margin width. # {fw} desired spine width. # {pos} layer depth. (let* ( (nx (car (gimp_image_width img))) (ny (car (gimp_image_height img))) (cx mrg) ; left {x} of culr lines. (cy mrg) ; top {y} of cut lines. (cw (- nx mrg mrg)) ; tot width of cut lines. (ch (- ny mrg mrg)) ; tot height of cut lines. (fx (floor (/ (- nx fld)))) ; left {x} of spine. (fy cy) ; top {y} of spine. (fw (- nx fx fx)) ; actual spine width. (fh ch) ; spine height. ) (gimp_context_set_opacity 50) (gimp_context_set_paint_mode LAYER_MODE_OVERLAY) # (gimp_context_set_paint_method "") (gimp_context_set_stroke_method STROKE_PAINT_METHOD) (gimp_context_set_foreground '(255 255 255) ) (gimp_context_set_brush_size 8) (gimp_context_set_brush_hardness 0.5) # (gimp_context_set_line_width) (gimp_image_select_rectangle img CHANNEL_OP_REPLACE cx cy cw ch) (let* ( (path (gimp_image_get_active_vectors img)) ) (gimp_message (car path)) (gimp_drawable_edit_stroke_item lyr (car (cadr (car path)))) ) (gimp_message (string_append "drew cut lines")) (gimp_image_select_rectangle img CHANNEL_OP_REPLACE fx fy fw hh) (let* ( (path (car (cadr (car (gimp_image_get_active_vectors img))))) ) (gimp_drawable_edit_stroke_item lyr path) ) (gimp_message (string_append "drew fold lines")) (list lyr) ) ) def my_make_bg(img gy pos): # Adds the sky and ground background. # {img} the image. # {gy} height of the horizon from image bottom. # {pos} layer depth. (let* ( (nx (car (gimp_image_width img))) (ny (car (gimp_image_height img))) (hy (- ny gy)) ; the {y} coordinate of the horizon. (sy (- hy (* 2 gy))) ; the {y} coordinate of the max say of sky color. (lyr (car (gimp_layer_new img nx ny RGB_IMAGE "layerBG" 100 LAYER_MODE_NORMAL))) ) (gimp_image_add_layer img lyr pos) (gimp_context_set_background '(160 160 160) ) (gimp_context_set_foreground '( 30 30 30) ) (gimp_context_set_gradient_fg_bg_rgb) (gimp_image_select_rectangle img CHANNEL_OP_REPLACE 0 hy nx (- ny hy)) (gimp_drawable_edit_gradient_fill lyr GRADIENT_LINEAR 0 FALSE 0 0 TRUE 0 ny 0 hy) (gimp_context_set_background '(220 220 220) ) (gimp_context_set_foreground '( 30 30 30) ) (gimp_image_select_rectangle img CHANNEL_OP_REPLACE 0 0 nx hy) (gimp_drawable_edit_gradient_fill lyr GRADIENT_LINEAR 0 FALSE 0 0 TRUE 0 sy 0 hy) (gimp_selection_none img) # (gimp_drawable_fill lyr BACKGROUND_FILL) (gimp_message (string_append "added backgound")) (list lyr) ) ) def my_add_layer(img fname mag dx dy pos): # Add a layer read from a PNG file. # {img} the image. # {fname} the file name (PNG). # {mag} scale factor (float). # {dx,dy} shift to apply after scaling. # {pos} layer depth. (let* ( (lyr (car (gimp_file_load_layer RUN_NONINTERACTIVE img fname))) (ex 50) ; Extra {x} displacement of all layers. (ey 600) ; Extra {y} displacement of all layers. (ox (car (gimp_drawable_width lyr))) (oy (car (gimp_drawable_height lyr))) (nx (floor (* ox mag))) (ny (floor (* oy mag))) ) (gimp_image_add_layer img lyr pos) (gimp_layer_scale lyr nx ny TRUE) (gimp_layer_set_offsets lyr (+ dx ex) (+ dy ey)) (gimp_message (string_append "loaded layer " fname)) (list lyr) ) ) (define (make_ico_composite) # Build and display the composite image. (let* ( (nx 5200) ; Initial image width. (ny 3000) ; Initial image height. (image1 (car (gimp_image_new nx ny RGB))) (layerBG) (monster0) (monster1) (monster2) (monster3) (monster4) (monster5) (monster6) (monster7) (monster8) (monster9) (monstera) (rat) (bird) (moneyfield0) (moneyfield1) (moneyfield2) (moneyfield3) (vitalik) ) (set! layerBG (car (my_make_bg image1 625 50 ))) (my_cut_marks image1 layerBG 20 80) (set! moneyfield0 (car (my_add_layer image1 "moneyfield0.png" 1.000 500 1800 0 ))) (set! rat (car (my_add_layer image1 "rat.png" 1.000 1100 2000 1 ))) (set! bird (car (my_add_layer image1 "bird.png" 1.000 500 1100 2 ))) (set! monster0 (car (my_add_layer image1 "monster0.png" 1.000 3800 1570 3 ))) (set! monster2 (car (my_add_layer image1 "monster2.png" 0.750 3865 1570 4 ))) (set! monster4 (car (my_add_layer image1 "monster4.png" 1.000 3475 1910 5 ))) (set! monster8 (car (my_add_layer image1 "monster8.png" 1.000 3000 1690 6 ))) (set! monster1 (car (my_add_layer image1 "monster1.png" 0.900 3560 1525 7 ))) (set! monster7 (car (my_add_layer image1 "monster7.png" 0.800 2500 1780 8 ))) (set! moneyfield1 (car (my_add_layer image1 "moneyfield1.png" 1.000 350 1750 9 ))) (set! monster3 (car (my_add_layer image1 "monster3.png" 0.800 3550 1100 10 ))) (set! monster6 (car (my_add_layer image1 "monster6.png" 1.000 2750 1290 11 ))) (set! monster5 (car (my_add_layer image1 "monster5.png" 1.100 2850 600 12 ))) (set! monster9 (car (my_add_layer image1 "monster9.png" 1.000 4570 1570 13 ))) (set! monstera (car (my_add_layer image1 "monstera.png" 1.200 1750 1150 14 ))) (set! moneyfield2 (car (my_add_layer image1 "moneyfield2.png" 1.000 500 1650 15 ))) (set! vitalik (car (my_add_layer image1 "vitalik.png" 1.000 3800 600 16 ))) (set! moneyfield3 (car (my_add_layer image1 "moneyfield3.png" 1.000 350 1660 17 ))) (gimp_message "done.") (gimp_display_new image1) # Clear the "unsaved" flag: (gimp_image_clean_all image1) # Return the image: (list image1) ) ) (make_ico_composite)