It is currently Sun Jul 07, 2024 7:58 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Question re (gimp-drawable-get-pixel drawable x-coord y-coord)
PostPosted: Mon Jan 05, 2015 7:38 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 199
From a novice to script-fu and scheme

I typed the code below into the SFC and its ok as far as it goes ……


> (gimp-image-new 99 99 0)
(3)
> (gimp-layer-new 3 99 99 0 "snow" 100 0)
(10)
> (gimp-image-add-layer 3 10 0)
(#t)
> (gimp-display-new 3)
(2)
> (gimp-context-set-foreground '(0 0 255))
(#t)
> (gimp-edit-bucket-fill 10 0 0 100 0 TRUE 0 0)
(#t)
> (define (vary 0))
vary
> (set! vary (car (gimp-drawable-get-pixel 10 18 18)))
3
> (set! vary (cdr (gimp-drawable-get-pixel 10 18 18)))
(#( 0 0 255 ))


…… but i can’t work out how to set! vary to just one of the three values in (#( 0 0 255 ))

Thanks for looking


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: Question re (gimp-drawable-get-pixel drawable x-coord y-coord)
PostPosted: Mon Jan 05, 2015 8:59 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
The # indicates you have a vector (also known as an array), so you use vector-ref to extract individual elements of the vector:
> (define vary (vector 1 2 255))
vary
> (vector-ref vary 2)
255


Kevin


Top
 Post subject: Re: Question re (gimp-drawable-get-pixel drawable x-coord y-coord)
PostPosted: Mon Jan 05, 2015 9:33 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 199
paynekj wrote:
The # indicates you have a vector (also known as an array), so you use vector-ref to extract individual elements of the vector:
> (define vary (vector 1 2 255))
vary
> (vector-ref vary 2)
255


Kevin

Thanks for the speedy reply and example Kevin, I didn't know the # indicated it was a vector

Steve


Top
 Post subject: Re: Question re (gimp-drawable-get-pixel drawable x-coord y-coord)
PostPosted: Mon Jan 05, 2015 11:37 am  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Steve wrote:
From a novice to script-fu and scheme


Why don't you use Python instead? A lot easier to learn and more powerful. Now a standard part of Gimp.

_________________
Image


Top
 Post subject: Re: Question re (gimp-drawable-get-pixel drawable x-coord y-coord)
PostPosted: Mon Jan 05, 2015 2:09 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 199
ofnuts wrote:
Steve wrote:
From a novice to script-fu and scheme


Why don't you use Python instead? A lot easier to learn and more powerful. Now a standard part of Gimp.

I’ve heard of Python but must admit I’ve never looked into its capabilities. I sort of drifted into Scheme after finding the SFC and the PB while nosing around in Gimp. Scheme seemed to be the way to get things working. I had no real reason to learn Scheme other than curiosity and of how it related to the SFC, to scripts and Gimp. Then as time went by my interest in these things grew and I just carried on. Not sure I want to drop Scheme and start from scratch with Python but will look into Python and give it some thought.

Steve


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Line/pixel size doesnot correspond with pixel resolution

3

No new posts Attachment(s) Pixel Art Help

2

No new posts Pixel art experiment

6

No new posts Attachment(s) GEGL Circular Pixel Stretch.

14

No new posts GIMP's fast pixel operations

4



* Login  



Powered by phpBB3 © phpBB Group