… | |
… | |
263 | my $img = $self->new_img (urxvt::PictStandardARGB32, $_[0] || 1, $_[1] || 1); |
263 | my $img = $self->new_img (urxvt::PictStandardARGB32, $_[0] || 1, $_[1] || 1); |
264 | $img->fill ($colour); |
264 | $img->fill ($colour); |
265 | $img |
265 | $img |
266 | } |
266 | } |
267 | |
267 | |
|
|
268 | =item clone $img |
|
|
269 | |
|
|
270 | Returns an exact copy of the image. This is useful if you want to have |
|
|
271 | multiple copies of the same image to apply different effects to. |
|
|
272 | |
|
|
273 | =cut |
|
|
274 | |
|
|
275 | sub clone($) { |
|
|
276 | $_[0]->clone |
|
|
277 | } |
|
|
278 | |
268 | =back |
279 | =back |
269 | |
280 | |
|
|
281 | =head2 TILING MODES |
|
|
282 | |
|
|
283 | The following operators modify the tiling mode of an image, that is, the |
|
|
284 | way that pixels outside the image area are painted when the image is used. |
|
|
285 | |
|
|
286 | =over 4 |
|
|
287 | |
|
|
288 | =item tile $img |
|
|
289 | |
|
|
290 | Tiles the whole plane with the image and returns this new image - or in |
|
|
291 | other words, it returns a copy of the image in plane tiling mode. |
|
|
292 | |
|
|
293 | Example: load an image and tile it over the background, without |
|
|
294 | resizing. The C<tile> call is superfluous because C<load> already defaults |
|
|
295 | to tiling mode. |
|
|
296 | |
|
|
297 | tile load "mybg.png" |
|
|
298 | |
|
|
299 | =item mirror $img |
|
|
300 | |
|
|
301 | Similar to tile, but reflects the image each time it uses a new copy, so |
|
|
302 | that top edges always touch top edges, right edges always touch right |
|
|
303 | edges and so on (with normal tiling, left edges always touch right edges |
|
|
304 | and top always touch bottom edges). |
|
|
305 | |
|
|
306 | Example: load an image and mirror it over the background, avoiding sharp |
|
|
307 | edges at the image borders at the expense of mirroring the image itself |
|
|
308 | |
|
|
309 | mirror load "mybg.png" |
|
|
310 | |
|
|
311 | =item pad $img |
|
|
312 | |
|
|
313 | Takes an image and modifies it so that all pixels outside the image area |
|
|
314 | become transparent. This mode is most useful when you want to place an |
|
|
315 | image over another image or the background colour while leaving all |
|
|
316 | background pixels outside the image unchanged. |
|
|
317 | |
|
|
318 | Example: load an image and display it in the upper left corner. The rest |
|
|
319 | of the space is left "empty" (transparent or wahtever your compisotr does |
|
|
320 | in alpha mode, else background colour). |
|
|
321 | |
|
|
322 | pad load "mybg.png" |
|
|
323 | |
|
|
324 | =item extend $img |
|
|
325 | |
|
|
326 | Extends the image over the whole plane, using the closest pixel in the |
|
|
327 | area outside the image. This mode is mostly useful when you more complex |
|
|
328 | filtering operations and want the pixels outside the image to have the |
|
|
329 | same values as the pixels near the edge. |
|
|
330 | |
|
|
331 | Example: just for curiosity, how does this pixel extension stuff work? |
|
|
332 | |
|
|
333 | extend move 50, 50, load "mybg.png" |
|
|
334 | |
|
|
335 | =cut |
|
|
336 | |
|
|
337 | sub pad($) { |
|
|
338 | my $img = $_[0]->clone; |
|
|
339 | $img->repeat_mode (urxvt::RepeatNone); |
|
|
340 | $img |
|
|
341 | } |
|
|
342 | |
|
|
343 | sub tile($) { |
|
|
344 | my $img = $_[0]->clone; |
|
|
345 | $img->repeat_mode (urxvt::RepeatNormal); |
|
|
346 | $img |
|
|
347 | } |
|
|
348 | |
|
|
349 | sub mirror($) { |
|
|
350 | my $img = $_[0]->clone; |
|
|
351 | $img->repeat_mode (urxvt::RepeatReflect); |
|
|
352 | $img |
|
|
353 | } |
|
|
354 | |
|
|
355 | sub extend($) { |
|
|
356 | my $img = $_[0]->clone; |
|
|
357 | $img->repeat_mode (urxvt::RepeatPad); |
|
|
358 | $img |
|
|
359 | } |
|
|
360 | |
|
|
361 | =back |
|
|
362 | |
270 | =head2 VARIABLES |
363 | =head2 VARIABLE VALUES |
271 | |
364 | |
272 | The following functions provide variable data such as the terminal window |
365 | The following functions provide variable data such as the terminal window |
273 | dimensions. They are not (Perl-) variables, they jsut return stuff that |
366 | dimensions. They are not (Perl-) variables, they just return stuff that |
274 | varies. Most of them make your expression sensitive to some events, for |
367 | varies. Most of them make your expression sensitive to some events, for |
275 | example using C<TW> (terminal width) means your expression is evaluated |
368 | example using C<TW> (terminal width) means your expression is evaluated |
276 | again when the terminal is resized. |
369 | again when the terminal is resized. |
277 | |
370 | |
278 | =over 4 |
371 | =over 4 |
… | |
… | |
352 | $self->{counter} + 0 |
445 | $self->{counter} + 0 |
353 | } |
446 | } |
354 | |
447 | |
355 | =back |
448 | =back |
356 | |
449 | |
357 | =head2 TILING MODES |
450 | =head2 SHAPE CHANGING OPERATORS |
358 | |
451 | |
359 | The following operators modify the tiling mode of an image, that is, the |
452 | The following operators modify the shape, size or position of the image. |
360 | way that pixels outside the image area are painted when the image is used. |
|
|
361 | |
453 | |
362 | =over 4 |
454 | =over 4 |
363 | |
|
|
364 | =item tile $img |
|
|
365 | |
|
|
366 | Tiles the whole plane with the image and returns this new image - or in |
|
|
367 | other words, it returns a copy of the image in plane tiling mode. |
|
|
368 | |
|
|
369 | Example: load an image and tile it over the background, without |
|
|
370 | resizing. The C<tile> call is superfluous because C<load> already defaults |
|
|
371 | to tiling mode. |
|
|
372 | |
|
|
373 | tile load "mybg.png" |
|
|
374 | |
|
|
375 | =item mirror $img |
|
|
376 | |
|
|
377 | Similar to tile, but reflects the image each time it uses a new copy, so |
|
|
378 | that top edges always touch top edges, right edges always touch right |
|
|
379 | edges and so on (with normal tiling, left edges always touch right edges |
|
|
380 | and top always touch bottom edges). |
|
|
381 | |
|
|
382 | Example: load an image and mirror it over the background, avoiding sharp |
|
|
383 | edges at the image borders at the expense of mirroring the image itself |
|
|
384 | |
|
|
385 | mirror load "mybg.png" |
|
|
386 | |
|
|
387 | =item pad $img |
|
|
388 | |
|
|
389 | Takes an image and modifies it so that all pixels outside the image area |
|
|
390 | become transparent. This mode is most useful when you want to place an |
|
|
391 | image over another image or the background colour while leaving all |
|
|
392 | background pixels outside the image unchanged. |
|
|
393 | |
|
|
394 | Example: load an image and display it in the upper left corner. The rest |
|
|
395 | of the space is left "empty" (transparent or wahtever your compisotr does |
|
|
396 | in alpha mode, else background colour). |
|
|
397 | |
|
|
398 | pad load "mybg.png" |
|
|
399 | |
|
|
400 | =item extend $img |
|
|
401 | |
|
|
402 | Extends the image over the whole plane, using the closest pixel in the |
|
|
403 | area outside the image. This mode is mostly useful when you more complex |
|
|
404 | filtering operations and want the pixels outside the image to have the |
|
|
405 | same values as the pixels near the edge. |
|
|
406 | |
|
|
407 | Example: just for curiosity, how does this pixel extension stuff work? |
|
|
408 | |
|
|
409 | extend move 50, 50, load "mybg.png" |
|
|
410 | |
|
|
411 | =cut |
|
|
412 | |
|
|
413 | sub pad($) { |
|
|
414 | my $img = $_[0]->clone; |
|
|
415 | $img->repeat_mode (urxvt::RepeatNone); |
|
|
416 | $img |
|
|
417 | } |
|
|
418 | |
|
|
419 | sub tile($) { |
|
|
420 | my $img = $_[0]->clone; |
|
|
421 | $img->repeat_mode (urxvt::RepeatNormal); |
|
|
422 | $img |
|
|
423 | } |
|
|
424 | |
|
|
425 | sub mirror($) { |
|
|
426 | my $img = $_[0]->clone; |
|
|
427 | $img->repeat_mode (urxvt::RepeatReflect); |
|
|
428 | $img |
|
|
429 | } |
|
|
430 | |
|
|
431 | sub extend($) { |
|
|
432 | my $img = $_[0]->clone; |
|
|
433 | $img->repeat_mode (urxvt::RepeatPad); |
|
|
434 | $img |
|
|
435 | } |
|
|
436 | |
|
|
437 | =back |
|
|
438 | |
|
|
439 | =head2 PIXEL OPERATORS |
|
|
440 | |
|
|
441 | The following operators modify the image pixels in various ways. |
|
|
442 | |
|
|
443 | =over 4 |
|
|
444 | |
|
|
445 | =item clone $img |
|
|
446 | |
|
|
447 | Returns an exact copy of the image. |
|
|
448 | |
|
|
449 | =cut |
|
|
450 | |
|
|
451 | sub clone($) { |
|
|
452 | $_[0]->clone |
|
|
453 | } |
|
|
454 | |
455 | |
455 | =item clip $img |
456 | =item clip $img |
456 | |
457 | |
457 | =item clip $width, $height, $img |
458 | =item clip $width, $height, $img |
458 | |
459 | |
… | |
… | |
596 | |
597 | |
597 | sub rootalign($) { |
598 | sub rootalign($) { |
598 | move -TX, -TY, $_[0] |
599 | move -TX, -TY, $_[0] |
599 | } |
600 | } |
600 | |
601 | |
|
|
602 | =back |
|
|
603 | |
|
|
604 | =head2 COLOUR MODIFICATIONS |
|
|
605 | |
|
|
606 | The following operators change the pixels of the image. |
|
|
607 | |
|
|
608 | =over 4 |
|
|
609 | |
601 | =item contrast $factor, $img |
610 | =item contrast $factor, $img |
602 | |
611 | |
603 | =item contrast $r, $g, $b, $img |
612 | =item contrast $r, $g, $b, $img |
604 | |
613 | |
605 | =item contrast $r, $g, $b, $a, $img |
614 | =item contrast $r, $g, $b, $a, $img |
606 | |
615 | |
607 | Adjusts the I<contrast> of an image. |
616 | Adjusts the I<contrast> of an image. |
608 | |
617 | |
609 | #TODO# |
618 | The first form applies a single C<$factor> to red, green and blue, the |
|
|
619 | second form applies separate factors to each colour channel, and the last |
|
|
620 | form includes the alpha channel. |
610 | |
621 | |
|
|
622 | Values from 0 to 1 lower the contrast, values higher than 1 increase the |
|
|
623 | contrast. |
|
|
624 | |
|
|
625 | Due to limitations in the underlying XRender extension, lowering contrast |
|
|
626 | also reduces brightness, while increasing contrast currently also |
|
|
627 | increases brightness. |
|
|
628 | |
611 | =item brightness $factor, $img |
629 | =item brightness $bias, $img |
612 | |
630 | |
613 | =item brightness $r, $g, $b, $img |
631 | =item brightness $r, $g, $b, $img |
614 | |
632 | |
615 | =item brightness $r, $g, $b, $a, $img |
633 | =item brightness $r, $g, $b, $a, $img |
616 | |
634 | |
617 | Adjusts the brightness of an image. |
635 | Adjusts the brightness of an image. |
|
|
636 | |
|
|
637 | The first form applies a single C<$bias> to red, green and blue, the |
|
|
638 | second form applies separate biases to each colour channel, and the last |
|
|
639 | form includes the alpha channel. |
|
|
640 | |
|
|
641 | Values less than 0 reduce brightness, while values larger than 0 increase |
|
|
642 | it. Useful range is from -1 to 1 - the former results in a black, the |
|
|
643 | latter in a white picture. |
|
|
644 | |
|
|
645 | Due to idiosynchrasies in the underlying XRender extension, biases less |
|
|
646 | than zero can be I<very> slow. |
618 | |
647 | |
619 | =cut |
648 | =cut |
620 | |
649 | |
621 | sub contrast($$;$$;$) { |
650 | sub contrast($$;$$;$) { |
622 | my $img = pop; |
651 | my $img = pop; |