Platforms to show: All Mac Windows Linux Cross-Platform
/Picture/Rotate picture/Free Rotation
Required plugins for this example: MBS Picture Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Picture/Rotate picture/Free Rotation
This example is the version from Wed, 14th May 2019.
Project "Free Rotation.xojo_binary_project"
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
draw g
End EventHandler
End Control
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub ValueChanged()
run
End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
dim n as integer
if CheckBox1.Value then
n=slider1.value
n=n+1
if n=360 then
n=0
end if
slider1.value=n
end if
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
original=Church
run
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
dim p as Picture
dim g as Graphics
p = new Picture(300,300,32)
g=p.Graphics
g.ForeColor=&cFF0000
g.FillRect 0,0,100,100
g.ForeColor=&c00FF00
g.FillRect 100,0,100,100
g.ForeColor=&c0000FF
g.FillRect 200,0,100,100
g.ForeColor=&cFFFF00
g.FillRect 0,100,100,100
g.ForeColor=&c00FFFF
g.FillRect 100,100,100,100
g.ForeColor=&cFF00FF
g.FillRect 200,100,100,100
g.ForeColor=&c000000
g.FillRect 0,200,100,100
g.ForeColor=&c777777
g.FillRect 100,200,100,100
g.ForeColor=&cFFFFFF
g.FillRect 200,200,100,100
original=p
run
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
dim p as Picture
dim g as Graphics
p = new Picture(300,300,32)
g=p.Graphics
g.ForeColor=&c000000
g.FillRect 0, 0,100,100
g.ForeColor=&c202020
g.FillRect 100, 0,100,100
g.ForeColor=&c404040
g.FillRect 200, 0,100,100
g.ForeColor=&c606060
g.FillRect 0,100,100,100
g.ForeColor=&c808080
g.FillRect 100,100,100,100
g.ForeColor=&cA0A0A0
g.FillRect 200,100,100,100
g.ForeColor=&cC0C0C0
g.FillRect 0,200,100,100
g.ForeColor=&cE0E0E0
g.FillRect 100,200,100,100
g.ForeColor=&cFFFFFF
g.FillRect 200,200,100,100
original=p
run
End EventHandler
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
End Control
Control CheckBox2 Inherits CheckBox
ControlInstance CheckBox2 Inherits CheckBox
EventHandler Sub Action()
run
End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action()
dim c as color
c=background
if SelectColor(C,"Select background color:") THEN
background=c
run
end if
End EventHandler
End Control
EventHandler Function KeyDown(Key As String) As Boolean
if key=" " then
Timer1.Mode=2-Timer1.Mode
Return true
end if
End EventHandler
EventHandler Sub Open()
background=rgb(255,255,255)
original=church
current=original
End EventHandler
Sub draw(g as graphics)
dim x,y,w,h as integer
dim xx,yy as integer
w=current.Width
h=current.Height
x=(g.Width-w)/2
y=(g.Height-h)/2
if CheckBox2.Value then
g.ForeColor=Rgb(255,0,0)
xx=x
yy=g.Height
if xx>0 and yy>0 then
g.FillRect 0,0,xx,yy
end if
g.ForeColor=Rgb(0,255,0)
xx=g.Width-x
yy=y
if xx>0 and yy>0 then
g.FillRect x,0,xx,yy
end if
g.ForeColor=Rgb(0,0,255)
xx=g.Width-x-w
yy=g.Height-y
if xx>0 and yy>0 then
g.FillRect x+w,y,xx,yy
end if
g.ForeColor=Rgb(0,0,0)
xx=g.Width-x
yy=g.Height-y-h
if xx>0 and yy>0 then
g.FillRect x,y+h,xx,yy
end if
else
g.ClearRect 0,0,g.Width,g.Height
end if
g.DrawPicture current,x,y,w,h
End Sub
Protected Sub run()
current=original.RotateMBS(Slider1.value,background)
Canvas1.Invalidate
End Sub
Property Protected background As color
Property Protected current As picture
Property Protected original As picture
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu7 = ""
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu6 = ""
MenuItem UntitledMenu5 = ""
MenuItem UntitledMenu4 = ""
End MenuBar
ExternalFile Church
End ExternalFile
Class App Inherits Application
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Picture Plugin.