Well in this case more like “Huh I guess I should finish that damned thing up” 😛
When I watched the recent keynote there was one bit that made me think exactly that. It was the point where geoff was showing off drawing from a XojoScript.
I’d tinkered with something on and off for a while – and its been more off lately than on.
But when I saw that I thought “Gee. I really should finish demo that up.”
So I did. And here you are. A way to draw from XojoScript to a graphics that resides in Xojo code. In the demo it comes from the paint event of a canvas.
Doesn’t currently support any additional clipping of the graphics but I’ll see what I can do.
There’s no support for Pictures since pictures do not exist in XojoScript. That might also be possible to do without too much effort but I dont have any need for it at the moment.
The ONE thing to remember with XojoScript is it is all very CLASSIC API 1.0
So extension methods like String.Mid, String.len etc dont exist (I could add those too but …)
Have fun with it. Let me know what you think.
UPDATE : Clipping has been added !
Huh? a blank white screen…. perhaps a minimal doc that explains what to do with it?
updates are coming 🙂
but in the left hand side you can write xojo script that draws graphics same as you could in Xojo itself
for now paste this in the left hand side
// Tweak these constants to change the logo's appearance.
Const TEXT_COLOR = &c0e73c0
Const BACKGROUND_COLOR = &cfefefe
Const BORDER_COLOR = &c0e73c0
Const LOGO_TEXT_SIZE = 200
Dim logoText As String = "if(!0" + &u338 + ")"
Dim w, h As Integer
Dim borderThickness As Integer = LOGO_TEXT_SIZE * 0.30
g.TextSize = LOGO_TEXT_SIZE
g.Bold = True
w = g.StringWidth(logoText) + borderThickness
h= g.TextHeight + borderThickness
Dim penSize As Integer = LOGO_TEXT_SIZE / 10
g.PenHeight = penSize
g.PenWidth = g.PenHeight
// Draw a filled rounded rectangle background.
g.ForeColor = BACKGROUND_COLOR
g.FillRoundRect(0,(PenSize/2), w + PenSize, h,borderThickness, borderThickness)
// Draw the outline of a rounded rectangle to act as the border.
g.ForeColor = BORDER_COLOR
g.DrawRoundRect(0, (PenSize/2), w + PenSize, h, borderThickness, borderThickness)
Dim x As Integer = ((w + PenSize) - g.StringWidth(logoText)) / 2
Dim y As Integer = g.TextAscent + (h - g.TextHeight) / 2
g.ForeColor = TEXT_COLOR
For i As Integer = 0 To logoText.Len
Dim y1 As Integer = y
// yes we use the really old style here as the extension method in XojoSCript gets it wrong
// see
Dim c As String = mid(logoText,i+1, 1)
If c = "0" Then
c = "0" + &u338
i = i + 1
End If
If c = "(" Or c = ")" Then
y1 = y1 - (0.075 * LOGO_TEXT_SIZE)
End If
g.DrawString(c, x, y1)
x = x + g.StringWidth(c)
Next i
EDIT : UPDATE pushed !
Just for the public record…. The above script that Norm posted is based on an Xojo Desktop program that I wrote in response to a Logo request for the “If Not Nil” forum
Indeed it is
I thought it used a sufficient amount of graphics calls to make it a good test without me having to so create something else 🙂
FWIW I did push a new update that now supports clipping as well
More updates are in the works to make it an option to use API 1 or API 2
no worries…. just wanted to be on the record is all 🙂
Pushed an update that has a proper attribution in the first lines of the included sample code