It is currently Sun Jun 30, 2024 5:50 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: A little Subroutine to build Means between two Dimensional Vectors
PostPosted: Thu Jan 27, 2022 1:21 pm  (#1) 
Offline
GimpChat Member

Joined: Apr 20, 2021
Posts: 13
Dear Community,
:roll: I'm really silly but why Workings followed Code not :roll:
(define (adapt l1 l2 m)
  (if (null? l)
      '()
      (cons ((* (car l1) m) + (* (car l1) ( - 1 m))
            (adapt (cdr l1) ( cdr l2) m))
        )
    )
)
 
(define (painter y dy ) ; Paint the founded Rectangle
    (begin
        (define color (adapt '(12 12 12) '(122 122 122) 0.4) ) ; Defines a shade of Red as Color for the Rectangle
        (gimp-image-select-rectangle image 2 0 y 300 dy ) ; Defines the Shape for the Rectangle
        (gimp-context-set-foreground color) ; Set the Color to fill the Shape of the Rectangle
        (gimp-edit-fill layer FILL-FOREGROUND) ; Paint finally the Rectangle
       
    )
)


:oops: The Idea behind this Code is to Mixing both Colors:
Color1 '(12 12 12)
Color2 '(122 122 122)
Not when the Subroutine Painter is called
Which Should Paint a Rectangle Across the Screen
And in the Hights y yd :geek

:gaah Dear Community I hope you can help me.
But it can been that this is Working, and Mistake
is anywhere Else in my Program. :hoh

Thomas Lahme

P.S.: The Complete Program is attached. But in this Version the Canvas must Uniformy Colored, but the Program results in a Mixed Colored Image.


Attachments:
Divider010.scm [2.86 KiB]
Downloaded 35 times
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: A little Subroutine to build Means between two Dimensional Vectors
PostPosted: Thu Jan 27, 2022 2:26 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
Hello

    adapt does not work because:
  • "l" is not defined. It is supposed to be l1
  • The + operator is between its two operands instead to start its list

adapt is the identity function independently of l2 and m. It always returns its first operand l1.
Since
R => R*m - R*(m-1) = R
G => G*m - G*(m-1) = G
B => B*m - B*(m-1) = B
Note your inversion (- 1 m) meaning that it is not an addition but a subtraction.

Never use l1 or l2 because it is so clause of 11 or 12.
It is about color so call them color1 and color2.

Never use a parameter having only one letter such as m.
It is not about mathematics!

Always align parenthesis.
Always give an example with the expected result.
(define (adapt color1 color2 ratio)
   (if (null? color1)
      '()
      (cons   (+(* (car color1) ratio) (* (car color1) (- 1 ratio)))
            (adapt (cdr color1) (cdr color2) ratio)
)   )   )


In the Script-Fu console:
(adapt  '(12 12 12)  '(it does not matter) 0.4)

The expected result will be:
(12.0 12.0 12.0)


Top
 Post subject: Re: A little Subroutine to build Means between two Dimensional Vectors
PostPosted: Fri Jan 28, 2022 9:33 am  (#3) 
Offline
GimpChat Member

Joined: Apr 20, 2021
Posts: 13
Hey AlSchemist,
I have tested your Script and have found an Error which leads me to another Error.
> (define (adapt color1 color2 ratio)
   (if (null? color1)
      '()
      (cons   (+(* (car color1) ratio) (* (car color2) (- 1 ratio)))
            (adapt (cdr color1) (cdr color2) ratio)
)   )   )
adapt
> (adapt  '(12 12 12)  '(1 1 1) 0.4)
(5,4.0 5,4.0 5,4.0)
> (adapt  '(12 12 12)  '(12 12 12) 0.4)
(12.0 12.0 12.0)
> (adapt  '(12 12 12)  '(6 6 6) 0.4)
(8,4.0 8,4.0 8,4.0)


I hope you can see that I must changed the Second Color1 to Color2.
This is in Because I need the Mixing between Color1 and Color2.
Then I have get another Error, When I give the Subroutine equal Lists all working.
But when I try to mix different Lists I got duplicated Values near the Right Result but computational Wrong.

So I now have tried to address Results which are Integer-Lists,
> (adapt  '(12 12 12)  '(6 6 6) 0.5)
(9.0 9.0 9.0)
> (adapt  '(12 12 12)  '(0 0 0) 0.5)
(6.0 6.0 6.0)
> (adapt  '(12 12 12)  '(0 0 0) 0.75)
(9.0 9.0 9.0)

then It works perfectly

I think that I have understand the Mathematical Background, and them seams correct
but can Anybody find the Problem.


Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Double Curve Bend using paths/vectors

6

No new posts Attachment(s) Gimp-2.99.13 nightly build for Windows 64

8

No new posts Attachment(s) CMYK Student's non-destructive dev build after 2.99.18 in use by me

93



* Login  



Powered by phpBB3 © phpBB Group