Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
adc74723
Commit
adc74723
authored
25 years ago
by
Mirar (Pontus Hagland)
Browse files
Options
Downloads
Patches
Plain Diff
poly added (convinent for me, it's not finished yet)
Rev: src/modules/Image/poly.c:1.1
parent
dbbbd45b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
src/modules/Image/poly.c
+189
-0
189 additions, 0 deletions
src/modules/Image/poly.c
with
190 additions
and
0 deletions
.gitattributes
+
1
−
0
View file @
adc74723
...
...
@@ -219,6 +219,7 @@ testfont binary
/src/modules/Image/operator.c foreign_ident
/src/modules/Image/orient.c foreign_ident
/src/modules/Image/pattern.c foreign_ident
/src/modules/Image/poly.c foreign_ident
/src/modules/Image/polyfill.c foreign_ident
/src/modules/Image/testsuite.in.in foreign_ident
/src/modules/Java/Makefile.in foreign_ident
...
...
This diff is collapsed.
Click to expand it.
src/modules/Image/poly.c
0 → 100644
+
189
−
0
View file @
adc74723
/*
**! module Image
**! note
**! $Id: poly.c,v 1.1 1999/07/16 11:43:50 mirar Exp $
**! class Poly
**!
*/
#include
"global.h"
RCSID
(
"$Id: poly.c,v 1.1 1999/07/16 11:43:50 mirar Exp $"
);
#include
"image_machine.h"
#include
<math.h>
#include
"stralloc.h"
#include
"pike_macros.h"
#include
"object.h"
#include
"constants.h"
#include
"interpret.h"
#include
"svalue.h"
#include
"array.h"
#include
"mapping.h"
#include
"threads.h"
#include
"builtin_functions.h"
#include
"dmalloc.h"
#include
"operators.h"
#include
"module_support.h"
#include
"opcodes.h"
#include
"image.h"
#include
"colortable.h"
#include
"initstuff.h"
#ifdef PFLOAT
#undef PFLOAT
#endif
#define PFLOAT double
#ifdef THIS
#undef THIS
#endif
#define THIS ((struct poly *)(fp->current_storage))
#define THISOBJ (fp->current_object)
struct
poly
{
PFLOAT
xmin
,
ymin
,
xmax
,
ymax
;
struct
vertex
{
PFLOAT
x
,
y
;
struct
line
*
firstdown
;
struct
line
*
firstup
;
}
*
vertex
;
int
nvertex
;
int
nallocatedvertex
;
};
/*****************************************************************/
static
void
init_poly
(
struct
object
*
dummy
)
{
THIS
->
xmin
=
THIS
->
ymin
=
0
;
THIS
->
xmax
=
THIS
->
ymax
=-
1
;
THIS
->
vertex
=
NULL
;
THIS
->
nvertex
=
THIS
->
nallocatedvertex
=
0
;
}
static
void
exit_poly
(
struct
object
*
dummy
)
{
}
/*****************************************************************/
#define CMP(A,B) (((A)->y<(B)->y)?-1:((A)->y<(B)->y)?1: \
((A)->x<(B)->x)?-1:((A)->x<(B)->x)?1:0)
#define TYPE struct vertex
#define ID image_sort_vertex
#include
"../../fsort_template.h"
#undef CMP
#undef TYPE
#undef ID
static
void
image_poly_xor
(
INT32
args
);
static
void
image_poly_create
(
INT32
args
)
{
int
n
=
0
,
i
,
j
=
0
;
struct
vertex
*
v
;
struct
array
*
a
;
/* this is to get the correct error message */
for
(
i
=
0
;
i
<
args
;
i
++
)
if
(
sp
[
i
-
args
].
type
!=
T_ARRAY
)
SIMPLE_BAD_ARG_ERROR
(
"Poly"
,
i
+
1
,
"array"
);
if
(
args
>
1
)
/* make two poly objects and xor' them */
{
/* shrink and build args>1 to one poly */
push_object
(
clone_object
(
image_poly_program
,
args
-
1
));
stack_swap
();
/* really create this object */
image_poly_create
(
1
);
/* only the above created poly (args>1) left on stack, xor with this */
image_poly_xor
(
1
);
pop_stack
();
return
;
}
if
(
!
args
)
return
;
/* empty */
a
=
sp
[
-
1
].
u
.
array
;
v
=
THIS
->
vertex
=
(
struct
vertex
*
)
xalloc
(
sizeof
(
struct
vertex
)
*
a
->
size
/
2
);
for
(
n
=
i
=
0
;
i
<
a
->
size
-
1
;
i
+=
2
,
n
++
)
{
if
(
a
->
item
[
i
].
type
==
T_INT
)
v
[
n
].
x
=
(
PFLOAT
)
a
->
item
[
i
].
u
.
integer
;
else
if
(
a
->
item
[
i
].
type
==
T_FLOAT
)
v
[
n
].
x
=
(
PFLOAT
)
a
->
item
[
i
].
u
.
float_number
;
else
v
[
n
].
x
=
0
.
0
;
if
(
a
->
item
[
i
+
1
].
type
==
T_INT
)
v
[
n
].
y
=
(
PFLOAT
)
a
->
item
[
i
+
1
].
u
.
integer
;
else
if
(
a
->
item
[
i
+
1
].
type
==
T_FLOAT
)
v
[
n
].
y
=
(
PFLOAT
)
a
->
item
[
i
+
1
].
u
.
float_number
;
else
v
[
n
].
y
=
0
.
0
;
}
if
(
n
)
{
image_sort_vertex
(
v
,
v
+
n
-
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
fprintf
(
stderr
,
"%g,%g
\n
"
,
THIS
->
vertex
[
i
].
x
,
THIS
->
vertex
[
i
].
y
);
for
(
i
=
j
=
1
;
i
<
n
;
i
++
)
if
(
v
[
i
].
x
!=
v
[
i
-
1
].
x
||
v
[
i
].
y
!=
v
[
i
-
1
].
y
)
v
[
j
++
]
=
v
[
i
];
fprintf
(
stderr
,
"---
\n
"
);
}
THIS
->
nvertex
=
j
;
THIS
->
nallocatedvertex
=
n
;
for
(
i
=
0
;
i
<
THIS
->
nvertex
;
i
++
)
fprintf
(
stderr
,
"%g,%g
\n
"
,
THIS
->
vertex
[
i
].
x
,
THIS
->
vertex
[
i
].
y
);
}
/*****************************************************************/
static
void
image_poly_xor
(
INT32
args
)
{
pop_n_elems
(
args
);
ref_push_object
(
THISOBJ
);
}
/*****************************************************************/
static
void
image_poly_cast
(
INT32
args
)
{
error
(
"unimplemented"
);
}
/*****************************************************************/
void
init_image_poly
(
void
)
{
ADD_STORAGE
(
struct
poly
);
set_init_callback
(
init_poly
);
set_exit_callback
(
exit_poly
);
/* setup */
ADD_FUNCTION
(
"create"
,
image_poly_create
,
tFuncV
(
tNone
,
tArray
,
tVoid
),
0
);
/* query */
ADD_FUNCTION
(
"cast"
,
image_poly_cast
,
tFunc
(
tStr
,
tArray
),
0
);
}
void
exit_image_poly
(
void
)
{
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment