Travis, I loaded up Cairo to try it out and ran into a couple of small problems. I was trying to recreate the Kapow image from your blog and there was some code in your example that wasn't in the package.
ArithmeticValue? or Point? or Magnitude?>>half (easy enough, I just made my own ) ImageSurface class>>withLastRights: (harder for me to conjure up) String>>dropSeparators (easy enough too) The code snippet is below: Mike spikes := 10. imageWidth := 384. imageHeight := 256. center := (imageWidth @ imageHeight) half. fuzz := 16. shadowOffset := 10. innerRatio := 0.7. random := Random standard. star := (1 to: spikes * 2) collect: [:n | | z | z := n / spikes * Float pi. z cos @ z sin * (center - fuzz - shadowOffset) * (n odd ifTrue: [innerRatio] ifFalse: [1]) + (random next @ random next * fuzz) + center] string := 'KAPOW'. surface := ImageSurface format: #alphaColor extent: imageWidth @ imageHeight cr := surface context. cr lineWidth: 2. cr save. cr translate: shadowOffset asPoint. cr completePath: star. cr sourceRed: 0 green: 0 blue: 0 alpha: 0.5 cr fill. cr restore. cr completePath: star. pattern := RadialGradient from: center radius: 10 to: center radius: 230. pattern addStopAt: 0 red: 1 green: 1 blue: 0.2. pattern addStopAt: 1 red: 1 green: 0 blue: 0 cr source: pattern. cr fill. cr completePath: star. cr sourceRed: 0 green: 0 blue: 0. cr stroke. cr selectFontFace: 'Sans' slant: 0 bold: true cr fontSize: 50. dimensions := cr measureString: string. x := imageWidth half - (dimensions width half + dimensions xBearing). y := imageHeight half - (dimensions height half + dimensions yBearing). bendPoint := [:point | anchor := imageWidth half @ 500. angle := Double pi half - ((point x - anchor x) / imageWidth). t := 3 * Double pi / 4 - angle + 0.05. angle := 3 * Double pi / 4 - (t ** 1.8). radius := anchor y - (imageHeight / 2 + ((point y - (imageHeight / 2)) * t * 2)). anchor + (angle cos @ angle sin negated * radius)]. cr moveTo: x @ y. cr textPath: string. path := cr copyFlatPath. cr newPath. path doMove: [:move | cr moveTo: (bendPoint value: move point)] line: [:line | cr lineTo: (bendPoint value: line point)] close: [:close | cr closePath]. pattern := LinearGradient from: (imageWidth half - 10) @ (imageHeight / 4) to: (imageWidth half + 10) @ (imageHeight * 3 / 4). pattern addStopAt: 0 colorValue: ColorValue white. pattern addStopAt: 1 red: 0 green: 0 blue: 0.4. cr source: pattern. cr fillPreserve. cr sourceColorValue: ColorValue black. cr stroke. surface saveAsPng: string dropSeparators , '.png'
|
On Aug 18, 2006, at 22:13, Mike Hales wrote: Travis, I loaded up Cairo to try it out and ran into a couple of small problems. I was trying to recreate the Kapow image from your blog and there was some code in your example that wasn't in the package. Mike, Do you have the latest version of Weaklings loaded? I just ran the kapow.ws example and generated it fine. But about version 15 or so, I ditched use of OSHandle and just rewrote all of that using Weaklings (far easier) and Weaklings got polished a little bit as a result. -- Travis Griggs Objologist "You A students, you'll be back soon teaching here with me. You B students, you'll actually go on to be real engineers. You C students, you'll go into management and tell the A and B students what to do." - My Fluid Dynamics Professor whom I have yet to disprove DISCLAIMER: This email is bound by the terms and conditions described at http://www.key.net/disclaimer.htm |
Free forum by Nabble | Edit this page |