Public feed #725550

SAVE/LOAD

public text v1 · immutable
Raw Edit
·published 2007-10-04 14:44 UTC
rendered paste body
View.Set ("graphics:max,max")

var mx, my, mb : int
var col : int := red %colour
var current_tool : string := "no tool"
var Daffy: int := Pic.FileNew ("daffy.jpg")
var font : int := Font.New ("sans serif:14:bold")
var Fox: int:= Pic.FileNew ("Fox.jpg")

%Drawing the Screen
%Tools
drawfillmapleleaf (50, 50, 100, 100, red)
drawbox (50, 50, 100, 100, black) % maple Leaf

drawbox (50, 120, 100, 170, black) %load
Font.Draw ("Load", 51, 140, font, red)
drawbox (49, 190, 105, 240, black) % Daffy
Pic.Draw (Daffy, 50, 190, picCopy)
drawbox (51, 310, 100, 260, black) %save
Font.Draw ("Save", 51, 280, font, red)
drawbox (49,340,100,400,black) %Fox
Pic.Draw (Fox, 50 , 350, picCopy)

%Canvas

drawbox (250, 50, 800, 400, black)


loop
    mousewhere (mx, my, mb)
    % tool selection
    if mb = 1 and mx > 50 and my > 50 and mx < 100 and my < 100 then
        current_tool := "mapleleaf"
    elsif mb = 1 and mx > 50 and my > 120 and mx < 100 and my < 170 then     % load
        Pic.ScreenLoad ("mypic.bmp", 250, 50, picCopy)
    elsif mb = 1 and mx > 50 and my > 190 and mx < 100 and my < 240 then
        current_tool := "daffy"
    elsif mb= 1 and mx  >49 and my >350 and mx <100 and my >350 then
        current_tool := "fox"
    elsif mb = 1 and mx > 50 and my > 260 and mx < 100 and my < 280 then  %save
        Pic.ScreenSave (250, 50, 800, 400, "mypic.bmp")

    elsif mb = 1 and mx > 250 and my > 50 and mx < 800 and my < 400 then
        %user has clicked in canvas
        if current_tool = "mapleleaf" then
            drawfillmapleleaf (mx - 25, my - 25, mx + 25, my + 25, col)
        elsif current_tool = "daffy" then
            Pic.Draw (Daffy, mx - 25, my - 25, picCopy)
        elsif current_tool = "fox" then
            Pic.Draw (Fox, mx - 25, my -25, picCopy)
        end if
    end if
end loop