ftp.nice.ch/pub/next/graphics/vector/PencilTWO.s.tar.gz#/PencilTWO/Source/PencilLibrary/Blend.tcl

This is Blend.tcl in view mode; [Download] [Up]

proc cp {o} {return [lindex $o 7]}

proc blend {st} {
	set s [P_selection]
	set a [lindex $s 0]
	set b [lindex $s 1]
	set ca [cp [P_getobject $a]]
	set cb [cp [P_getobject $b]]
	for {set t $st} {$t<1} {set t [expr $t+$st]} {
		P_addobject 0 [lreplace $o 7 7 [doBlend $ca $cb $t]]
	}
	P_display
}

proc doBlend {oa ob z} {
	set n [llength $oa]
	set r ""
	for {set i 0} {$i<$n} {incr i} {
		lappend r [expr [lindex $oa $i]*(1-$z)+[lindex $ob $i]*$z]
	}
	return $r
}

proc mat {o} {return [lindex $o 9]}

proc setcols {o c} {
	return [eval "lreplace {$o} 10 15 $c"]
}

proc blend {st} {
	set s [P_selection]
	if [llength $s]!=2 {
		alertPanel "Blend" "Please select two objects before blending..." "OK"
	} {
	set a [lindex $s 0]
	set b [lindex $s 1]
	set ca [cp [P_getobject $a]]
	set cb [cp [P_getobject $b]]
	set o [P_getobject $a]
	set z [P_getobject $b]
	set mo [mat $o]
	set mz [mat $z]
	set Ca [lrange $o 10 15]
	set Cb [lrange $z 10 15]
	set dx [expr [lindex $mz 4]-[lindex $mo 4]]
	set dy [expr [lindex $mz 5]-[lindex $mo 5]]
	for {set t $st} {$t<1} {set t [expr $t+$st]} {
		P_moveObject  [P_addobject 0 [setcols [lreplace $o 7 7 [doBlend $ca $cb $t]] [doBlend $Ca $Cb $t]]] [expr $dx*$t] [expr $dy*$t]
	}
	P_select1 $b
	P_front
	P_select1 -1
	}
	# P_display
}

P_addMenuItem 2 "Blend (4 steps)" "" {blend .25}
P_addMenuItem 2 "Blend (10 steps)" + {blend .1}
P_addMenuItem 2 "Blend (20 steps)" "" {blend .05}
P_addMenuItem 2 "Blend (50 steps)" "" {blend .02}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.