From 3c74c6209065a27ce5bfab85c0164bd826301357 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Bl=C3=A4sius?= Date: Mon, 3 Mar 2014 16:51:15 +0100 Subject: [PATCH] decorator: remove unused stuff, created basic sample files --- ipelets/decorator/{test.ipe => decorator.ipe} | 615 +++++++++++++----- ipelets/decorator/decorator.isy | 22 + ipelets/decorator/decorator.lua | 85 +-- 3 files changed, 477 insertions(+), 245 deletions(-) rename ipelets/decorator/{test.ipe => decorator.ipe} (50%) create mode 100644 ipelets/decorator/decorator.isy diff --git a/ipelets/decorator/test.ipe b/ipelets/decorator/decorator.ipe similarity index 50% rename from ipelets/decorator/test.ipe rename to ipelets/decorator/decorator.ipe index d3c57e6..33250e9 100644 --- a/ipelets/decorator/test.ipe +++ b/ipelets/decorator/decorator.ipe @@ -1,9 +1,7 @@ - -\usepackage[english]{babel} -\usepackage{blindtext} + @@ -164,96 +162,6 @@ h h - - - --4 4 m --4 0 l -0 0 l -0 4 l -h - - --4 0 m --4 4 l -0 4 l - - - - - -5 1 m -4 0 0 4 1 1 1 5 a --5 5 l --5 -1 l -4 0 0 4 -1 -1 -1 -5 a -5 -5 l -h - - - - --5 5 m --5 -5 l -5 -5 l -5 5 l -h - - - - -5 1 m -4 0 0 4 1 1 1 5 a --1 5 l -4 0 0 4 -1 1 -5 1 a --5 -1 l -4 0 0 4 -1 -1 -1 -5 a -1 -5 l -4 0 0 4 1 -1 5 -1 a -h - - - - --5 5 m --5 11 l -1 11 l -4 0 0 -4 1 7 5 7 a -5 5 l --5 5 m --5 -1 l -4 0 0 4 -1 -1 -1 -5 a -5 -5 l -5 1 l -5 5 l --5 5 m -5 5 l - - - - - -10 2 m -8 0 0 8 2 2 2 10 a --10 10 l --10 -2 l -8 0 0 8 -2 -2 -2 -10 a -10 -10 l -h - - --10 10 m -10 -10 l - - -12 20 m -12 12 l -20 12 l -20 20 l -h - - - @@ -263,8 +171,6 @@ h - - @@ -272,6 +178,7 @@ h + @@ -287,6 +194,7 @@ h + @@ -314,6 +222,7 @@ h + @@ -322,112 +231,478 @@ h - - - - - -582 166 m -8 0 0 8 574 166 574 174 a -266 174 l -266 65.503 l -8 0 0 8 274 65.503 274 57.503 a -582 57.503 l + + + + +0 64 m +0 0 l +64 0 l +64 64 l h -266 174 m -582 57.503 l +8 56 m +8 8 l +56 8 l +56 56 l +h + + - -86 62 m -8 0 0 8 78 62 78 70 a -42 70 l -42 34 l -8 0 0 8 50 34 50 26 a -86 26 l + +0 64 m +0 0 l +64 0 l +64 64 l h -42 70 m -86 26 l +4 60 m +4 4 l +60 4 l +60 60 l +h - -469 369 m -4 0 0 4 465 369 465 373 a -159 373 l -4 0 0 4 159 369 155 369 a -155 262.503 l -4 0 0 4 159 262.503 159 258.503 a -465 258.503 l -4 0 0 4 465 262.503 469 262.503 a + + + + +0 64 m +0 0 l +64 0 l +64 64 l h - -139 501 m -139 386.503 l -453 386.503 l -453 501 l + +2 62 m +2 2 l +62 2 l +62 62 l h - -469 625 m -4 0 0 4 465 625 465 629 a -155 629 l -155 518.503 l -4 0 0 4 159 518.503 159 514.503 a -469 514.503 l + + + + + +0 64 m +0 0 l +64 0 l +64 64 l +h + + +1 63 m +1 1 l +63 1 l +63 63 l +h + + + + + + +64 60 m +4 0 0 4 60 60 60 64 a +4 64 l +4 0 0 4 4 60 0 60 a +0 4 l +4 0 0 4 4 4 4 0 a +60 0 l +4 0 0 4 60 4 64 4 a +h + + +4 60 m +4 4 l +60 4 l +60 60 l +h + + + + + + +64 60 m +4 0 0 4 60 60 60 64 a +4 64 l +4 0 0 4 4 60 0 60 a +0 4 l +4 0 0 4 4 4 4 0 a +60 0 l +4 0 0 4 60 4 64 4 a +h + + +8 56 m +8 8 l +56 8 l +56 56 l h -\blindtext -\blindtext -\blindtext -\blindtext - -48 128 m -48 96 l -80 96 l -80 128 l + + + + + +64 60 m +4 0 0 4 60 60 60 64 a +4 64 l +4 0 0 4 4 60 0 60 a +0 4 l +4 0 0 4 4 4 4 0 a +60 0 l +4 0 0 4 60 4 64 4 a h -48 64 m -48 32 l -80 32 l -80 64 l +2 62 m +2 2 l +62 2 l +62 62 l +h + + + + + + +64 60 m +4 0 0 4 60 60 60 64 a +4 64 l +4 0 0 4 4 60 0 60 a +0 4 l +4 0 0 4 4 4 4 0 a +60 0 l +4 0 0 4 60 4 64 4 a h -12 28 m -12 26 l -14 26 l -14 28 l +1 63 m +1 1 l +63 1 l +63 63 l h + + + - -10 2 m -8 0 0 8 2 2 2 10 a --10 10 l --10 -2 l -8 0 0 8 -2 -2 -2 -10 a -10 -10 l + +64 62 m +2 0 0 2 62 62 62 64 a +2 64 l +2 0 0 2 2 62 0 62 a +0 2 l +2 0 0 2 2 2 2 0 a +62 0 l +2 0 0 2 62 2 64 2 a h - --10 10 m -10 -10 l + +8 56 m +8 8 l +56 8 l +56 56 l +h - -12 20 m -12 12 l -20 12 l -20 20 l + + + + + +64 62 m +2 0 0 2 62 62 62 64 a +2 64 l +2 0 0 2 2 62 0 62 a +0 2 l +2 0 0 2 2 2 2 0 a +62 0 l +2 0 0 2 62 2 64 2 a h + +4 60 m +4 4 l +60 4 l +60 60 l +h + + + + + + +64 62 m +2 0 0 2 62 62 62 64 a +2 64 l +2 0 0 2 2 62 0 62 a +0 2 l +2 0 0 2 2 2 2 0 a +62 0 l +2 0 0 2 62 2 64 2 a +h + + +2 62 m +2 2 l +62 2 l +62 62 l +h + + + + + + +64 62 m +2 0 0 2 62 62 62 64 a +2 64 l +2 0 0 2 2 62 0 62 a +0 2 l +2 0 0 2 2 2 2 0 a +62 0 l +2 0 0 2 62 2 64 2 a +h + + +1 63 m +1 1 l +63 1 l +63 63 l +h + + + + + + + + + +216 230 m +2 0 0 2 214 230 214 232 a +186 232 l +2 0 0 2 186 230 184 230 a +184 186 l +2 0 0 2 186 186 186 184 a +214 184 l +2 0 0 2 214 186 216 186 a +h + + + + +190 226 m +190 190 l +210 190 l +210 226 l +h + + + + +304 118 m +2 0 0 2 302 118 302 120 a +274 120 l +2 0 0 2 274 118 272 118 a +272 74 l +2 0 0 2 274 74 274 72 a +302 72 l +2 0 0 2 302 74 304 74 a +h + + + + +300 114 m +2 0 0 2 298 114 298 116 a +278 116 l +2 0 0 2 278 114 276 114 a +276 78 l +2 0 0 2 278 78 278 76 a +298 76 l +2 0 0 2 298 78 300 78 a +h + + + + +298 112 m +2 0 0 2 296 112 296 114 a +280 114 l +2 0 0 2 280 112 278 112 a +278 80 l +2 0 0 2 280 80 280 78 a +296 78 l +2 0 0 2 296 80 298 80 a +h + + + + +297 111 m +2 0 0 2 295 111 295 113 a +281 113 l +2 0 0 2 281 111 279 111 a +279 81 l +2 0 0 2 281 81 281 79 a +295 79 l +2 0 0 2 295 81 297 81 a +h + + + + +248 116 m +4 0 0 4 244 116 244 120 a +220 120 l +4 0 0 4 220 116 216 116 a +216 76 l +4 0 0 4 220 76 220 72 a +244 72 l +4 0 0 4 244 76 248 76 a +h + + + + +244 112 m +4 0 0 4 240 112 240 116 a +224 116 l +4 0 0 4 224 112 220 112 a +220 80 l +4 0 0 4 224 80 224 76 a +240 76 l +4 0 0 4 240 80 244 80 a +h + + + + +242 110 m +4 0 0 4 238 110 238 114 a +226 114 l +4 0 0 4 226 110 222 110 a +222 82 l +4 0 0 4 226 82 226 78 a +238 78 l +4 0 0 4 238 82 242 82 a +h + + + + +241 109 m +4 0 0 4 237 109 237 113 a +227 113 l +4 0 0 4 227 109 223 109 a +223 83 l +4 0 0 4 227 83 227 79 a +237 79 l +4 0 0 4 237 83 241 83 a +h + + + + +160 120 m +160 72 l +192 72 l +192 120 l +h + + + + +164 116 m +164 76 l +188 76 l +188 116 l +h + + + + +166 114 m +166 78 l +186 78 l +186 114 l +h + + + + +167 113 m +167 79 l +185 79 l +185 113 l +h + + + + +176 112 m +176 80 l + + +168 95 m +184 95 l + + + + +176 112 m +176 80 l + + +168 95 m +184 95 l + + + +64 62 m +2 0 0 2 62 62 62 64 a +2 64 l +2 0 0 2 2 62 0 62 a +0 2 l +2 0 0 2 2 2 2 0 a +62 0 l +1.76777 0 0 1.76777 62.25 1.75 64 2 a +h + + +8 56 m +8 8 l +56 8 l +56 56 l +h + + + +176 112 m +176 80 l + + +168 95 m +184 95 l + + + + +176 112 m +176 80 l + + +168 95 m +184 95 l + diff --git a/ipelets/decorator/decorator.isy b/ipelets/decorator/decorator.isy new file mode 100644 index 0000000..a5e7834 --- /dev/null +++ b/ipelets/decorator/decorator.isy @@ -0,0 +1,22 @@ + + + + + + + -16 16 m + -16 -16 l + 16 -16 l + 16 16 l + h + + + -8 8 m + -8 -8 l + 8 -8 l + 8 8 l + h + + + + diff --git a/ipelets/decorator/decorator.lua b/ipelets/decorator/decorator.lua index cffa3b5..389a260 100644 --- a/ipelets/decorator/decorator.lua +++ b/ipelets/decorator/decorator.lua @@ -93,9 +93,14 @@ end function run_fancy_decorator (model) local p = model:page() local prim = p:primarySelection() + if (not prim) then + report_problem(model, "You must select somethings.") + return + end local bbox_target = p:bbox(prim) local deco_obj_group = ask_for_decorator(model) + if (not deco_obj_group) then return end if (deco_obj_group:type() ~= "group") then report_problem(model, "The decoration must be a group.") return @@ -106,7 +111,11 @@ function run_fancy_decorator (model) local bbox_source = bbox(last_obj, p) local center = ipe.Vector(bbox_source:left() + 0.5 * bbox_source:width(), bbox_source:bottom() + 0.5 * bbox_source:height()) - + + if (#objects == 0) then + report_problem(model, "The decoration must be a group of at least two elements.") + return + end for i,deco_obj in ipairs(objects) do if (deco_obj:type() ~= "path") then report_problem(model, "Each decoration object needs to be a path.") @@ -141,53 +150,6 @@ function ask_for_decorator(model) return symbol:clone() end --- Decorate something given by its bounding box with a given deco --- object, which needs to be a path. -function decorate(model, bbox, deco) - if (deco:type() ~= "path") then - report_problem(model, "The decoration needs to be a path.") - return - end - - local shape = deco:shape() - local m = deco:matrix() - for _,path in pairs(shape) do - for _,subpath in ipairs(path) do - -- move all points - for i,point in ipairs(subpath) do - subpath[i] = translation(bbox, m*point) * m*point - end - - -- for acs, the center must be translated separately - if (subpath["type"] == "arc") then - local arc = subpath["arc"] - local arc_pos = arc:matrix():translation() - subpath["arc"] = translation(bbox, m*arc_pos) * m * arc - end - end - end - -- update model - deco:setShape(shape) - deco:setMatrix(ipe.Matrix()) - model:creation("create", deco) -end - --- The translation matrix that should be applied to a given point when --- doing the decoration. -function translation(bbox, point) - local dx = 0 - local dy = 0 - if (point.x > 0) then - dx = dx + bbox:width() - end - if (point.y > 0) then - dy = dy + bbox:height() - end - dx = dx + bbox:left() - dy = dy + bbox:bottom() - return ipe.Translation(dx, dy) -end - function mainWindow(model) if model.ui.win == nil then return model.ui @@ -196,34 +158,7 @@ function mainWindow(model) end end -function run_decorator(model) - -- get bbox of primary selection - local p = model:page() - local prim = p:primarySelection() - if not prim then - model.ui:explain("An object must be selected.") - return - end - local bbox = p:bbox(prim) - - -- create decorator object - local dialog = ipeui.Dialog(mainWindow(model), "Select a decorator.") - local decorators = decorator_names(model) - dialog:add("deco", "combo", decorators, 1, 1, 1, 2) - dialog:add("ok", "button", { label="&Ok", action="accept" }, 2, 2) - dialog:add("cancel", "button", { label="&Cancel", action="reject" }, 2, 1) - local r = dialog:execute() - if not r then return end - local deco_name = decorators[dialog:get("deco")] - local symbol = model.doc:sheets():find("symbol", deco_name) - local deco = symbol:clone() - - -- run the decoration - decorate(model, bbox, deco) -end - label = "Decorator" methods = { - { label = "Decorate", run=run_decorator}, { label = "Fancy decorator", run=run_fancy_decorator}, } -- 2.34.1