593
594
return Fget_color_rgb (rep_MAKE_INT(shape.r * 256),
594
595
rep_MAKE_INT(shape.g * 256),
595
rep_MAKE_INT(shape.b * 256));
596
rep_MAKE_INT(shape.b * 256),
596
598
#elif defined HAVE_GDK_PIXBUF
597
599
fprintf (stderr, "shape colors are unimplemented for gdk-pixbuf\n");
745
747
static inline void
746
bevel_pixel (u_char *data, bool up, double bevel_fraction)
748
bevel_pixel (u_char *data, bool up, int bevel_percent)
749
pix[0] = ((double)data[0]) / 256.0;
750
pix[1] = ((double)data[1]) / 256.0;
751
pix[2] = ((double)data[2]) / 256.0;
750
unsigned int t0 = data[0], t1 = data[1], t2 = data[2];
754
pix[0] = pix[0] + (1.0 - pix[0]) * bevel_fraction;
755
pix[1] = pix[1] + (1.0 - pix[1]) * bevel_fraction;
756
pix[2] = pix[2] + (1.0 - pix[2]) * bevel_fraction;
757
data[0] = pix[0] * 256.0;
758
data[1] = pix[1] * 256.0;
759
data[2] = pix[2] * 256.0;
753
data[0] = t0 + (255 - t0) * bevel_percent / 100;
754
data[1] = t1 + (255 - t1) * bevel_percent / 100;
755
data[2] = t2 + (255 - t2) * bevel_percent / 100;
763
pix[0] = pix[0] - pix[0] * bevel_fraction;
764
pix[1] = pix[1] - pix[1] * bevel_fraction;
765
pix[2] = pix[2] - pix[2] * bevel_fraction;
766
data[0] = pix[0] * 256.0;
767
data[1] = pix[1] * 256.0;
768
data[2] = pix[2] * 256.0;
759
data[0] = t0 - t0 * bevel_percent / 100;
760
data[1] = t1 - t1 * bevel_percent / 100;
761
data[2] = t2 - t2 * bevel_percent / 100;
766
bevel_region (u_char *data, int row_stride, int bpp,
767
int rx, int ry, int rw, int rh, bool up, int bevel_percent)
770
for (y = ry; y < ry + rh; y++)
772
u_char *row = data + y * row_stride + rx * bpp;
773
for (x = rx; x < rx + rh; x++)
775
bevel_pixel (row, up, bevel_percent);
772
781
static inline void
773
782
bevel_horizontally (u_char *data, int width, int height,
774
783
int row_stride, int channels,
775
int border, bool top, bool up, double bevel_fraction)
784
int border, bool top, bool up, int bevel_percent)
778
787
up = top ? up : !up;
795
804
static inline void
796
805
bevel_vertically (u_char *data, int width, int height,
797
806
int row_stride, int channels,
798
int border, bool top, bool up, double bevel_fraction)
807
int border, bool top, bool up, int bevel_percent)
801
810
up = top ? up : !up;
809
818
ptr += (width - (cols + 1)) * channels + ((cols) * row_stride);
810
819
for (y = cols; y <= height - (cols + 1); y++)
812
bevel_pixel (ptr, up, bevel_fraction);
821
bevel_pixel (ptr, up, bevel_percent);
813
822
ptr += row_stride;
818
827
DEFUN("bevel-image", Fbevel_image, Sbevel_image,
819
(repv image, repv border, repv up, repv bevel_percent),
828
(repv image, repv border, repv up, repv bevel_percent_),
821
830
::doc:sawfish.wm.images#bevel-image::
822
831
bevel-image IMAGE BORDER UP [BEVEL-PERCENT]
828
837
intensity of the bevel created.
831
double bevel_fraction = 0.75;
840
int bevel_percent = 75;
832
841
rep_DECLARE1(image, IMAGEP);
833
842
rep_DECLARE2(border, rep_INTP);
835
if (!rep_INTP(bevel_percent))
836
bevel_percent = global_symbol_value (Qdefault_bevel_percent);
837
if (rep_INTP(bevel_percent))
844
if (!rep_INTP(bevel_percent_))
845
bevel_percent_ = global_symbol_value (Qdefault_bevel_percent);
846
if (rep_INTP(bevel_percent_))
839
int bp = rep_INT(bevel_percent);
840
if ((bp >= 0) && (bp <= 100))
841
bevel_fraction = (((double) bp) / 100.0);
848
bevel_percent = rep_INT (bevel_percent_);
849
bevel_percent = CLAMP (bevel_percent, 0, 100);
844
852
bevel_horizontally (image_pixels (VIMAGE(image)),
846
854
image_height (VIMAGE(image)),
847
855
image_row_stride (VIMAGE(image)),
848
856
image_channels (VIMAGE(image)),
849
rep_INT(border), TRUE, up != Qnil, bevel_fraction);
857
rep_INT(border), TRUE, up != Qnil, bevel_percent);
850
858
bevel_vertically (image_pixels (VIMAGE(image)),
851
859
image_width (VIMAGE(image)),
852
860
image_height (VIMAGE(image)),
853
861
image_row_stride (VIMAGE(image)),
854
862
image_channels (VIMAGE(image)),
855
rep_INT(border), TRUE, up != Qnil, bevel_fraction);
863
rep_INT(border), TRUE, up != Qnil, bevel_percent);
856
864
bevel_horizontally (image_pixels (VIMAGE(image)),
857
865
image_width (VIMAGE(image)),
858
866
image_height (VIMAGE(image)),
859
867
image_row_stride (VIMAGE(image)),
860
868
image_channels (VIMAGE(image)),
861
rep_INT(border), FALSE, up != Qnil, bevel_fraction);
869
rep_INT(border), FALSE, up != Qnil, bevel_percent);
862
870
bevel_vertically (image_pixels (VIMAGE(image)),
863
871
image_width (VIMAGE(image)),
864
872
image_height (VIMAGE(image)),
865
873
image_row_stride (VIMAGE(image)),
866
874
image_channels (VIMAGE(image)),
867
rep_INT(border), FALSE, up != Qnil, bevel_fraction);
875
rep_INT(border), FALSE, up != Qnil, bevel_percent);
869
877
image_changed (VIMAGE(image));