Skip to content
Snippets Groups Projects
Commit fa8bd768 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

added tkpath to the build system

parent 44e38147
No related branches found
No related tags found
No related merge requests found
Showing
with 1075 additions and 11 deletions
......@@ -107,7 +107,7 @@ endif
.PHONY: pd gui externs all
all: pd $(BIN_DIR)/pd-watchdog gui $(BIN_DIR)/pdsend \
$(BIN_DIR)/pdreceive externs
$(BIN_DIR)/pdreceive externs tkpath
bin: pd $(BIN_DIR)/pd-watchdog gui $(BIN_DIR)/pdsend \
$(BIN_DIR)/pdreceive
......@@ -189,6 +189,11 @@ externs:
make -C ../extra/pd~ @EXTERNTARGET@
make -C ../extra/stdout @EXTERNTARGET@
tkpath:
cd ../tkpath && aclocal && autoconf && ./configure --prefix=$(prefix)
make -C ../tkpath
cd ../src
BINARYMODE=@binarymode@
ABOUT_FILE=$(DESTDIR)$(pddocdir)/1.manual/1.introduction.txt
......@@ -199,6 +204,8 @@ install: all
install -m644 pd.tk $(DESTDIR)$(libpdbindir)/pd.tk
install -m644 pkgIndex.tcl $(DESTDIR)$(libpdbindir)/pkgIndex.tcl
install -m644 helpbrowser.tcl $(DESTDIR)$(libpdbindir)/helpbrowser.tcl
install -m644 ../tkpath/library/tkpath.tcl $(DESTDIR)$(libpdbindir)/tkpath.tcl
install -m644 ../tkpath/libtkpath*so $(DESTDIR)$(libpdbindir)/
install -d $(DESTDIR)$(bindir)
install $(BINARYMODE) $(PDEXEC) $(DESTDIR)$(bindir)/@PDEXEC@
# kludge to allow pd~ to work by default in pd-l2ork
......@@ -258,6 +265,7 @@ distclean: clean
autom4te.cache/output.* autom4te.cache/traces.* autom4te.cache/requests
-rmdir autom4te.cache
-rm -rf autom4te-*.cache
cd ../tkpath && make distclean
tags: $(SRC) $(GSRC); ctags *.[ch]
......@@ -297,12 +305,3 @@ etags_Linux:
etags_MINGW:
find /usr/local/include/ -type f -name \*.h -exec etags -a '{}' \;
# Tcl package index file, version 1.1
# pkgIndex.tcl. Generated from pkgIndex.tcl.in by configure.
#
package ifneeded helpbrowser 0.1 [list source [file join $dir helpbrowser.tcl]]
namespace eval ::tkpath {
proc load_package {dir} {
load [file join $dir libtkpath0.3.2.so]
# Allow optional redirect of library components.
# Only necessary for testing, but could be used elsewhere.
if {[info exists ::env(TKPATH_LIBRARY)]} {
set dir $::env(TKPATH_LIBRARY)
}
source $dir/tkpath.tcl
};# load_package
}
package ifneeded tkpath 0.3.2 [list ::tkpath::load_package $dir]
#*EOF*
2012-07-04 George Petasis <petasis@iit.demokritos.gr>
* generic/tkpUtil.c: Fix in the tkStateKeyObjType definistion, in
order to compile with Tk 8.6.
* tclconfig/install-sh:
* tclconfig/tcl.m4:
* configure, configure.in: Updated to TEA 3.9.
* generic/*.c: Various fixes for mingw32/mingw64.
2011-10-28 Peter Spjuth <peter.spjuth@gmail.com>
* win/makefile.vc
* generic/path.c:
* configure, configure.in: Bumped revision to 0.3.2
2011-10-28 Peter Spjuth <peter.spjuth@gmail.com>
* generic/tkCanvPath.c (PathCoords):
Fixed memory leak when using coords command with path item.
2010-03-15 Peter Spjuth <peter.spjuth@gmail.com>
* generic/tkIntPath.h: Updated PATH_DEPIXELIZE to avoid an offset
error with negative coordinates.
* demos/arcs.tcl: Added an arc where the offset error was visible.
2010-03-15 Peter Spjuth <peter.spjuth@gmail.com>
* unix/tkUnixCairoPath.c (TkPathInit): Get correct size of Drawable.
This fixes an intermittent strange clipping bug.
2010-03-10 George Petasis <petasis@iit.demokritos.gr>
* generic/tkpCanvPoly.c: fixes in DeletePolygon() to avoid double
releases of polyPtr->coordPtr & polyPtr->fillGC by
Tk_FreeConfigOptions().
* generic/tkpCanvUtil.c: fixes in Tk_PathDeleteOutline(), to set the
default empty values in the various Tk_PathOutline members, to stop
double releases done by Tk_FreeConfigOptions() (i.e. by
DeletePolygon() in tkpCanvPoly.c).
* generic/tkpCanvas.c: fix in DestroyCanvas(), so as
TkPathCanvasItemIteratorPrev() accepts a pointer that has not been
just freed.
* generic/tkpUtil.c: added a CONST before tkStateKeyObjType, to get
the code to compile with Tk 8.6.
* win/tkWinGDIPlusPath.cpp: changed the file from Mac OS X format to
windows, as the MS C++ 10.0 compiler stopped with an error.
* win/makefile.vc: I updated the windows makefile, to compile tkpath
with VC++ 10.0 compiler. May need further tweaking to work with
earlier versions.
2009-04-01 Jeff Hobbs <jeffh@ActiveState.com>
* Makefile.in (VPATH): add macosx subdir to VPATH
2009-03-31 Jeff Hobbs <jeffh@ActiveState.com>
* Makefile.in, tclconfig/config.m4: updated to TEA 3.7 and improved
* configure, configure.in: Makefile for Windows build
* win/tkWinGDIPlusPath.cpp: clarify TkPathContext_ typedef
* pkgIndex.tcl.in: use a more flexible pkgIndex.tcl.in starter
* generic/tkPathStyle.c (Tk_PathDashOptionSetProc): initialize newPtr
README for tkpath
_________________
This package implements path drawing modelled after its SVG counterpart,
see http://www.w3.org/TR/SVG11/. See the doc directory for more info.
There are three backends used for drawing. They are all platform specific
except for the Tk drawing which uses only the API found in Tk. This
backend is very limited and has some problems with multiple subpaths.
It is only to be used as a fallback when the cairo backend is missing.
The backends:
1) CoreGraphics for MacOSX, built using ProjectBuilder
2) GDI+ for WinXP, built by VC++7 (.NET), runs also on older system
using the gdiplus.dll
3) cairo (http://cairographics.org), built using the automake system;
the configure.in and Makefile.in files are a hack, so please help
yourself (and me). It requires a cairo 1.0 installation since
incompatible API changes appeared before 1.0 (libcairo.so.2 ?).
There used to be two additional backends, GDI and core Tk drawing, but
these have been dropped.
I could think of another backend based on X11 that has more features than
the compatibility layer of Tk, since the fallback is only necessary on unix
systems anyway. Perhaps an OpenGL backend would also be useful, mainly on
unix systems without cairo support.
There are two important Design Principles:
1) Follow the SVG graphics model. Make it more condensed without
giving up any features. For instance, tkpath keeps only a -matrix
option which comprises translate, scale etc. attributes
2) Keep the actual path drawing code separate and independent of any
canvas code.
Open Issues:
There are a number of design choices that I'd like to discuss.
o How to provide coordinates for prect? As the standard Tk way (x1,y1,x2,y2),
using sizes (x,y,width,height), or using options (x,y,-width,-height)?
o What shall the precedence of the -style option compared to the individual
options be?
Copyright (c) 2005-2008 Mats Bengtsson
BSD style license.
TODO + BUGS and undecided for tkpath
------------------------------------
o The 'delete itemOrTag' may match items of any combination and therefore
deleteing a group may delete items already in the list which may crash.
o Scaling rotated arcs. Much math! Simplified.
Test case:
pack [tkp::canvas .c -width 600 -height 400]
set p "M 100 100 a 100 25 60 1 0 50 -25"
set id [.c create path $p]
set id [.c create path $p -stroke red -matrix {{2 0} {0 1} {0 0}}]
set id [.c create path $p -stroke blue]
.c scale $id 0 0 2 1
o Optimize segmentation computations used for hittesting in the 'Point'
functions.
o Perhaps an OpenGL renderer.
o Perhaps lightweight items with no own style options but only a reference
to a styleName to save a lot of memory. See TreeCtrl.
o I have paid no attention to if strokes are transformed or not. Sort out!
CG + cairo: strokes are scaled exactly.
o Perhaps it would be useful to allow multiple objects on a single item
by supplying many coordinates for pline, prect, circle, and ellipse?
o I would like to move the TkPathInit/TkPathFree to the canvas
Display function instead of having it in the items Display function.
This is currently not possible due to the X11 emulation code
used by the old items. This would save a lot of cpu, on aqua
in particular.
o Try to get rid of the Tk_Uid.
o Perhaps have the Tk_PathItem's x1, y1, ... as doubles.
That would make translations and scaling easier since we don't have
to bother about roundoffs. Separate flag for hidden?
o What to do with the -state option for the new items?
o Perhaps it would be useful to have the precedence order between
item options and style options configurable.
o Maybe there should be a group item also for tkp::surface?
o Would it be useful to be able to set the viewport and coordinate
system for the canvas, like SVG does? Note that this is possible
using the root items -matrix option.
o gdi+ seems unable to produce antialiasing effects on a surface but
there seems to be no gdi+ specific way of drawing in memory bitmaps
but had to call CreateDIBSection() which is a Win32 GDI API.
o All postscript is missing.
o Need to sort out how the tags "all" and "root" (0) shall interact.
o It could be useful to have a 'style reset' command that sets all options
to their defaults and clears the mask.
o Write all test code.
o Add clipping. Use an extra item option '-clipto idOrTags' where the joint
set of all idOrTags form the clipping region. It should be possible to use
items not on the display, and perhaps the -state option can be used to hide items.
#!/bin/bash -norc
dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
#
# RCS: @(#) $Id: configure.in,v 1.19 2012/07/04 20:43:21 petasis Exp $
#-----------------------------------------------------------------------
# Sample configure.in for Tcl Extensions. The only places you should
# need to modify this file are marked by the string __CHANGE__
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# Set your package name and version numbers here.
#
# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
# set as provided. These will also be added as -D defs in your Makefile
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------
AC_INIT([tkpath], [0.3.2])
#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
#--------------------------------------------------------------------
TEA_INIT([3.9])
AC_CONFIG_AUX_DIR(tclconfig)
#--------------------------------------------------------------------
# Load the tclConfig.sh file
#--------------------------------------------------------------------
TEA_PATH_TCLCONFIG
TEA_LOAD_TCLCONFIG
#--------------------------------------------------------------------
# Load the tkConfig.sh file if necessary (Tk extension)
#--------------------------------------------------------------------
TEA_PATH_TKCONFIG
TEA_LOAD_TKCONFIG
#-----------------------------------------------------------------------
# Handle the --prefix=... option by defaulting to what Tcl gave.
# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
#-----------------------------------------------------------------------
TEA_PREFIX
#-----------------------------------------------------------------------
# Standard compiler checks.
# This sets up CC by using the CC env var, or looks for gcc otherwise.
# This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
# the basic setup necessary to compile executables.
#-----------------------------------------------------------------------
TEA_SETUP_COMPILER
#--------------------------------------------------------------------
# The code makes use of PTR2INT, ensure the correct definition is
# picked from Tcl/Tk internal headers...
#--------------------------------------------------------------------
AS_IF([test "$do64bit" = "yes"], [
tcl_ok=no
], [
tcl_ok=yes
])
AC_CHECK_TYPE([intptr_t], [
AC_DEFINE([HAVE_INTPTR_T], 1, [Do we have the intptr_t type?])], [
AC_CACHE_CHECK([for pointer-size signed integer type], tcl_cv_intptr_t, [
for tcl_cv_intptr_t in "int" "long" "long long" none; do
if test "$tcl_cv_intptr_t" != none; then
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
[[sizeof (void *) <= sizeof ($tcl_cv_intptr_t)]])],
[tcl_ok=yes], [tcl_ok=no])
test "$tcl_ok" = yes && break; fi
done])
if test "$tcl_cv_intptr_t" != none; then
AC_DEFINE_UNQUOTED([intptr_t], [$tcl_cv_intptr_t], [Signed integer
type wide enough to hold a pointer.])
fi
])
AC_CHECK_TYPE([uintptr_t], [
AC_DEFINE([HAVE_UINTPTR_T], 1, [Do we have the uintptr_t type?])], [
AC_CACHE_CHECK([for pointer-size unsigned integer type], tcl_cv_uintptr_t, [
for tcl_cv_uintptr_t in "unsigned int" "unsigned long" "unsigned long long" \
none; do
if test "$tcl_cv_uintptr_t" != none; then
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT],
[[sizeof (void *) <= sizeof ($tcl_cv_uintptr_t)]])],
[tcl_ok=yes], [tcl_ok=no])
test "$tcl_ok" = yes && break; fi
done])
if test "$tcl_cv_uintptr_t" != none; then
AC_DEFINE_UNQUOTED([uintptr_t], [$tcl_cv_uintptr_t], [Unsigned integer
type wide enough to hold a pointer.])
fi
])
#-----------------------------------------------------------------------
# Specify the C source files to compile in TEA_ADD_SOURCES,
# public headers that need to be installed in TEA_ADD_HEADERS,
# stub library C source files to compile in TEA_ADD_STUB_SOURCES,
# and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
# and PKG_TCL_SOURCES.
#-----------------------------------------------------------------------
TEA_ADD_SOURCES([path.c \
tkPath.c \
tkpCanvas.c \
tkpCanvArc.c \
tkpCanvBmap.c \
tkpCanvImg.c \
tkpCanvLine.c \
tkpCanvPoly.c \
tkpCanvPs.c \
tkpCanvText.c \
tkpCanvUtil.c \
tkpCanvWind.c \
tkpRectOval.c \
tkpTrig.c \
tkpUtil.c \
tkCanvPathUtil.c \
tkCanvEllipse.c \
tkCanvGroup.c \
tkCanvPath.c \
tkCanvPimage.c \
tkCanvPline.c \
tkCanvPpoly.c \
tkCanvPrect.c \
tkCanvPtext.c \
tkCanvGradient.c \
tkPathGradient.c \
tkCanvStyle.c \
tkPathStyle.c \
tkPathSurface.c \
tkPathUtil.c])
TEA_ADD_HEADERS([])
TEA_ADD_INCLUDES([-I. -I\"`${CYGPATH} ${srcdir}/generic`\"])
TEA_ADD_LIBS([])
TEA_ADD_CFLAGS([])
TEA_ADD_STUB_SOURCES([])
TEA_ADD_TCL_SOURCES([library/tkpath.tcl])
#--------------------------------------------------------------------
# A few miscellaneous platform-specific items:
#
# Define a special symbol for Windows (BUILD_sample in this case) so
# that we create the export library with the dll.
#
# Windows creates a few extra files that need to be cleaned up.
# You can add more files to clean if your extension creates any extra
# files.
#
# TEA_ADD_* any platform specific compiler/build info here.
#--------------------------------------------------------------------
if test "${TEA_PLATFORM}" = "windows" ; then
AC_PROG_CXX
CC=$CXX
AC_DEFINE(BUILD_tkpath, 1, [Build windows export dll])
CLEANFILES="pkgIndex.tcl *.lib *.dll *.exp *.ilk *.pdb vc*.pch"
TEA_ADD_SOURCES([win/tkWinGDIPlusPath.cpp])
TEA_ADD_LIBS([gdiplus.lib gdi32.lib])
#TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
## Check if the compiler accepts -static-libstdc++ (i.e. mingw)...
AC_CACHE_CHECK([if the compiler understands -static-libstdc++],
tcl_cv_cc_staticlib, [
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -static-libstdc++"
AC_TRY_COMPILE(,, tcl_cv_cc_staticlib=yes, tcl_cv_cc_staticlib=no)
CFLAGS=$hold_cflags])
else
CLEANFILES="pkgIndex.tcl"
if test "${TEA_WINDOWINGSYSTEM}" = "aqua" ; then
TEA_ADD_SOURCES([macosx/tkMacOSXPath.c])
TEA_ADD_LIBS([-framework Carbon])
TEA_ADD_LIBS([-framework CoreServices])
else
TEA_ADD_SOURCES([unix/tkUnixCairoPath.c])
TEA_ADD_INCLUDES([`freetype-config --cflags`])
TEA_ADD_INCLUDES([-I/usr/include/cairo])
TEA_ADD_LIBS([-lcairo])
fi
fi
AC_SUBST(CLEANFILES)
#--------------------------------------------------------------------
# Choose which headers you need. Extension authors should try very
# hard to only rely on the Tcl public header files. Internal headers
# contain private data structures and are subject to change without
# notice.
# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
#--------------------------------------------------------------------
TEA_PUBLIC_TCL_HEADERS
#TEA_PRIVATE_TCL_HEADERS
#TEA_PUBLIC_TK_HEADERS
TEA_PRIVATE_TK_HEADERS
#TEA_PATH_X
#--------------------------------------------------------------------
# Check whether --enable-threads or --disable-threads was given.
# This auto-enables if Tcl was compiled threaded.
#--------------------------------------------------------------------
TEA_ENABLE_THREADS
#--------------------------------------------------------------------
# The statement below defines a collection of symbols related to
# building as a shared library instead of a static library.
#--------------------------------------------------------------------
TEA_ENABLE_SHARED
#--------------------------------------------------------------------
# This macro figures out what flags to use with the compiler/linker
# when building shared/static debug/optimized objects. This information
# can be taken from the tclConfig.sh file, but this figures it all out.
#--------------------------------------------------------------------
TEA_CONFIG_CFLAGS
#--------------------------------------------------------------------
# Set the default compiler switches based on the --enable-symbols option.
#--------------------------------------------------------------------
TEA_ENABLE_SYMBOLS
#--------------------------------------------------------------------
# Everyone should be linking against the Tcl stub library. If you
# can't for some reason, remove this definition. If you aren't using
# stubs, you also need to modify the SHLIB_LD_LIBS setting below to
# link against the non-stubbed Tcl library. Add Tk too if necessary.
#--------------------------------------------------------------------
AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs])
#--------------------------------------------------------------------
# This macro generates a line to use when building a library. It
# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
# and TEA_LOAD_TCLCONFIG macros above.
#--------------------------------------------------------------------
TEA_MAKE_LIB
#--------------------------------------------------------------------
# Determine the name of the tclsh and/or wish executables in the
# Tcl and Tk build directories or the location they were installed
# into. These paths are used to support running test cases only,
# the Makefile should not be making use of these paths to generate
# a pkgIndex.tcl file or anything else at extension build time.
#--------------------------------------------------------------------
TEA_PROG_TCLSH
TEA_PROG_WISH
if test "${TEA_PLATFORM}" = "windows" ; then
## If the compiler accepts -static-libstdc++, modify the compiler
## and linker options...
if test $tcl_cv_cc_staticlib = yes; then
CFLAGS="$CFLAGS -static-libgcc -static-libstdc++"
SHLIB_LD="$SHLIB_LD -static-libgcc -static-libstdc++"
fi
fi
#--------------------------------------------------------------------
# Finally, substitute all of the various values into the Makefile.
# You may alternatively have a special pkgIndex.tcl.in or other files
# which require substituting th AC variables in. Include these here.
#--------------------------------------------------------------------
AC_OUTPUT([Makefile pkgIndex.tcl])
set dir [file dirname [info script]] set tail [file tail [info script]] foreach fileName [glob -nocomplain -directory $dir *.tcl] { if {[file tail $fileName] ne $tail} { source $fileName }}
\ No newline at end of file
package require tkpath 0.3.0
set t .c_apple
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
set grad [$w gradient create linear -stops \
{{0.0 "#00bb00"} {0.35 "#00bb00"} {0.35 "#ffff00"} {0.50 "#ffff00"} \
{0.50 "#ff6600"} {0.65 "#ff6600"} {0.65 "#dd0000"} {0.8 "#dd0000"} \
{0.8 "#3366cc"} {1.0 "#3366cc"}} \
-lineartransition {0 0 0 1}]
$w create path "M 0 0 C 20 0 40 -20 70 -20 S 130 30 130 60 \
110 200 60 200 20 180 0 180 \
-10 200 -60 200 -130 90 -130 60 \
-110 -20 -70 -20 -20 0 0 0 z \
M 0 -10 Q -10 -60 50 -80 Q 50 -20 0 -10 z" \
-fill $grad -stroke "" -tags apple
$w move apple 200 120
package require tkpath 0.3.0
set t .c_arcs
destroy $t
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 500 -height 400 -bg white]
$w create path "M 20 350 l 50 -25 \
a 25 25 -30 0 1 50 -25 l 50 -25 \
a 25 50 -30 0 1 50 -25 l 50 -25 \
a 25 75 -30 0 1 50 -25 l 50 -25 \
a 25 100 -30 0 1 50 -25 l 50 -25" -stroke red -strokewidth 2
$w create path "M 30 350 h 100 a 25 200 0 0 1 50 0 h 60" \
-stroke blue -strokewidth 2
$w create path "M 100 100 a 25 25 -30 0 1 50 -25 z" -fill yellow -strokewidth 2
$w create path "M 180 100 a 25 25 30 0 1 50 25 z" -fill yellow -strokewidth 2
set r 40
set a 10
set b 6
set b2 [expr {2*$b}]
set r2 [expr {2*$r}]
set ra [expr {$r+$a}]
set a2 [expr {2*$r+$a}]
proc tkp::circlepath {r} {
return [list M -6 -$a l -$b -$b M -6 -$a l -$b $b]
}
$w create path "M 0 0 A $r $r 0 1 1 0 $r2 A $r $r 0 1 1 0 0 Z" \
-strokewidth 2 -tag acircle
$w create path "M 0 -$a A $ra $ra 0 1 1 6 $a2" \
-stroke red -tag acircle
$w create path "M 0 -$a v -$b v $b2" \
-stroke red -tag acircle
$w create path "M 6 $a2 l $b -$b M 6 $a2 l $b $b" \
-stroke red -tag acircle
$w create path "M 0 $a2 A $ra $ra 0 1 1 -6 -$a" \
-stroke red -tag acircle
$w create path "M 0 $a2 v -$b v $b2" \
-stroke red -tag acircle
$w create path "M -6 -$a l -$b -$b M -6 -$a l -$b $b" \
-stroke red -tag acircle
$w create ptext -20 [expr {$a2+30}] \
-text "M 0 0 A $r $r 0 1 1 0 $r2 A $r $r 0 1 1 0 0 Z" \
-textanchor middle -tags acircle
$w move acircle 400 220
# Make an elllipse around origo and put it in place using a transation matrix
namespace import ::tcl::mathop::*
proc ellipsepath {x y rx ry} {
list \
M $x [- $y $ry] \
a $rx $ry 0 1 1 0 [* 2 $ry] \
a $rx $ry 0 1 1 0 [* -2 $ry] \
Z
}
set Phi [expr {45 / 180.0 * 3.1415926535}]
set cosPhi [expr {cos($Phi)*4}]
set sinPhi [expr {sin($Phi)*4}]
set msinPhi [- $sinPhi]
set matrix \
[list [list $cosPhi $msinPhi] [list $sinPhi $cosPhi] \
[list 200 200]]
$w create path [ellipsepath 0 0 20 10] -stroke purple -matrix $matrix
This diff is collapsed.
package require tkpath 0.3.0
set t .c_clock
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
namespace eval ::clock {
variable w $::w
set r1 160
set r2 140
set r3 120
set r4 100
for {set i 1} {$i <= 12} {incr i} {
set phi [expr (30.0*$i - 90.0)*3.14159/180.0]
set sinPhi [expr sin($phi)]
set cosPhi [expr cos($phi)]
set pt1($i) [list [expr $r1*$cosPhi] [expr $r1*$sinPhi]]
set pt2($i) [list [expr $r2*$cosPhi] [expr $r2*$sinPhi]]
set pt3($i) [list [expr $r3*$cosPhi] [expr $r3*$sinPhi]]
}
$w create path \
"M $pt2(1) L $pt1(1) M $pt2(2) L $pt1(2) M $pt3(3) L $pt1(3) \
M $pt2(4) L $pt1(4) M $pt2(5) L $pt1(5) M $pt3(6) L $pt1(6) \
M $pt2(7) L $pt1(7) M $pt2(8) L $pt1(8) M $pt3(9) L $pt1(9) \
M $pt2(10) L $pt1(10) M $pt2(11) L $pt1(11) M $pt3(12) L $pt1(12)" \
-tags clock -strokewidth 4 -strokelinecap round
$w create path "M 0 4 L $r4 4 $r4 10 $r2 0 $r4 -10 $r4 -4 0 -4 z" \
-stroke "" -fill gray50 -tags pointer
$w move clock 200 200
$w move pointer 200 200
proc ticker {secs} {
variable w
if {[winfo exists $w]} {
after 1000 [list clock::ticker [expr [incr secs] % 60]]
set phi [expr $secs*2.0*3.14159/60.0]
set m [::tkp::transform rotate $phi 200 200]
$w itemconfig pointer -m $m
}
}
ticker -15
}
package require tkpath 0.3.0
set t .c_ellipse
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
$w create circle 60 60 -r 32 -stroke "#c8c8c8" -fill "#e6e6e6"
$w create circle 200 60 -r 32 -stroke "#a19de2" -fill "#d6d6ff"
$w create circle 60 160 -r 40 -stroke "#9ac790" -fill "#cae2c5"
$w create circle 200 160 -r 40 -stroke "#e2a19d" -fill "#ffd6d6"
$w create ellipse 200 280 -rx 20 -ry 60 -stroke "#999999"
$w create ellipse 100 260 -rx 60 -ry 20 -stroke "#666666" -strokewidth 3 -fill "#bdbdbd"
set id [$w create ellipse 280 280 -rx 20 -ry 60]
$w bind $id <Button-1> [list puts "hit $id"]
$w create circle 300 220 -r 8 -fill red -stroke ""
$w create circle 300 240 -r 8 -fill green -stroke ""
$w create circle 300 260 -r 8 -fill blue -stroke ""
package require tkpath 0.3.0
destroy ._fillrule
toplevel ._fillrule
set w ._fillrule.c
pack [tkp::canvas $w -bg white -width 300 -height 300]
$w create path "M 10 10 h 80 v 80 h -80 z m 20 20 h 40 v 40 h -40 z" \
-fill green -fillrule nonzero
set id [$w create path "M 10 10 h 80 v 80 h -80 z m 20 20 h 40 v 40 h -40 z" \
-fill blue -fillrule evenodd]
$w move $id 100 0
proc ellipsepathCW {x y rx ry} {
return "M $x $y a $rx $ry 0 1 1 0 [expr {2*$ry}] a $rx $ry 0 1 1 0 [expr {-2*$ry}] Z"
}
proc ellipsepathCCW {x y rx ry} {
return "M $x $y a $rx $ry 0 1 0 0 [expr {2*$ry}] a $rx $ry 0 1 0 0 [expr {-2*$ry}] Z"
}
set r1 40
set r2 20
set circleCW "[ellipsepathCW 0 0 $r1 $r1] [ellipsepathCW 0 20 $r2 $r2]"
set id [$w create path $circleCW -fill green -fillrule nonzero]
$w move $id 50 120
set circleCCW "[ellipsepathCW 0 0 $r1 $r1] [ellipsepathCCW 0 20 $r2 $r2]"
set id [$w create path $circleCCW -fill blue -fillrule evenodd]
$w move $id 150 120
$w create text 50 240 -text "nonzero"
$w create text 150 240 -text "evenodd"
package require tkpath 0.3.0 set t .c_gradients toplevel $t set w $t.c pack [tkp::canvas $w -bg white -width 480 -height 400] set rainbow [::tkp::gradientstopsstyle rainbow] set g1 [$w gradient create linear -stops {{0 lightblue} {1 blue}}]$w create prect 10 10 210 60 -fill $g1$w create text 220 20 -anchor w -text "-stops {{0 lightblue} {1 blue}}" set g2 [$w gradient create linear -stops {{0 "#f60"} {1 "#ff6"}} \ -lineartransition {50 0 160 0} -units userspace]$w create prect 10 70 210 120 -fill $g2$w create text 220 80 -anchor w -text "-stops {{0 #f60} {1 #ff6}}"$w create text 220 100 -anchor w -text "-lineartransition {50 0 160 0} -units userspace" set g5 [$w gradient create linear -stops {{0 lightgreen} {1 green}}]$w create prect 10 130 210 180 -fill $g5$w create text 220 140 -anchor w -text "-stops {{0 lightgreen} {1 green}}" set g3 [$w gradient create linear -stops {{0 "#f60"} {1 "#ff6"}} \ -lineartransition {0 0 0 1}]$w create path "M 40 200 q 60 -200 120 0 z" -fill $g3 set g4 [$w gradient create linear -stops $rainbow]$w create prect 10 210 210 260 -fill $g4$w create text 220 220 -anchor w -text "rainbow" set g6 [$w gradient create radial -stops {{0 white} {1 black}}]$w create circle 60 330 -r 50 -fill $g6 set g7 [$w gradient create radial -stops {{0 white} {1 black}} \ -radialtransition {0.6 0.4 0.5 0.7 0.3}]$w create circle 200 330 -r 50 -fill $g7 -stroke "" set g8 [$w gradient create radial -stops {{0 white} {1 black}} \ -radialtransition {0.6 0.4 0.8 0.7 0.3}]$w create circle 340 330 -r 50 -fill $g8 -stroke "" proc GradientsOnButton {w} { set id [$w find withtag current] if {$id ne ""} { set type [$w type $id] switch -- $type { prect - path - circle - ellipse { set stroke [$w itemcget $id -stroke] set fill [$w itemcget $id -fill] puts "Hit a $type with stroke $stroke and fill $fill" } } }}$w bind all <Button-1> [list GradientsOnButton $w]
\ No newline at end of file
package require tkpath 0.3.0
set t .c_group
destroy $t
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
array set stroke [list 1 "#c8c8c8" 2 "#a19de2" 3 "#9ac790" 4 "#e2a19d"]
array set fill [list 1 "#e6e6e6" 2 "#d6d6ff" 3 "#cae2c5" 4 "#ffd6d6"]
$w create prect 10 10 390 390 -rx 20 -strokewidth 4 -stroke gray70 -tags g0
foreach i {1 2 3 4} {
set s($i) [$w style create -strokewidth 3 -stroke $stroke($i)]
set f($i) [$w style create -strokewidth 3 -stroke $stroke($i) -fill $fill($i)]
$w create group -tags g$i
$w create prect 10 10 180 180 -rx 10 -parent g$i -style $s($i)
set id [$w create path "M 0 0 l 30 40 h -60 z" -parent g$i -style $f($i)]
$w move $id 60 40
set id [$w create path "M -20 0 h 40 l -40 80 h 40 z" -parent g$i -style $f($i)]
$w move $id 140 40
set id [$w create ellipse 0 0 -rx 30 -ry 20 -parent g$i -style $f($i)]
$w move $id 60 140
}
$w move g1 10 10
$w move g2 200 10
$w move g3 10 200
$w move g4 200 200
unset -nocomplain s f stroke fill
package require tkpath 0.3.0
set t .c_hittest
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
set id [$w create path "M 20 20 L 120 20 v 30 h -20 z"]
$w bind $id <Button-1> [list puts "hit $id"]
set id [$w create path "M 10 80 h 100 v 100 z" -fill red]
$w bind $id <Button-1> [list puts "hit $id (red triangle)"]
set id [$w create path "M 20 200 Q 50 120 100 200 T 150 200 200 200"]
$w bind $id <Button-1> [list puts "hit $id (quad bezier)"]
set id [$w create path "M 10 250 h 80 v 80 h -80 z m 20 20 h 40 v 40 h -40 z" \
-fill green -fillrule nonzero]
$w bind $id <Button-1> [list puts "hit $id (green with nonzero rule)"]
set id [$w create path "M 110 250 h 80 v 80 h -80 z m 20 20 h 40 v 40 h -40 z" \
-fill blue -fillrule evenodd]
$w bind $id <Button-1> [list puts "hit $id (blue with evenodd rule)"]
set id [$w create path "M 220 50 v 100" -strokewidth 36 -strokelinecap round]
$w bind $id <Button-1> [list puts "hit $id (fat line with rounded caps)"]
package require tkpath 0.3.0
set t .c_image
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
set dir [file dirname [info script]]
set imageFile [file join $dir trees.gif]
set name [image create photo -file $imageFile]
set x 20
set y 20
$w create pimage $x $y -image $name
$w create prect $x $y \
[expr $x+[image width $name]] [expr $y+[image height $name]]
set m [::tkp::transform rotate 0.5]
lset m {2 0} 220
lset m {2 1} -120
$w create pimage 100 100 -image $name -matrix $m
set m [::tkp::transform scale 2 0.8]
$w create pimage 10 300 -image $name -matrix $m
#
# This file demonstrates the inheritance mechanisms. Note that items inherit
# style options set in their parents, but the items own style option
# takes precedence.
#
package require tkpath 0.3.0
set t .c_inherit
destroy $t
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
array set stroke [list 1 "#c8c8c8" 2 "#a19de2" 3 "#9ac790" 4 "#e2a19d"]
array set fill [list 1 "#e6e6e6" 2 "#d6d6ff" 3 "#cae2c5" 4 "#ffd6d6"]
$w create prect 10 10 390 390 -rx 20 -strokewidth 4 -stroke gray70 -tags g0
foreach i {1 2 3 4} {
$w create group -tags g$i -strokewidth 3 -stroke $stroke($i) -fill $fill($i)
$w create prect 10 10 180 180 -rx 10 -parent g$i -fill ""
set id [$w create path "M 0 0 l 30 40 h -60 z" -parent g$i]
$w move $id 60 40
set id [$w create path "M -20 0 h 40 l -40 80 h 40 z" -parent g$i]
$w move $id 140 40
set id [$w create ellipse 0 0 -rx 30 -ry 20 -parent g$i -strokewidth 6]
$w move $id 60 140
}
$w move g1 10 10
$w move g2 200 10
$w move g3 10 200
$w move g4 200 200
unset -nocomplain stroke fill
package require tkpath 0.3.0
set transparent 1
set t .c_isexy1
destroy $t
toplevel $t
set w $t.c
if {$transparent && $tcl_version >= 8.5 && [tk windowingsystem] eq "aqua"} {
wm attributes $t -transparent 1
tkp::canvas $w -width 400 -height 400 -bg systemTransparent -highlightthickness 0
} else {
tkp::canvas $w -width 400 -height 400 -highlightthickness 0
}
pack $w -fill both -expand 1
set ::tkp::antialias 1
set height 24
set width 120
set radius 12
array set light {
gray "#e6e6e6"
blue "#d6d6ff"
green "#cae2c5"
red "#ffd6d6"
}
proc drawcolumn {w tag {op 1.0}} {
global height width radius light
array set font [font actual systemSystemFont]
set family $font(-family)
set fsize $font(-size)
set g1 [$w gradient create linear \
-stops [list [list 0.0 gray90 $op] [list 1.0 gray60 $op]] \
-lineartransition {0 0 0 1}]
set ybase [expr {$height - ($height - $fsize)/2 - 1}]
set id1 [$w create prect 0 0 $width $height -rx $radius \
-fill $g1 -stroke gray50 -tags $tag -strokeopacity $op]
set id2 [$w create ptext 20 $ybase -fontfamily $family -fontsize $fsize \
-text "Vikings" -tags $tag -fill white -fillopacity $op]
set id3 [$w create ptext 20 $ybase -fontfamily $family -fontsize $fsize \
-text "Vikings" -tags $tag -fillopacity $op]
$w move $id2 0 1
set y 0
foreach col {gray blue green red} text {Tor Freja Fro Oden} {
incr y [expr {$height + 8}]
set id1 [$w create prect 0 0 $width $height -rx $radius \
-fill $light($col) -stroke "" -tags $tag -fillopacity $op]
set id2 [$w create ptext 20 $ybase -fill gray30 -text $text -tags $tag \
-fillopacity $op -fontfamily $family -fontsize $fsize]
$w move $id1 0 $y
$w move $id2 0 $y
}
}
proc drawbar {w tag} {
set g1 [$w gradient create linear \
-stops {{0.0 "#c3c3c3"} {1.0 "#969696"}} \
-lineartransition {0 0 0 1}]
$w create prect 0 0 2000 40 -fill $g1 -stroke "" -tags $tag
$w create pline 0 40 2000 40 -stroke "#404040"
}
proc drawbutton {win grad1 grad2 tag {type plain}} {
set w 26
set h 21
set r 4
set a [expr {$w-2*$r}]
set b [expr {$h-2*$r}]
set c [expr {$w-$r}]
switch -- $type {
plain {
set p "M $r 0 h $a q $r 0 $r $r v $b q 0 $r -$r $r h -$a q -$r 0 -$r -$r v -$b q 0 -$r $r -$r Z"
}
left {
set p "M $r 0 h $c v $h h -$c q -$r 0 -$r -$r v -$b q 0 -$r $r -$r Z"
}
center {
set p "M 0 0 h $w v $h h -$w z"
}
right {
set p "M 0 0 h $c q $r 0 $r $r v $b q 0 $r -$r $r h -$c z"
}
}
set id1 [$win create path $p -stroke "#c2c2c2" -tags $tag -fill ""]
set id2 [$win create path $p -stroke "#454545" -tags $tag -fill $grad1]
$win move $id1 0 1
$win bind $id2 <ButtonPress-1> [list $win itemconfig $id2 -fill $grad2]
$win bind $id2 <ButtonRelease-1> [list $win itemconfig $id2 -fill $grad1]
}
proc drawhammer {w tag} {
set path "M 0 -3 H 2 L 5 -2 V 0 H 1 V 8 H -1 V 0 H -5 V -2 L -2 -3 z"
return [$w create path $path -stroke "" -fill gray50 -tags $tag]
}
drawcolumn $w c1
$w move c1 10 60
drawcolumn $w c2 0.6
$w move c2 [expr {$width + 2*10}] 60
drawhammer $w hammer
$w move hammer 80 102
$w itemconfig hammer -matrix [::tkp::transform rotate -0.7 80 102]
drawbar $w bar
set g1 [$w gradient create linear \
-stops {{0.0 "#ffffff"} {0.5 "#d1d1d1"} {1.0 "#a9a9a9"}} \
-lineartransition {0 0 0 1}]
set g2 [$w gradient create linear \
-stops {{0.0 "#222222"} {0.1 "#4b4b4b"} {0.9 "#616161"} {1.0 "#454545"}} \
-lineartransition {0 0 0 1}]
drawbutton $w $g1 $g2 b1
set l 12
set path "M 0 0 h $l M 0 3 h $l M 0 6 h $l M 0 9 h $l"
set id [$w create path $path -stroke "#0f0f0f" -tags b1]
$w move $id 8 6
set id [$w create path $path -stroke white -strokeopacity 0.5 -tags b1]
$w move $id 8 7
$w move b1 20 10
drawbutton $w $g1 $g2 b2 left
set path "M 0 0 l 9 4 v -9 z"
set id [$w create path $path -fill white -stroke "" -tags {b2 b2-a}]
set id [$w create path $path -fill black -stroke "" -tags {b2 b2-a} -fillopacity 0.7]
$w move b2-a 8 10
$w move b2 60 10
drawbutton $w $g1 $g2 b3 right
set path "M 0 0 l -9 4 v -9 z"
set id [$w create path $path -fill white -stroke "" -tags {b3 b3-a}]
set id [$w create path $path -fill black -stroke "" -tags {b3 b3-a} -fillopacity 0.78]
$w move b3-a 17 10
$w move b3 [expr {60+26}] 10
proc drawletter {w c tag} {
array set font [font actual systemSystemFont]
set family $font(-family)
set fsize $font(-size)
$w create ptext 10 17 -fontfamily $family -fontsize $fsize -tags $tag \
-text $c -fill white
$w create ptext 10 16 -fontfamily $family -fontsize $fsize -tags $tag \
-text $c -fillopacity 0.8
}
drawbutton $w $g1 $g2 b4 left
drawbutton $w $g1 $g2 b5 center
drawbutton $w $g1 $g2 b6 center
drawbutton $w $g1 $g2 b7 right
drawletter $w M b4c
drawletter $w A b5c
drawletter $w T b6c
drawletter $w S b7c
$w move b4 [expr {130+0*26}] 10
$w move b5 [expr {130+1*26}] 10
$w move b6 [expr {130+2*26}] 10
$w move b7 [expr {130+3*26}] 10
$w move b4c [expr {130+0*26}] 10
$w move b5c [expr {130+1*26}] 10
$w move b6c [expr {130+2*26}] 10
$w move b7c [expr {130+3*26}] 10
package require tkpath 0.3.0
set t .c_lines
toplevel $t
set w $t.c
pack [tkp::canvas $w -width 400 -height 400 -bg white]
$w create pline 20 20 180 20
$w create pline 200 20 260 20 -stroke blue
$w create pline 20 30 180 30 -stroke green
$w create pline 200 30 260 30 -stroke red
$w create pline 20 40 260 40 -stroke "#999999"
$w create pline 40 50 120 80 -stroke "#666666" -strokewidth 3
$w create pline 150 60 170 60 -stroke red -strokewidth 4
$w create pline 150 70 170 70 -stroke green -strokewidth 4
$w create pline 150 80 170 80 -stroke blue -strokewidth 4
$w create polyline 20 200 30 200 30 180 50 180 50 200 \
70 200 70 160 90 160 90 200 110 200 110 120 130 120 \
130 200
$w create polyline 150 200 200 120 150 120 200 200 -stroke gray50 -strokewidth 4
$w create polyline 220 200 270 120 220 120 270 200 -stroke gray50 -strokewidth 4 \
-fill gray80
$w create ppolygon 75 237 89 280 134 280 98 307 111 350 75 325 38 350 \
51 307 15 280 60 280 -stroke "#9ac790" -strokewidth 4 -fill "#cae2c5"
$w create ppolygon 240 250 283 275 283 325 240 350 196 325 196 275 \
-stroke "#a19de2" -strokewidth 6 -fill "#d6d6ff"
$w create text 300 20 -anchor w -text "pline"
$w create text 300 150 -anchor w -text "polyline"
$w create text 300 300 -anchor w -text "ppolygon"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment